Improved switches aliases resolution
+Added an option to include additional aliases indexes in switches definitions +Added additional aliases indexes for switches Rz 60E1-300-1_9 R / L and Rz 60E1-190-1_9 R / L
This commit is contained in:
parent
479610aaaf
commit
7f908f24ab
@ -22,7 +22,7 @@ const DefinedSwitches = {
|
|||||||
"Rz 60E1-300-1_9 R": [
|
"Rz 60E1-300-1_9 R": [
|
||||||
0,
|
0,
|
||||||
-300,
|
-300,
|
||||||
[0, 0, 3, 4],
|
[0, 0, 3, 4, 2, 1],
|
||||||
new Vector3(0, 0, 0),
|
new Vector3(0, 0, 0),
|
||||||
new Vector3(0, 0, 0),
|
new Vector3(0, 0, 0),
|
||||||
new Vector3(0, 0, 33.231),
|
new Vector3(0, 0, 33.231),
|
||||||
@ -31,7 +31,7 @@ const DefinedSwitches = {
|
|||||||
"Rz 60E1-300-1_9 L": [
|
"Rz 60E1-300-1_9 L": [
|
||||||
0,
|
0,
|
||||||
300,
|
300,
|
||||||
[0, 0, 3, 4],
|
[0, 0, 3, 4, 2, 1],
|
||||||
new Vector3(0, 0, 0),
|
new Vector3(0, 0, 0),
|
||||||
new Vector3(0, 0, 0),
|
new Vector3(0, 0, 0),
|
||||||
new Vector3(0, 0, 33.231),
|
new Vector3(0, 0, 33.231),
|
||||||
@ -40,7 +40,7 @@ const DefinedSwitches = {
|
|||||||
"Rz 60E1-190-1_9 R": [
|
"Rz 60E1-190-1_9 R": [
|
||||||
0,
|
0,
|
||||||
-190,
|
-190,
|
||||||
[0, 0, 5, 6],
|
[0, 0, 5, 6, 3, 4],
|
||||||
new Vector3(0, 0, 0),
|
new Vector3(0, 0, 0),
|
||||||
new Vector3(0, 0, 0),
|
new Vector3(0, 0, 0),
|
||||||
new Vector3(0, 0, 27.139),
|
new Vector3(0, 0, 27.139),
|
||||||
@ -49,7 +49,7 @@ const DefinedSwitches = {
|
|||||||
"Rz 60E1-190-1_9 L": [
|
"Rz 60E1-190-1_9 L": [
|
||||||
0,
|
0,
|
||||||
190,
|
190,
|
||||||
[0, 0, 5, 6],
|
[0, 0, 5, 6, 3, 4],
|
||||||
new Vector3(0, 0, 0),
|
new Vector3(0, 0, 0),
|
||||||
new Vector3(0, 0, 0),
|
new Vector3(0, 0, 0),
|
||||||
new Vector3(0, 0, 27.139),
|
new Vector3(0, 0, 27.139),
|
||||||
|
|||||||
@ -84,14 +84,27 @@ export default class Switch extends SceneryObject {
|
|||||||
|
|
||||||
this.def = def;
|
this.def = def;
|
||||||
|
|
||||||
const trackAAliases = Array.from(new Set([ids[0][0], ids[2][0]]));
|
const trackAAliases = this._getTrackAliases(ids);
|
||||||
this.trackA = this._createSwitchTrackFromDef(scenery, this.id+"A", def[0], ids[0][1], ids[2][1], def[3], def[5], trackAAliases);
|
this.trackA = this._createSwitchTrackFromDef(scenery, this.id+"A", def[0], ids[0][1], ids[2][1], def[3], def[5], trackAAliases);
|
||||||
|
|
||||||
const trackBAliases = Array.from(new Set([ids[1][0], ids[3][0]])).filter(alias => trackAAliases.includes(alias) === false);
|
const trackBAliases = this._getTrackAliases(ids, 1, trackAAliases);
|
||||||
this.trackB = this._createSwitchTrackFromDef(scenery, this.id+"B", def[1], ids[1][1], ids[3][1], def[4], def[6], trackBAliases);
|
this.trackB = this._createSwitchTrackFromDef(scenery, this.id+"B", def[1], ids[1][1], ids[3][1], def[4], def[6], trackBAliases);
|
||||||
this.trackB.hide_isolation = true; // hide isolation for the second track
|
this.trackB.hide_isolation = true; // hide isolation for the second track
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getTrackAliases(ids, startingId = 0, exclude = []) {
|
||||||
|
const aliases = new Set();
|
||||||
|
for(let i = startingId; i < ids.length; i+=2) {
|
||||||
|
aliases.add(ids[i][0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
exclude.forEach(alias => {
|
||||||
|
aliases.delete(alias);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Array.from(aliases);
|
||||||
|
}
|
||||||
|
|
||||||
_getTrackIds(outs) {
|
_getTrackIds(outs) {
|
||||||
const dataValues = this.data.split(",");
|
const dataValues = this.data.split(",");
|
||||||
const isCrossing = outs.length === 2;
|
const isCrossing = outs.length === 2;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user