@@ -40,16 +40,21 @@ namespace Orts.Simulation
4040
4141 public class Transfertable : MovingTable
4242 {
43- public float Width ;
43+ public float Span ; // horizontal or vertical
4444 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+ }
4550 // Dynamic data
4651 public bool Forward ; // forward motion on
4752 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
4954 public bool Connected = true ; // Transfertable is connected to a track
5055 public bool SaveConnected = true ; // Transfertable is connected to a track
5156 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;
5358
5459 public Signals signalRef { get ; protected set ; }
5560
@@ -68,9 +73,11 @@ public Transfertable(STFReader stf, Simulator simulator): base(stf, simulator)
6873 new STFReader . TokenProcessor ( "uid" , ( ) => { UID = stf . ReadIntBlock ( - 1 ) ; } ) ,
6974 new STFReader . TokenProcessor ( "animation" , ( ) => { animation = stf . ReadStringBlock ( null ) ;
7075 Animations . Add ( animation . ToLower ( ) ) ; } ) ,
76+ new STFReader . TokenProcessor ( "verticaltransfer" , ( ) => { VerticalTransfer = stf . ReadBoolBlock ( false ) ; } ) ,
7177 new STFReader . TokenProcessor ( "length" , ( ) => { Length = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; } ) ,
7278 new STFReader . TokenProcessor ( "xoffset" , ( ) => { CenterOffset . X = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; } ) ,
7379 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 ) ; } ) ,
7481 new STFReader . TokenProcessor ( "trackshapeindex" , ( ) =>
7582 {
7683 TrackShapeIndex = stf . ReadIntBlock ( - 1 ) ;
@@ -88,11 +95,11 @@ public override void Save(BinaryWriter outf)
8895 base . Save ( outf ) ;
8996 outf . Write ( Forward ) ;
9097 outf . Write ( Reverse ) ;
91- outf . Write ( XPos ) ;
98+ outf . Write ( OffsetPos ) ;
9299 outf . Write ( Connected ) ;
93100 outf . Write ( SaveConnected ) ;
94101 outf . Write ( ConnectedTarget ) ;
95- outf . Write ( TargetX ) ;
102+ outf . Write ( TargetOffset ) ;
96103 }
97104
98105
@@ -105,11 +112,11 @@ public override void Restore(BinaryReader inf, Simulator simulator)
105112 base . Restore ( inf , simulator ) ;
106113 Forward = inf . ReadBoolean ( ) ;
107114 Reverse = inf . ReadBoolean ( ) ;
108- XPos = inf . ReadSingle ( ) ;
115+ OffsetPos = inf . ReadSingle ( ) ;
109116 Connected = inf . ReadBoolean ( ) ;
110117 SaveConnected = inf . ReadBoolean ( ) ;
111118 ConnectedTarget = inf . ReadInt32 ( ) ;
112- TargetX = inf . ReadSingle ( ) ;
119+ TargetOffset = inf . ReadSingle ( ) ;
113120 }
114121
115122 protected void InitializeOffsetsAndTrackNodes ( )
@@ -122,7 +129,7 @@ protected void InitializeOffsetsAndTrackNodes()
122129 var iMyTrackNodes = 0 ;
123130 foreach ( var sectionIdx in trackShape . SectionIdxs )
124131 {
125- Offsets . Add ( ( float ) sectionIdx . X ) ;
132+ Offsets . Add ( VerticalTransfer ? ( float ) sectionIdx . Y : ( float ) sectionIdx . X ) ;
126133 MyTrackNodesIndex [ iMyTrackNodes ] = - 1 ;
127134 MyTrVectorSectionsIndex [ iMyTrackNodes ] = - 1 ;
128135 iMyTrackNodes ++ ;
@@ -148,9 +155,16 @@ protected void InitializeOffsetsAndTrackNodes()
148155 }
149156 }
150157 }
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+ }
154168 }
155169
156170 /// <summary>
@@ -179,7 +193,7 @@ public override void ComputeTarget(bool isForward)
179193 {
180194 if ( MyTrackNodesIndex [ iOffset ] != - 1 && MyTrVectorSectionsIndex [ iOffset ] != - 1 )
181195 {
182- var thisOffsetDiff = Offsets [ iOffset ] - XPos ;
196+ var thisOffsetDiff = Offsets [ iOffset ] - OffsetPos ;
183197 if ( thisOffsetDiff < offsetDiff && thisOffsetDiff >= 0 )
184198 {
185199 ConnectedTarget = iOffset ;
@@ -210,7 +224,7 @@ public override void ComputeTarget(bool isForward)
210224 {
211225 if ( MyTrackNodesIndex [ iOffset ] != - 1 && MyTrVectorSectionsIndex [ iOffset ] != - 1 )
212226 {
213- var thisOffsetDiff = Offsets [ iOffset ] - XPos ;
227+ var thisOffsetDiff = Offsets [ iOffset ] - OffsetPos ;
214228 if ( thisOffsetDiff > offsetDiff && thisOffsetDiff <= 0 )
215229 {
216230 ConnectedTarget = iOffset ;
@@ -292,7 +306,10 @@ public override void StartContinuous(bool isForward)
292306 public void ComputeCenter ( WorldPosition worldPosition )
293307 {
294308 Vector3 movingCenterOffset = CenterOffset ;
295- movingCenterOffset . X = XPos ;
309+ if ( VerticalTransfer )
310+ movingCenterOffset . Y = OffsetPos ;
311+ else
312+ movingCenterOffset . X = OffsetPos ;
296313 Vector3 originCoordinates ;
297314 Vector3 . Transform ( ref movingCenterOffset , ref worldPosition . XNAMatrix , out originCoordinates ) ;
298315 WorldPosition = new WorldPosition ( worldPosition ) ;
@@ -340,14 +357,14 @@ public override void Update()
340357 Connected = false ;
341358 if ( ConnectedTarget != - 1 )
342359 {
343- if ( Offsets [ ConnectedTarget ] - XPos < 0.005 )
360+ if ( Offsets [ ConnectedTarget ] - OffsetPos < 0.005 )
344361 {
345362 Connected = true ;
346363 Forward = false ;
347364 ConnectedTrackEnd = ConnectedTarget ;
348365 Simulator . Confirmer . Information ( Simulator . Catalog . GetStringFmt ( "Transfertable connected" ) ) ;
349366 GoToTarget = true ;
350- TargetX = Offsets [ ConnectedTarget ] ;
367+ TargetOffset = Offsets [ ConnectedTarget ] ;
351368 }
352369 }
353370 }
@@ -356,14 +373,14 @@ public override void Update()
356373 Connected = false ;
357374 if ( ConnectedTarget != - 1 )
358375 {
359- if ( XPos - Offsets [ ConnectedTarget ] < 0.005 )
376+ if ( OffsetPos - Offsets [ ConnectedTarget ] < 0.005 )
360377 {
361378 Connected = true ;
362379 Reverse = false ;
363380 ConnectedTrackEnd = ConnectedTarget ;
364381 Simulator . Confirmer . Information ( Simulator . Catalog . GetStringFmt ( "Transfertable connected" ) ) ;
365382 GoToTarget = true ;
366- TargetX = Offsets [ ConnectedTarget ] ;
383+ TargetOffset = Offsets [ ConnectedTarget ] ;
367384 }
368385 }
369386 }
0 commit comments