mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 18:31:59 -05:00
Implement plugin getters for subposition and subposition length
This commit is contained in:
parent
05a9ef8b70
commit
7b5aeece59
8 changed files with 32 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
- Feature: [#16662] Show a warning message when g2.dat is mismatched.
|
||||
- Feature: [#17107] Ride operating settings can be set via text input.
|
||||
- Feature: [#17638] Added Zero G rolls, medium loops and large corkscrews to the Hybrid and Single-Rail coasters.
|
||||
- Feature: [#17821] [Plugin] Add API for track subposition length and vehicle subposition.
|
||||
- Feature: [#17877] Add three real-life flying roller coaster colour schemes.
|
||||
- Feature: [#17900] Add “Classic Wooden Coaster” with shallow banked turns.
|
||||
- Feature: [#6570, #10860, #17929] Fully support RollerCoaster Tycoon Classic as a RCT2 base install path.
|
||||
|
|
13
distribution/openrct2.d.ts
vendored
13
distribution/openrct2.d.ts
vendored
|
@ -107,7 +107,7 @@ declare global {
|
|||
* The direction is between 0 and 3.
|
||||
*/
|
||||
interface CoordsXYZD extends CoordsXYZ {
|
||||
direction: number;
|
||||
direction: Direction;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1244,6 +1244,11 @@ declare global {
|
|||
* Gets a list of the elements that make up the track segment.
|
||||
*/
|
||||
readonly elements: TrackSegmentElement[];
|
||||
|
||||
/**
|
||||
* Gets a length of the subpositions list for this track segment.
|
||||
*/
|
||||
getSubpositionLength(subpositionType: number, direction: Direction): number;
|
||||
}
|
||||
|
||||
enum TrackSlope {
|
||||
|
@ -1467,6 +1472,12 @@ declare global {
|
|||
*/
|
||||
readonly remainingDistance: number;
|
||||
|
||||
/**
|
||||
* The type of subposition coordinates that this vehicle is using to find its
|
||||
* position on the track.
|
||||
*/
|
||||
readonly subposition: number;
|
||||
|
||||
/**
|
||||
* List of guest IDs ordered by seat.
|
||||
* @deprecated since version 34, use guests instead.
|
||||
|
|
|
@ -664,7 +664,7 @@ const rct_vehicle_info* Vehicle::GetMoveInfo() const
|
|||
return vehicle_get_move_info(TrackSubposition, GetTrackType(), GetTrackDirection(), track_progress);
|
||||
}
|
||||
|
||||
static uint16_t vehicle_get_move_info_size(VehicleTrackSubposition trackSubposition, track_type_t type, uint8_t direction)
|
||||
uint16_t vehicle_get_move_info_size(VehicleTrackSubposition trackSubposition, track_type_t type, uint8_t direction)
|
||||
{
|
||||
uint16_t typeAndDirection = (type << 2) | (direction & 3);
|
||||
|
||||
|
|
|
@ -526,6 +526,7 @@ enum
|
|||
Vehicle* try_get_vehicle(EntityId spriteIndex);
|
||||
void vehicle_update_all();
|
||||
void vehicle_sounds_update();
|
||||
uint16_t vehicle_get_move_info_size(VehicleTrackSubposition trackSubposition, track_type_t type, uint8_t direction);
|
||||
|
||||
void RideUpdateMeasurementsSpecialElements_Default(Ride* ride, const track_type_t trackType);
|
||||
void RideUpdateMeasurementsSpecialElements_MiniGolf(Ride* ride, const track_type_t trackType);
|
||||
|
|
|
@ -75,6 +75,7 @@ namespace OpenRCT2::Scripting
|
|||
dukglue_register_property(ctx, &ScVehicle::trackLocation_get, &ScVehicle::trackLocation_set, "trackLocation");
|
||||
dukglue_register_property(ctx, &ScVehicle::trackProgress_get, nullptr, "trackProgress");
|
||||
dukglue_register_property(ctx, &ScVehicle::remainingDistance_get, nullptr, "remainingDistance");
|
||||
dukglue_register_property(ctx, &ScVehicle::subposition_get, nullptr, "subposition");
|
||||
dukglue_register_property(
|
||||
ctx, &ScVehicle::poweredAcceleration_get, &ScVehicle::poweredAcceleration_set, "poweredAcceleration");
|
||||
dukglue_register_property(ctx, &ScVehicle::poweredMaxSpeed_get, &ScVehicle::poweredMaxSpeed_set, "poweredMaxSpeed");
|
||||
|
@ -386,6 +387,12 @@ namespace OpenRCT2::Scripting
|
|||
return vehicle != nullptr ? vehicle->remaining_distance : 0;
|
||||
}
|
||||
|
||||
uint8_t ScVehicle::subposition_get() const
|
||||
{
|
||||
auto vehicle = GetVehicle();
|
||||
return vehicle != nullptr ? static_cast<uint8_t>(vehicle->TrackSubposition) : 0;
|
||||
}
|
||||
|
||||
uint8_t ScVehicle::poweredAcceleration_get() const
|
||||
{
|
||||
auto vehicle = GetVehicle();
|
||||
|
|
|
@ -77,6 +77,8 @@ namespace OpenRCT2::Scripting
|
|||
|
||||
int32_t remainingDistance_get() const;
|
||||
|
||||
uint8_t subposition_get() const;
|
||||
|
||||
uint8_t poweredAcceleration_get() const;
|
||||
void poweredAcceleration_set(uint8_t value);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
# include "../../../Context.h"
|
||||
# include "../../../ride/TrackData.h"
|
||||
# include "../../../ride/Vehicle.h"
|
||||
# include "../../ScriptEngine.h"
|
||||
|
||||
using namespace OpenRCT2::Scripting;
|
||||
|
@ -35,6 +36,7 @@ void ScTrackSegment::Register(duk_context* ctx)
|
|||
dukglue_register_property(ctx, &ScTrackSegment::endZ_get, nullptr, "endZ");
|
||||
dukglue_register_property(ctx, &ScTrackSegment::endDirection_get, nullptr, "endDirection");
|
||||
dukglue_register_property(ctx, &ScTrackSegment::length_get, nullptr, "length");
|
||||
dukglue_register_method(ctx, &ScTrackSegment::getSubpositionLength, "getSubpositionLength");
|
||||
}
|
||||
|
||||
int32_t ScTrackSegment::type_get() const
|
||||
|
@ -141,4 +143,9 @@ DukValue ScTrackSegment::elements_get() const
|
|||
return DukValue::take_from_stack(ctx);
|
||||
}
|
||||
|
||||
uint16_t ScTrackSegment::getSubpositionLength(uint8_t trackSubposition, uint8_t direction) const
|
||||
{
|
||||
return vehicle_get_move_info_size(static_cast<VehicleTrackSubposition>(trackSubposition), _type, direction);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace OpenRCT2::Scripting
|
|||
int32_t endBank_get() const;
|
||||
int32_t length_get() const;
|
||||
DukValue elements_get() const;
|
||||
uint16_t getSubpositionLength(uint8_t trackSubposition, uint8_t direction) const;
|
||||
};
|
||||
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
|
Loading…
Reference in a new issue