1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-25 07:44:38 +01:00

Expose ride satisfaction to plugin api (#22172)

This commit is contained in:
Arnold Zhou
2024-07-08 18:53:14 +10:00
committed by GitHub
parent 1af27a62d9
commit aa11d8ddfe
5 changed files with 16 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
0.4.13 (in development)
------------------------------------------------------------------------
- Feature: [#22172] [Plugin] Expose ride satisfaction ratings to the plugin API.
0.4.12 (2024-07-07)
------------------------------------------------------------------------

View File

@@ -2115,6 +2115,11 @@ declare global {
* The min chain lift speed for this ride in miles per hour.
*/
readonly minLiftHillSpeed: number;
/**
* The satisfaction rating of the ride from 0 to 100.
*/
readonly satisfaction: number;
}
type RideClassification = "ride" | "stall" | "facility";

View File

@@ -47,7 +47,7 @@ namespace OpenRCT2
namespace OpenRCT2::Scripting
{
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 94;
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 95;
// Versions marking breaking changes.
static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33;

View File

@@ -524,6 +524,12 @@ namespace OpenRCT2::Scripting
return ride != nullptr ? ride->GetRideTypeDescriptor().LiftData.minimum_speed : 0;
}
uint8_t ScRide::satisfaction_get() const
{
auto ride = GetRide();
return ride != nullptr ? ride->satisfaction * 5 : 0;
}
void ScRide::Register(duk_context* ctx)
{
dukglue_register_property(ctx, &ScRide::id_get, nullptr, "id");
@@ -558,6 +564,7 @@ namespace OpenRCT2::Scripting
dukglue_register_property(ctx, &ScRide::liftHillSpeed_get, &ScRide::lifthillSpeed_set, "liftHillSpeed");
dukglue_register_property(ctx, &ScRide::maxLiftHillSpeed_get, nullptr, "maxLiftHillSpeed");
dukglue_register_property(ctx, &ScRide::minLiftHillSpeed_get, nullptr, "minLiftHillSpeed");
dukglue_register_property(ctx, &ScRide::satisfaction_get, nullptr, "satisfaction");
}
} // namespace OpenRCT2::Scripting

View File

@@ -163,6 +163,8 @@ namespace OpenRCT2::Scripting
uint8_t maxLiftHillSpeed_get() const;
uint8_t minLiftHillSpeed_get() const;
uint8_t satisfaction_get() const;
Ride* GetRide() const;
public: