expose Vehicle.spin_sprite to Car scripting (#22392)

* expose spinSprite to Car scripting

---------

Co-authored-by: Guy Sviry <guy@axissecurity.com>
This commit is contained in:
Guy Sviry 2024-08-07 20:13:33 +03:00 committed by GitHub
parent 2f39ee55f7
commit 332df0f1db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 33 additions and 1 deletions

View file

@ -1,6 +1,7 @@
0.4.14 (in development) 0.4.14 (in development)
------------------------------------------------------------------------ ------------------------------------------------------------------------
- Feature: [#15750] Allow using different types of park entrance in one park. - Feature: [#15750] Allow using different types of park entrance in one park.
- Feature: [#22392] [Plugin] Expose ride vehicles spin to the plugin API.
- Feature: [#22414] Finance graphs can be resized. - Feature: [#22414] Finance graphs can be resized.
- Change: [#21659] Increase the Hybrid Roller Coasters maximum lift speed to 17 km/h (11 mph). - Change: [#21659] Increase the Hybrid Roller Coasters maximum lift speed to 17 km/h (11 mph).
- Change: [#22466] The Clear Scenery tool now uses a bulldozer cursor instead of a generic crosshair. - Change: [#22466] The Clear Scenery tool now uses a bulldozer cursor instead of a generic crosshair.

View file

@ -2562,6 +2562,14 @@ declare global {
*/ */
status: VehicleStatus; status: VehicleStatus;
/**
* Current vehicle spin rotation.
* Values are 0-255. The game actually only considers the higher
* 5 bits when rendering.
*/
spin: number;
/** /**
* The location and direction of where the car is on the track. * The location and direction of where the car is on the track.
*/ */

View file

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

View file

@ -83,6 +83,7 @@ namespace OpenRCT2::Scripting
ctx, &ScVehicle::poweredAcceleration_get, &ScVehicle::poweredAcceleration_set, "poweredAcceleration"); ctx, &ScVehicle::poweredAcceleration_get, &ScVehicle::poweredAcceleration_set, "poweredAcceleration");
dukglue_register_property(ctx, &ScVehicle::poweredMaxSpeed_get, &ScVehicle::poweredMaxSpeed_set, "poweredMaxSpeed"); dukglue_register_property(ctx, &ScVehicle::poweredMaxSpeed_get, &ScVehicle::poweredMaxSpeed_set, "poweredMaxSpeed");
dukglue_register_property(ctx, &ScVehicle::status_get, &ScVehicle::status_set, "status"); dukglue_register_property(ctx, &ScVehicle::status_get, &ScVehicle::status_set, "status");
dukglue_register_property(ctx, &ScVehicle::spin_get, &ScVehicle::spin_set, "spin");
dukglue_register_property(ctx, &ScVehicle::guests_get, nullptr, "peeps"); dukglue_register_property(ctx, &ScVehicle::guests_get, nullptr, "peeps");
dukglue_register_property(ctx, &ScVehicle::guests_get, nullptr, "guests"); dukglue_register_property(ctx, &ScVehicle::guests_get, nullptr, "guests");
dukglue_register_property(ctx, &ScVehicle::gForces_get, nullptr, "gForces"); dukglue_register_property(ctx, &ScVehicle::gForces_get, nullptr, "gForces");
@ -476,6 +477,25 @@ namespace OpenRCT2::Scripting
} }
} }
uint8_t ScVehicle::spin_get() const
{
auto vehicle = GetVehicle();
if (vehicle != nullptr)
{
return vehicle->spin_sprite;
}
return 0;
}
void ScVehicle::spin_set(const uint8_t value)
{
ThrowIfGameStateNotMutable();
auto vehicle = GetVehicle();
if (vehicle != nullptr)
{
vehicle->spin_sprite = value;
}
}
std::vector<DukValue> ScVehicle::guests_get() const std::vector<DukValue> ScVehicle::guests_get() const
{ {
auto ctx = GetContext()->GetScriptEngine().GetContext(); auto ctx = GetContext()->GetScriptEngine().GetContext();

View file

@ -91,6 +91,9 @@ namespace OpenRCT2::Scripting
std::string status_get() const; std::string status_get() const;
void status_set(const std::string& value); void status_set(const std::string& value);
uint8_t spin_get() const;
void spin_set(uint8_t value);
std::vector<DukValue> guests_get() const; std::vector<DukValue> guests_get() const;
DukValue gForces_get() const; DukValue gForces_get() const;