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();
|
const trackIds = this._getTrackIds();
|
||||||
if (!trackIds) return;
|
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);
|
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 { startPos, rotationDeg } = CurveHelper.transformStart(this.pos, this.rot, trackDef.pos, trackDef.rot);
|
||||||
|
|
||||||
const track = StandardTrack.createSwitchTrack(
|
const track = StandardTrack.createSwitchTrack(
|
||||||
|
this,
|
||||||
trackId,
|
trackId,
|
||||||
startPos,
|
startPos,
|
||||||
rotationDeg,
|
rotationDeg,
|
||||||
trackDef.length,
|
trackDef.length,
|
||||||
trackDef.radius,
|
trackDef.radius,
|
||||||
connections,
|
connections,
|
||||||
trackDef.slope1,
|
trackDef.slope1 ?? 0,
|
||||||
trackDef.slope2,
|
trackDef.slope2 ?? 0,
|
||||||
this,
|
trackDef.speedLimit ?? 999
|
||||||
);
|
);
|
||||||
scenery.addObject(track);
|
scenery.addObject(track);
|
||||||
return track;
|
return track;
|
||||||
|
|||||||
@ -99,20 +99,20 @@ export default class StandardTrack extends Track {
|
|||||||
return 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(
|
const track = new StandardTrack(
|
||||||
id, start, rot, len, r,
|
id, start, rot, len, r,
|
||||||
connections,
|
connections,
|
||||||
object.id_switch,
|
switchObj.id_switch,
|
||||||
start_slope,
|
start_slope,
|
||||||
end_slope,
|
end_slope,
|
||||||
object.id_isolation,
|
switchObj.id_isolation,
|
||||||
object.prefab_name,
|
switchObj.prefab_name,
|
||||||
object.maxspeed,
|
Math.min(switchObj.maxspeed, speed_limit),
|
||||||
object.derailspeed,
|
Math.min(switchObj.derailspeed, speed_limit),
|
||||||
TrackSource.SWITCH,
|
TrackSource.SWITCH,
|
||||||
);
|
);
|
||||||
track.switch = object;
|
track.switch = switchObj;
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user