Add Ride.totalProfit to the plugin API (#12795)

Add Ride.totalProfit to the plugin API
This commit is contained in:
Cory Sanin 2020-08-28 16:52:54 -05:00 committed by GitHub
parent b53c4b3625
commit 8d366ebaea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -804,6 +804,11 @@ declare global {
*/
runningCost: number;
/**
* The total profit of the ride over the course of its lifetime.
*/
totalProfit: number;
/**
* How often the ride should be inspected by a mechanic.
*/

View File

@ -582,6 +582,21 @@ namespace OpenRCT2::Scripting
}
}
int32_t totalProfit_get() const
{
auto ride = GetRide();
return ride != nullptr ? ride->total_profit : 0;
}
void totalProfit_set(int32_t value)
{
ThrowIfGameStateNotMutable();
auto ride = GetRide();
if (ride != nullptr)
{
ride->total_profit = value;
}
}
uint8_t inspectionInterval_get() const
{
auto ride = GetRide();
@ -660,6 +675,7 @@ namespace OpenRCT2::Scripting
dukglue_register_property(ctx, &ScRide::buildDate_get, &ScRide::buildDate_set, "buildDate");
dukglue_register_property(ctx, &ScRide::age_get, nullptr, "age");
dukglue_register_property(ctx, &ScRide::runningCost_get, &ScRide::runningCost_set, "runningCost");
dukglue_register_property(ctx, &ScRide::totalProfit_get, &ScRide::totalProfit_set, "totalProfit");
dukglue_register_property(
ctx, &ScRide::inspectionInterval_get, &ScRide::inspectionInterval_set, "inspectionInterval");
dukglue_register_property(ctx, &ScRide::value_get, &ScRide::value_set, "value");

View File

@ -41,7 +41,7 @@
using namespace OpenRCT2;
using namespace OpenRCT2::Scripting;
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 1;
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 2;
struct ExpressionStringifier final
{