@@ -89,9 +89,12 @@ internal void ParseExtensionsConfig(string TrainPath, Encoding Encoding, ref Uni
89
89
Plugin . CurrentHost . LoadObject ( carObject , Encoding , out CarObjects [ block . Index ] ) ;
90
90
}
91
91
92
+ bool definedLength = false ;
92
93
if ( block . GetValue ( ExtensionCfgKey . Length , out double carLength ) )
93
94
{
94
95
Train . Cars [ block . Index ] . Length = carLength ;
96
+ Train . Cars [ block . Index ] . BeaconReceiverPosition = 0.5 * carLength ;
97
+ definedLength = true ;
95
98
}
96
99
block . GetValue ( ExtensionCfgKey . Reversed , out CarObjectsReversed [ block . Index ] ) ;
97
100
block . GetValue ( ExtensionCfgKey . VisibleFromInterior , out VisibleFromInterior [ block . Index ] ) ;
@@ -107,7 +110,15 @@ internal void ParseExtensionsConfig(string TrainPath, Encoding Encoding, ref Uni
107
110
Train . Cars [ block . Index ] . RearAxle . Position = carAxles . X ;
108
111
Train . Cars [ block . Index ] . FrontAxle . Position = carAxles . Y ;
109
112
}
110
-
113
+ }
114
+ else
115
+ {
116
+ if ( definedLength == false )
117
+ {
118
+ double axleDistance = 0.4 * Train . Cars [ block . Index ] . Length ;
119
+ Train . Cars [ block . Index ] . RearAxle . Position = - axleDistance ;
120
+ Train . Cars [ block . Index ] . FrontAxle . Position = axleDistance ;
121
+ }
111
122
}
112
123
break ;
113
124
case ExtensionCfgSection . Coupler :
@@ -150,7 +161,6 @@ internal void ParseExtensionsConfig(string TrainPath, Encoding Encoding, ref Uni
150
161
//Assuming that there are two bogies per car
151
162
bool IsOdd = ( block . Index % 2 != 0 ) ;
152
163
int CarIndex = block . Index / 2 ;
153
- bool DefinedAxles = false ;
154
164
155
165
if ( block . GetPath ( ExtensionCfgKey . Object , TrainPath , out string bogieObject ) )
156
166
{
@@ -175,22 +185,21 @@ internal void ParseExtensionsConfig(string TrainPath, Encoding Encoding, ref Uni
175
185
Train . Cars [ CarIndex ] . RearBogie . RearAxle . Position = bogieAxles . X ;
176
186
Train . Cars [ CarIndex ] . RearBogie . FrontAxle . Position = bogieAxles . Y ;
177
187
}
178
- DefinedAxles = true ;
179
188
}
180
189
}
181
- if ( ! DefinedAxles )
190
+ else
182
191
{
183
192
if ( IsOdd )
184
193
{
185
- double AxleDistance = 0.4 * Train . Cars [ CarIndex ] . FrontBogie . Length ;
186
- Train . Cars [ CarIndex ] . FrontBogie . RearAxle . Position = - AxleDistance ;
187
- Train . Cars [ CarIndex ] . FrontBogie . FrontAxle . Position = AxleDistance ;
194
+ double axleDistance = 0.4 * Train . Cars [ CarIndex ] . FrontBogie . Length ;
195
+ Train . Cars [ CarIndex ] . FrontBogie . RearAxle . Position = - axleDistance ;
196
+ Train . Cars [ CarIndex ] . FrontBogie . FrontAxle . Position = axleDistance ;
188
197
}
189
198
else
190
199
{
191
- double AxleDistance = 0.4 * Train . Cars [ CarIndex ] . RearBogie . Length ;
192
- Train . Cars [ CarIndex ] . RearBogie . RearAxle . Position = - AxleDistance ;
193
- Train . Cars [ CarIndex ] . RearBogie . FrontAxle . Position = AxleDistance ;
200
+ double axleDistance = 0.4 * Train . Cars [ CarIndex ] . RearBogie . Length ;
201
+ Train . Cars [ CarIndex ] . RearBogie . RearAxle . Position = - axleDistance ;
202
+ Train . Cars [ CarIndex ] . RearBogie . FrontAxle . Position = axleDistance ;
194
203
}
195
204
}
196
205
break ;
0 commit comments