mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 10:21:57 -05:00
Expose guest's favourite ride (ID) to plugin API
This commit is contained in:
parent
a985931910
commit
01319ff352
6 changed files with 55 additions and 1 deletions
|
@ -119,6 +119,7 @@ Appreciation for contributors who have provided substantial work, but are no lon
|
|||
* Tiago Reul (reul) - Misc.
|
||||
* Fredrik Tegnell (fredriktegnell) - Misc.
|
||||
* Alex Parisi (alex-parisi) - Added API for returning metadata from all registered plugins.
|
||||
* Arnold Zhou (mrmagic2020) - Added plugin API for getting and setting guests' favourite rides.
|
||||
|
||||
## Bug fixes & Refactors
|
||||
* Claudio Tiecher (janclod)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
- Feature: [#21853] Enlarged UI mode.
|
||||
- Feature: [#21893, #22065] On launch, the game now indicates what system is being initialised.
|
||||
- Feature: [#21913] [Plugin] Allow precise and safe control of peep animations.
|
||||
- Feature: [#22087] [Plugin] Expose guests’ favourite rides to the plugin API.
|
||||
- Improved: [#19870] Allow using new colours in UI themes.
|
||||
- Improved: [#21853] Dropdowns now automatically use multiple columns if they are too tall for the screen.
|
||||
- Improved: [#21981] Rendering performance of the map window has been improved considerably.
|
||||
|
|
5
distribution/openrct2.d.ts
vendored
5
distribution/openrct2.d.ts
vendored
|
@ -2874,6 +2874,11 @@ declare global {
|
|||
* The total number of frames in the current animation.
|
||||
*/
|
||||
readonly animationLength: number;
|
||||
|
||||
/**
|
||||
* The ride ID of the guest's favourite ride.
|
||||
*/
|
||||
favouriteRide: number | null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace OpenRCT2
|
|||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 88;
|
||||
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 90;
|
||||
|
||||
// Versions marking breaking changes.
|
||||
static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33;
|
||||
|
|
|
@ -11,9 +11,11 @@
|
|||
|
||||
# include "ScGuest.hpp"
|
||||
|
||||
# include "../../../GameState.h"
|
||||
# include "../../../entity/Guest.h"
|
||||
# include "../../../localisation/Localisation.h"
|
||||
# include "../../../peep/PeepAnimationData.h"
|
||||
# include "../../../ride/RideEntry.h"
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -202,6 +204,7 @@ namespace OpenRCT2::Scripting
|
|||
dukglue_register_property(ctx, &ScGuest::isInPark_get, nullptr, "isInPark");
|
||||
dukglue_register_property(ctx, &ScGuest::isLost_get, nullptr, "isLost");
|
||||
dukglue_register_property(ctx, &ScGuest::lostCountdown_get, &ScGuest::lostCountdown_set, "lostCountdown");
|
||||
dukglue_register_property(ctx, &ScGuest::favouriteRide_get, &ScGuest::favouriteRide_set, "favouriteRide");
|
||||
dukglue_register_property(ctx, &ScGuest::thoughts_get, nullptr, "thoughts");
|
||||
dukglue_register_property(ctx, &ScGuest::items_get, nullptr, "items");
|
||||
dukglue_register_property(ctx, &ScGuest::availableAnimations_get, nullptr, "availableAnimations");
|
||||
|
@ -507,6 +510,47 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
}
|
||||
|
||||
DukValue ScGuest::favouriteRide_get() const
|
||||
{
|
||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||
auto* ctx = scriptEngine.GetContext();
|
||||
auto peep = GetGuest();
|
||||
if (peep != nullptr)
|
||||
{
|
||||
if (peep->FavouriteRide != RideId::GetNull())
|
||||
{
|
||||
duk_push_int(ctx, peep->FavouriteRide.ToUnderlying());
|
||||
}
|
||||
else
|
||||
{
|
||||
duk_push_null(ctx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
duk_push_null(ctx);
|
||||
}
|
||||
return DukValue::take_from_stack(ctx);
|
||||
}
|
||||
|
||||
void ScGuest::favouriteRide_set(const DukValue& value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
auto peep = GetGuest();
|
||||
if (peep != nullptr)
|
||||
{
|
||||
if (value.type() == DukValue::Type::NUMBER && value.as_uint() < GetGameState().Rides.size()
|
||||
&& GetGameState().Rides[value.as_uint()].type != RIDE_TYPE_NULL)
|
||||
{
|
||||
peep->FavouriteRide = RideId::FromUnderlying(value.as_uint());
|
||||
}
|
||||
else
|
||||
{
|
||||
peep->FavouriteRide = RideId::GetNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DukValue ScGuest::thoughts_get() const
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
|
|
|
@ -167,6 +167,9 @@ namespace OpenRCT2::Scripting
|
|||
uint8_t lostCountdown_get() const;
|
||||
void lostCountdown_set(uint8_t value);
|
||||
|
||||
DukValue favouriteRide_get() const;
|
||||
void favouriteRide_set(const DukValue& value);
|
||||
|
||||
DukValue thoughts_get() const;
|
||||
|
||||
DukValue items_get() const;
|
||||
|
|
Loading…
Reference in a new issue