1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-27 16:54:52 +01:00

Add more properties to track segment

This commit is contained in:
Ted John
2022-03-13 13:47:57 +00:00
parent b39f7643f0
commit 8c593709fa
3 changed files with 81 additions and 0 deletions

View File

@@ -649,6 +649,7 @@ declare global {
"surface" | "footpath" | "track" | "small_scenery" | "wall" | "entrance" | "large_scenery" | "banner";
type Direction = 0 | 1 | 2 | 3;
type Direction8 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
type TileElement =
SurfaceElement | FootpathElement | TrackElement | SmallSceneryElement | WallElement | EntranceElement
@@ -1154,6 +1155,38 @@ declare global {
*/
readonly description: string;
/**
* The relative starting Z position.
*/
readonly beginZ: number;
/**
* The relative starting direction. Usually 0, but will be 4
* for diagonal pieces.
*/
readonly beginDirection: Direction8;
/**
* The relative ending X position.
*/
readonly endX: number;
/**
* The relative ending Y position.
*/
readonly endY: number;
/**
* The relative ending Z position. Negative numbers indicate
* that the track ends upside down.
*/
readonly endZ: number;
/**
* The relative ending direction.
*/
readonly endDirection: Direction8;
/**
* Gets a list of the elements that make up the track segment.
*/

View File

@@ -28,6 +28,12 @@ void ScTrackSegment::Register(duk_context* ctx)
dukglue_register_property(ctx, &ScTrackSegment::type_get, nullptr, "type");
dukglue_register_property(ctx, &ScTrackSegment::description_get, nullptr, "description");
dukglue_register_property(ctx, &ScTrackSegment::elements_get, nullptr, "elements");
dukglue_register_property(ctx, &ScTrackSegment::beginZ, nullptr, "beginZ");
dukglue_register_property(ctx, &ScTrackSegment::beginDirection, nullptr, "beginDirection");
dukglue_register_property(ctx, &ScTrackSegment::endX, nullptr, "endX");
dukglue_register_property(ctx, &ScTrackSegment::endY, nullptr, "endY");
dukglue_register_property(ctx, &ScTrackSegment::endZ, nullptr, "endZ");
dukglue_register_property(ctx, &ScTrackSegment::endDirection, nullptr, "endDirection");
}
int32_t ScTrackSegment::type_get() const
@@ -41,6 +47,42 @@ std::string ScTrackSegment::description_get() const
return language_get_string(ted.Description);
}
int32_t ScTrackSegment::beginZ() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.z_begin;
}
int32_t ScTrackSegment::beginDirection() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.rotation_begin;
}
int32_t ScTrackSegment::endX() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.x;
}
int32_t ScTrackSegment::endY() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.y;
}
int32_t ScTrackSegment::endZ() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.z_end;
}
int32_t ScTrackSegment::endDirection() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.rotation_end;
}
DukValue ScTrackSegment::elements_get() const
{
auto& scriptEngine = GetContext()->GetScriptEngine();

View File

@@ -32,6 +32,12 @@ namespace OpenRCT2::Scripting
private:
int32_t type_get() const;
std::string description_get() const;
int32_t beginZ() const;
int32_t beginDirection() const;
int32_t endX() const;
int32_t endY() const;
int32_t endZ() const;
int32_t endDirection() const;
DukValue elements_get() const;
};