@@ -83,6 +83,7 @@ public class TrainCarOperationsWindow : Window
83
83
public int SeparatorCount ;
84
84
public int SpacerRowCount ;
85
85
public int SymbolsRowCount ;
86
+ public bool BrakeHoseCarCoupling ;
86
87
87
88
public ControlLayout Client ;
88
89
public bool CarPositionChanged ;
@@ -499,6 +500,8 @@ void AddSpace()
499
500
// Allows to resize the window according to the carPosition value.
500
501
if ( RowsCount > carPosition ) RowsCount = carPosition ;
501
502
if ( SeparatorCount > carPosition - 1 ) SeparatorCount = carPosition - 1 ;
503
+
504
+ BrakeHoseCarCoupling = false ; // All brake hoses checked
502
505
}
503
506
}
504
507
return Vbox ;
@@ -603,14 +606,11 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
603
606
PlayerTrain = Owner . Viewer . PlayerTrain ;
604
607
if ( LastPlayerTrainCars != Owner . Viewer . PlayerTrain . Cars . Count || ! LayoutUpdated )
605
608
{
606
- // Updates BrakeHoses
609
+ // Updates brake hoses
607
610
if ( LastPlayerTrainCars > 0 && PlayerTrain . Cars . Count > LastPlayerTrainCars && ( ( PlayerTrain . Cars [ LastPlayerTrainCars ] as MSTSWagon ) . BrakeSystem . FrontBrakeHoseConnected != ( PlayerTrain . Cars [ LastPlayerTrainCars - 1 ] as MSTSWagon ) . BrakeSystem . RearBrakeHoseConnected ) )
608
611
{
609
- // When coupling cars. The front brake hose of the new car is unconnected, the brake hose of the previous car must also be unconnected.
610
- new WagonBrakeHoseRearConnectCommand ( Owner . Viewer . Log , ( PlayerTrain . Cars [ LastPlayerTrainCars - 1 ] as MSTSWagon ) , ! ( PlayerTrain . Cars [ LastPlayerTrainCars - 1 ] as MSTSWagon ) . BrakeSystem . RearBrakeHoseConnected ) ;
611
- new WagonBrakeHoseRearConnectCommand ( Owner . Viewer . Log , ( PlayerTrain . Cars [ LastPlayerTrainCars ] as MSTSWagon ) , ! ( PlayerTrain . Cars [ LastPlayerTrainCars ] as MSTSWagon ) . BrakeSystem . FrontBrakeHoseConnected ) ;
612
+ BrakeHoseCarCoupling = true ; // Enable to check all brake hoses when coupling cars
612
613
}
613
-
614
614
LayoutUpdated = true ;
615
615
Layout ( ) ;
616
616
localScrollLayout ( SelectedCarPosition ) ;
@@ -837,6 +837,7 @@ class buttonFrontBrakeHose : Image
837
837
{
838
838
readonly Viewer Viewer ;
839
839
readonly TrainCarOperationsViewerWindow TrainCarViewer ;
840
+ readonly TrainCarOperationsWindow TrainCarOperations ;
840
841
readonly CarOperationsWindow CarOperations ;
841
842
readonly int CarPosition ;
842
843
readonly bool First ;
@@ -845,10 +846,25 @@ public buttonFrontBrakeHose(int x, int y, int size, Viewer viewer, TrainCar car,
845
846
{
846
847
Viewer = viewer ;
847
848
TrainCarViewer = Viewer . TrainCarOperationsViewerWindow ;
849
+ TrainCarOperations = Viewer . TrainCarOperationsWindow ;
848
850
CarOperations = Viewer . CarOperationsWindow ;
851
+ var PlayerTrain = Viewer . PlayerTrain ;
849
852
850
853
CarPosition = carPosition ;
851
854
First = car == viewer . PlayerTrain . Cars . First ( ) ;
855
+ if ( CarPosition > 0 && TrainCarOperations . BrakeHoseCarCoupling )
856
+ { // Sometimes when coupling cars. The front brake hose of the new car and the brake hose of the previous car are not synchronised.
857
+ var frontBrakeHoseCurrentCar = ( PlayerTrain . Cars [ CarPosition ] as MSTSWagon ) . BrakeSystem . FrontBrakeHoseConnected ;
858
+ var rearBrakeHosePreviousCar = ( PlayerTrain . Cars [ CarPosition - 1 ] as MSTSWagon ) . BrakeSystem . RearBrakeHoseConnected ;
859
+ if ( frontBrakeHoseCurrentCar && ! rearBrakeHosePreviousCar )
860
+ {
861
+ new WagonBrakeHoseConnectCommand ( Viewer . Log , ( PlayerTrain . Cars [ CarPosition ] as MSTSWagon ) , ! ( PlayerTrain . Cars [ CarPosition ] as MSTSWagon ) . BrakeSystem . FrontBrakeHoseConnected ) ;
862
+ }
863
+ else if ( ! frontBrakeHoseCurrentCar && rearBrakeHosePreviousCar )
864
+ {
865
+ new WagonBrakeHoseRearConnectCommand ( Viewer . Log , ( PlayerTrain . Cars [ CarPosition - 1 ] as MSTSWagon ) , ! ( PlayerTrain . Cars [ CarPosition - 1 ] as MSTSWagon ) . BrakeSystem . RearBrakeHoseConnected ) ;
866
+ }
867
+ }
852
868
Texture = First ? BrakeHoseFirstDis : ( viewer . PlayerTrain . Cars [ carPosition ] as MSTSWagon ) . BrakeSystem . FrontBrakeHoseConnected ? BrakeHoseCon : BrakeHoseDis ;
853
869
854
870
// Allows compatibility with CarOperationWindow
0 commit comments