@@ -332,11 +332,11 @@ protected virtual void AssignScriptFunctions()
332332 AbstractScript . SignalEventToTcsWithMessage = ( evt , message ) => Locomotive . TrainControlSystem . HandleEvent ( evt , message ) ;
333333 AbstractScript . SignalEventToOtherLocomotives = ( evt ) =>
334334 {
335- if ( Locomotive == Simulator . PlayerLocomotive )
335+ if ( Locomotive == Train . LeadLocomotive )
336336 {
337337 foreach ( MSTSLocomotive locomotive in Locomotive . Train . Cars . OfType < MSTSLocomotive > ( ) )
338338 {
339- if ( locomotive != Locomotive && locomotive != Locomotive . Train . LeadLocomotive && locomotive . RemoteControlGroup != - 1 )
339+ if ( locomotive != Locomotive && locomotive . RemoteControlGroup != - 1 )
340340 {
341341 locomotive . LocomotivePowerSupply . HandleEventFromLeadLocomotive ( evt ) ;
342342 }
@@ -345,11 +345,11 @@ protected virtual void AssignScriptFunctions()
345345 } ;
346346 AbstractScript . SignalEventToOtherLocomotivesWithId = ( evt , id ) =>
347347 {
348- if ( Locomotive == Simulator . PlayerLocomotive )
348+ if ( Locomotive == Train . LeadLocomotive )
349349 {
350350 foreach ( MSTSLocomotive locomotive in Locomotive . Train . Cars . OfType < MSTSLocomotive > ( ) )
351351 {
352- if ( locomotive != Locomotive && locomotive != Locomotive . Train . LeadLocomotive && locomotive . RemoteControlGroup != - 1 )
352+ if ( locomotive != Locomotive && locomotive . RemoteControlGroup != - 1 )
353353 {
354354 locomotive . LocomotivePowerSupply . HandleEventFromLeadLocomotive ( evt , id ) ;
355355 }
@@ -358,26 +358,40 @@ protected virtual void AssignScriptFunctions()
358358 } ;
359359 AbstractScript . SignalEventToOtherTrainVehicles = ( evt ) =>
360360 {
361- if ( Locomotive == Simulator . PlayerLocomotive )
361+ if ( Locomotive == Train . LeadLocomotive )
362362 {
363363 foreach ( TrainCar car in Locomotive . Train . Cars )
364364 {
365- if ( car != Locomotive && car != Locomotive . Train . LeadLocomotive && car . RemoteControlGroup != - 1 )
365+ if ( car != Locomotive && car . RemoteControlGroup != - 1 )
366366 {
367- car . PowerSupply ? . HandleEventFromLeadLocomotive ( evt ) ;
367+ if ( car . PowerSupply != null )
368+ {
369+ car . PowerSupply . HandleEventFromLeadLocomotive ( evt ) ;
370+ }
371+ else if ( car is MSTSWagon wagon )
372+ {
373+ wagon . Pantographs . HandleEvent ( evt ) ;
374+ }
368375 }
369376 }
370377 }
371378 } ;
372379 AbstractScript . SignalEventToOtherTrainVehiclesWithId = ( evt , id ) =>
373380 {
374- if ( Locomotive == Simulator . PlayerLocomotive )
381+ if ( Locomotive == Train . LeadLocomotive )
375382 {
376383 foreach ( TrainCar car in Locomotive . Train . Cars )
377384 {
378- if ( car != Locomotive && car != Locomotive . Train . LeadLocomotive && car . RemoteControlGroup != - 1 )
385+ if ( car != Locomotive && car . RemoteControlGroup != - 1 )
379386 {
380- car . PowerSupply ? . HandleEventFromLeadLocomotive ( evt , id ) ;
387+ if ( car . PowerSupply != null )
388+ {
389+ car . PowerSupply . HandleEventFromLeadLocomotive ( evt , id ) ;
390+ }
391+ else if ( car is MSTSWagon wagon )
392+ {
393+ wagon . Pantographs . HandleEvent ( evt , id ) ;
394+ }
381395 }
382396 }
383397 }
@@ -388,7 +402,7 @@ protected virtual void AssignScriptFunctions()
388402
389403 foreach ( MSTSDieselLocomotive locomotive in Train . Cars . OfType < MSTSDieselLocomotive > ( ) . Where ( ( MSTSLocomotive locomotive ) => { return locomotive . RemoteControlGroup != - 1 ; } ) )
390404 {
391- if ( locomotive == Simulator . PlayerLocomotive )
405+ if ( locomotive == Train . LeadLocomotive )
392406 {
393407 // Engine number 1 or above are helper engines
394408 for ( int i = 1 ; i < locomotive . DieselEngines . Count ; i ++ )
0 commit comments