Skip to content

Commit 838c314

Browse files
committed
Redefine sound triggers after selection of a new player train
1 parent 26f569b commit 838c314

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Source/Orts.Simulation/Simulation/AIs/AITrain.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6616,6 +6616,22 @@ public void RedefineAITriggers(AITrain train)
66166616
}
66176617
}
66186618

6619+
//================================================================================================//
6620+
/// <summary>
6621+
/// Redefine sound triggers for Player Train
6622+
/// </summary>
6623+
public void RedefinePlayerTrainTriggers(AITrain train)
6624+
{
6625+
Simulator.PlayerLocomotive.SignalEvent(Event.PlayerTrainLeadLoco);
6626+
foreach (var car in train.Cars)
6627+
{
6628+
if (car is MSTSLocomotive && car != Simulator.PlayerLocomotive)
6629+
{
6630+
car.SignalEvent(Event.PlayerTrainHelperLoco);
6631+
}
6632+
}
6633+
}
6634+
66196635
}
66206636

66216637

Source/Orts.Simulation/Simulation/Simulator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,7 @@ private void StartSwitchPlayerTrain()
19871987
// and now switch!
19881988
playerTrain.TrainType = Train.TRAINTYPE.AI;
19891989
playerTrain.Autopilot = false;
1990+
(playerTrain as AITrain).RedefineAITriggers(playerTrain as AITrain);
19901991
if (TrainSwitcher.SuspendOldPlayer)
19911992
{
19921993
playerTrain.MovementState = AITrain.AI_MOVEMENT_STATE.SUSPENDED;
@@ -2186,6 +2187,7 @@ private void CompleteSwitchPlayerTrain()
21862187
PlayerLocomotive.Train.CreatePathlessPlayerTrain();
21872188
}
21882189
var playerLocomotive = PlayerLocomotive as MSTSLocomotive;
2190+
(PlayerLocomotive.Train as AITrain).RedefinePlayerTrainTriggers(PlayerLocomotive.Train as AITrain);
21892191
playerLocomotive.UsingRearCab = (PlayerLocomotive.Flipped ^ PlayerLocomotive.Train.MUDirection == Direction.Reverse) && (playerLocomotive.HasRearCab || playerLocomotive.HasRear3DCab);
21902192
OnPlayerLocomotiveChanged();
21912193
playerSwitchOngoing = false;

0 commit comments

Comments
 (0)