1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Add extra fields to TrackSegment

This commit is contained in:
Ted John
2022-04-30 16:09:01 +01:00
parent 8c593709fa
commit bf1e3412a5
3 changed files with 70 additions and 27 deletions

View File

@@ -1160,17 +1160,27 @@ declare global {
*/
readonly beginZ: number;
/**
* The relative starting direction. Usually 0, but will be 4
* for diagonal pieces.
*/
/**
* The relative starting direction. Usually 0, but will be 4
* for diagonal segments.
*/
readonly beginDirection: Direction8;
/**
* The slope angle the segment starts with.
*/
readonly beginAngle: number;
/**
* The kind of banking the segment starts with.
*/
readonly beginBank: TrackBanking;
/**
* The relative ending X position.
*/
readonly endX: number;
/**
* The relative ending Y position.
*/
@@ -1180,12 +1190,30 @@ declare global {
* The relative ending Z position. Negative numbers indicate
* that the track ends upside down.
*/
readonly endZ: number;
readonly endZ: number;
/**
* The relative ending direction.
*/
readonly endDirection: Direction8;
readonly endDirection: Direction8;
/**
* The slope angle the segment ends with.
*/
readonly endAngle: number;
/**
* The kind of banking the segment ends with.
*/
readonly endBank: TrackBanking;
/**
* The length of the segment in RCT track length units.
*
* *1 metre = 1 / (2 ^ 16)*
*/
readonly length: number;
/**
* Gets a list of the elements that make up the track segment.
@@ -1193,7 +1221,14 @@ declare global {
readonly elements: TrackSegmentElement[];
}
interface TrackSegmentElement implements CoordsXYZ {
enum TrackBanking {
None = 0,
Left = 2,
Right = 4,
UpsideDown = 15
}
interface TrackSegmentElement extends CoordsXYZ {
}
interface TrackIterator {
@@ -1201,7 +1236,7 @@ declare global {
* The position and direction of the current track segment. Usually this is the position of the
* element of the segment, however for some segments, it may be offset.
*/
readonly position: CoordsXYZD;
readonly position: CoordsXYZD;
/**
* The current track segment.

View File

@@ -28,12 +28,13 @@ 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");
dukglue_register_property(ctx, &ScTrackSegment::beginZ_get, nullptr, "beginZ");
dukglue_register_property(ctx, &ScTrackSegment::beginDirection_get, nullptr, "beginDirection");
dukglue_register_property(ctx, &ScTrackSegment::endX_get, nullptr, "endX");
dukglue_register_property(ctx, &ScTrackSegment::endY_get, nullptr, "endY");
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");
}
int32_t ScTrackSegment::type_get() const
@@ -47,42 +48,48 @@ std::string ScTrackSegment::description_get() const
return language_get_string(ted.Description);
}
int32_t ScTrackSegment::beginZ() const
int32_t ScTrackSegment::beginZ_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.z_begin;
}
int32_t ScTrackSegment::beginDirection() const
int32_t ScTrackSegment::beginDirection_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.rotation_begin;
}
int32_t ScTrackSegment::endX() const
int32_t ScTrackSegment::endX_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.x;
}
int32_t ScTrackSegment::endY() const
int32_t ScTrackSegment::endY_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.y;
}
int32_t ScTrackSegment::endZ() const
int32_t ScTrackSegment::endZ_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.z_end;
}
int32_t ScTrackSegment::endDirection() const
int32_t ScTrackSegment::endDirection_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.rotation_end;
}
int32_t ScTrackSegment::length_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.PieceLength;
}
DukValue ScTrackSegment::elements_get() const
{
auto& scriptEngine = GetContext()->GetScriptEngine();

View File

@@ -32,12 +32,13 @@ 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;
int32_t beginZ_get() const;
int32_t beginDirection_get() const;
int32_t endX_get() const;
int32_t endY_get() const;
int32_t endZ_get() const;
int32_t endDirection_get() const;
int32_t length_get() const;
DukValue elements_get() const;
};