@@ -40,16 +40,21 @@ namespace Orts.Simulation
40
40
41
41
public class Transfertable : MovingTable
42
42
{
43
- public float Width ;
43
+ public float Span ; // horizontal or vertical
44
44
public List < float > Offsets = new List < float > ( ) ;
45
+ private bool VerticalTransfer = false ;
46
+ public float CenterOffsetComponent
47
+ {
48
+ get => VerticalTransfer ? CenterOffset . Y : CenterOffset . X ;
49
+ }
45
50
// Dynamic data
46
51
public bool Forward ; // forward motion on
47
52
public bool Reverse ; // reverse motion on
48
- public float XPos = 0 ; // X Position of animated part, to be compared with X positions of endpoints
53
+ public float OffsetPos = 0 ; // Offset Position of animated part, to be compared with offset positions of endpoints
49
54
public bool Connected = true ; // Transfertable is connected to a track
50
55
public bool SaveConnected = true ; // Transfertable is connected to a track
51
56
public int ConnectedTarget = - 1 ; // index of trackend connected
52
- public float TargetX = 0 ; //final target for Viewer;
57
+ public float TargetOffset = 0 ; //final target for Viewer;
53
58
54
59
public Signals signalRef { get ; protected set ; }
55
60
@@ -68,9 +73,11 @@ public Transfertable(STFReader stf, Simulator simulator): base(stf, simulator)
68
73
new STFReader . TokenProcessor ( "uid" , ( ) => { UID = stf . ReadIntBlock ( - 1 ) ; } ) ,
69
74
new STFReader . TokenProcessor ( "animation" , ( ) => { animation = stf . ReadStringBlock ( null ) ;
70
75
Animations . Add ( animation . ToLower ( ) ) ; } ) ,
76
+ new STFReader . TokenProcessor ( "verticaltransfer" , ( ) => { VerticalTransfer = stf . ReadBoolBlock ( false ) ; } ) ,
71
77
new STFReader . TokenProcessor ( "length" , ( ) => { Length = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; } ) ,
72
78
new STFReader . TokenProcessor ( "xoffset" , ( ) => { CenterOffset . X = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; } ) ,
73
79
new STFReader . TokenProcessor ( "zoffset" , ( ) => { CenterOffset . Z = - stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; } ) ,
80
+ new STFReader . TokenProcessor ( "yoffset" , ( ) => { CenterOffset . Y = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; } ) ,
74
81
new STFReader . TokenProcessor ( "trackshapeindex" , ( ) =>
75
82
{
76
83
TrackShapeIndex = stf . ReadIntBlock ( - 1 ) ;
@@ -88,11 +95,11 @@ public override void Save(BinaryWriter outf)
88
95
base . Save ( outf ) ;
89
96
outf . Write ( Forward ) ;
90
97
outf . Write ( Reverse ) ;
91
- outf . Write ( XPos ) ;
98
+ outf . Write ( OffsetPos ) ;
92
99
outf . Write ( Connected ) ;
93
100
outf . Write ( SaveConnected ) ;
94
101
outf . Write ( ConnectedTarget ) ;
95
- outf . Write ( TargetX ) ;
102
+ outf . Write ( TargetOffset ) ;
96
103
}
97
104
98
105
@@ -105,11 +112,11 @@ public override void Restore(BinaryReader inf, Simulator simulator)
105
112
base . Restore ( inf , simulator ) ;
106
113
Forward = inf . ReadBoolean ( ) ;
107
114
Reverse = inf . ReadBoolean ( ) ;
108
- XPos = inf . ReadSingle ( ) ;
115
+ OffsetPos = inf . ReadSingle ( ) ;
109
116
Connected = inf . ReadBoolean ( ) ;
110
117
SaveConnected = inf . ReadBoolean ( ) ;
111
118
ConnectedTarget = inf . ReadInt32 ( ) ;
112
- TargetX = inf . ReadSingle ( ) ;
119
+ TargetOffset = inf . ReadSingle ( ) ;
113
120
}
114
121
115
122
protected void InitializeOffsetsAndTrackNodes ( )
@@ -122,7 +129,7 @@ protected void InitializeOffsetsAndTrackNodes()
122
129
var iMyTrackNodes = 0 ;
123
130
foreach ( var sectionIdx in trackShape . SectionIdxs )
124
131
{
125
- Offsets . Add ( ( float ) sectionIdx . X ) ;
132
+ Offsets . Add ( VerticalTransfer ? ( float ) sectionIdx . Y : ( float ) sectionIdx . X ) ;
126
133
MyTrackNodesIndex [ iMyTrackNodes ] = - 1 ;
127
134
MyTrVectorSectionsIndex [ iMyTrackNodes ] = - 1 ;
128
135
iMyTrackNodes ++ ;
@@ -148,9 +155,16 @@ protected void InitializeOffsetsAndTrackNodes()
148
155
}
149
156
}
150
157
}
151
- XPos = CenterOffset . X ;
152
- // Compute width of transfer table
153
- Width = ( float ) ( trackShape . SectionIdxs [ trackShape . SectionIdxs . Length - 1 ] . X - trackShape . SectionIdxs [ 0 ] . X ) ;
158
+ if ( VerticalTransfer )
159
+ {
160
+ OffsetPos = CenterOffset . Y ;
161
+ Span = ( float ) ( trackShape . SectionIdxs [ trackShape . SectionIdxs . Length - 1 ] . Y - trackShape . SectionIdxs [ 0 ] . Y ) ;
162
+ }
163
+ else
164
+ {
165
+ OffsetPos = CenterOffset . X ;
166
+ Span = ( float ) ( trackShape . SectionIdxs [ trackShape . SectionIdxs . Length - 1 ] . X - trackShape . SectionIdxs [ 0 ] . X ) ;
167
+ }
154
168
}
155
169
156
170
/// <summary>
@@ -179,7 +193,7 @@ public override void ComputeTarget(bool isForward)
179
193
{
180
194
if ( MyTrackNodesIndex [ iOffset ] != - 1 && MyTrVectorSectionsIndex [ iOffset ] != - 1 )
181
195
{
182
- var thisOffsetDiff = Offsets [ iOffset ] - XPos ;
196
+ var thisOffsetDiff = Offsets [ iOffset ] - OffsetPos ;
183
197
if ( thisOffsetDiff < offsetDiff && thisOffsetDiff >= 0 )
184
198
{
185
199
ConnectedTarget = iOffset ;
@@ -210,7 +224,7 @@ public override void ComputeTarget(bool isForward)
210
224
{
211
225
if ( MyTrackNodesIndex [ iOffset ] != - 1 && MyTrVectorSectionsIndex [ iOffset ] != - 1 )
212
226
{
213
- var thisOffsetDiff = Offsets [ iOffset ] - XPos ;
227
+ var thisOffsetDiff = Offsets [ iOffset ] - OffsetPos ;
214
228
if ( thisOffsetDiff > offsetDiff && thisOffsetDiff <= 0 )
215
229
{
216
230
ConnectedTarget = iOffset ;
@@ -292,7 +306,10 @@ public override void StartContinuous(bool isForward)
292
306
public void ComputeCenter ( WorldPosition worldPosition )
293
307
{
294
308
Vector3 movingCenterOffset = CenterOffset ;
295
- movingCenterOffset . X = XPos ;
309
+ if ( VerticalTransfer )
310
+ movingCenterOffset . Y = OffsetPos ;
311
+ else
312
+ movingCenterOffset . X = OffsetPos ;
296
313
Vector3 originCoordinates ;
297
314
Vector3 . Transform ( ref movingCenterOffset , ref worldPosition . XNAMatrix , out originCoordinates ) ;
298
315
WorldPosition = new WorldPosition ( worldPosition ) ;
@@ -340,14 +357,14 @@ public override void Update()
340
357
Connected = false ;
341
358
if ( ConnectedTarget != - 1 )
342
359
{
343
- if ( Offsets [ ConnectedTarget ] - XPos < 0.005 )
360
+ if ( Offsets [ ConnectedTarget ] - OffsetPos < 0.005 )
344
361
{
345
362
Connected = true ;
346
363
Forward = false ;
347
364
ConnectedTrackEnd = ConnectedTarget ;
348
365
Simulator . Confirmer . Information ( Simulator . Catalog . GetStringFmt ( "Transfertable connected" ) ) ;
349
366
GoToTarget = true ;
350
- TargetX = Offsets [ ConnectedTarget ] ;
367
+ TargetOffset = Offsets [ ConnectedTarget ] ;
351
368
}
352
369
}
353
370
}
@@ -356,14 +373,14 @@ public override void Update()
356
373
Connected = false ;
357
374
if ( ConnectedTarget != - 1 )
358
375
{
359
- if ( XPos - Offsets [ ConnectedTarget ] < 0.005 )
376
+ if ( OffsetPos - Offsets [ ConnectedTarget ] < 0.005 )
360
377
{
361
378
Connected = true ;
362
379
Reverse = false ;
363
380
ConnectedTrackEnd = ConnectedTarget ;
364
381
Simulator . Confirmer . Information ( Simulator . Catalog . GetStringFmt ( "Transfertable connected" ) ) ;
365
382
GoToTarget = true ;
366
- TargetX = Offsets [ ConnectedTarget ] ;
383
+ TargetOffset = Offsets [ ConnectedTarget ] ;
367
384
}
368
385
}
369
386
}
0 commit comments