Improved switches
+Added support for the speedLimit field in switch definitions *Updated defined-switches.js, removing unused fields and adding speedLimit *Changed the header of StandardTrack.createSwitchTrack
This commit is contained in:
parent
415878ba02
commit
5f57eb24ee
File diff suppressed because it is too large
Load Diff
@ -80,7 +80,7 @@ export default class Switch extends SceneryObject {
|
||||
const trackIds = this._getTrackIds();
|
||||
if (!trackIds) return;
|
||||
|
||||
const tracks = Object.entries(def.tracks).map(([key, track]) => {
|
||||
const tracks = Object.values(def.tracks).map((track) => {
|
||||
return this._createSwitchTrackFromDef(scenery, def, track, trackIds);
|
||||
});
|
||||
|
||||
@ -155,15 +155,16 @@ export default class Switch extends SceneryObject {
|
||||
const { startPos, rotationDeg } = CurveHelper.transformStart(this.pos, this.rot, trackDef.pos, trackDef.rot);
|
||||
|
||||
const track = StandardTrack.createSwitchTrack(
|
||||
this,
|
||||
trackId,
|
||||
startPos,
|
||||
rotationDeg,
|
||||
trackDef.length,
|
||||
trackDef.radius,
|
||||
connections,
|
||||
trackDef.slope1,
|
||||
trackDef.slope2,
|
||||
this,
|
||||
trackDef.slope1 ?? 0,
|
||||
trackDef.slope2 ?? 0,
|
||||
trackDef.speedLimit ?? 999
|
||||
);
|
||||
scenery.addObject(track);
|
||||
return track;
|
||||
|
||||
@ -99,20 +99,20 @@ export default class StandardTrack extends Track {
|
||||
return track;
|
||||
}
|
||||
|
||||
static createSwitchTrack(id, start, rot, len, r, connections, start_slope, end_slope, object) {
|
||||
static createSwitchTrack(switchObj, id, start, rot, len, r, connections, start_slope, end_slope, speed_limit) {
|
||||
const track = new StandardTrack(
|
||||
id, start, rot, len, r,
|
||||
connections,
|
||||
object.id_switch,
|
||||
switchObj.id_switch,
|
||||
start_slope,
|
||||
end_slope,
|
||||
object.id_isolation,
|
||||
object.prefab_name,
|
||||
object.maxspeed,
|
||||
object.derailspeed,
|
||||
switchObj.id_isolation,
|
||||
switchObj.prefab_name,
|
||||
Math.min(switchObj.maxspeed, speed_limit),
|
||||
Math.min(switchObj.derailspeed, speed_limit),
|
||||
TrackSource.SWITCH,
|
||||
);
|
||||
track.switch = object;
|
||||
track.switch = switchObj;
|
||||
return track;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user