Skip to content

Commit 71e21a6

Browse files
committed
Add first hooks for Timetable Mode
1 parent e2dd24e commit 71e21a6

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Source/Orts.Simulation/Simulation/Timetables/TTTrain.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,7 @@ public override void SetNextStationAction(bool fromAutopilotSwitch = false)
22482248
AIActionItem newAction = new AIActionItem(null, AIActionItem.AI_ACTION_TYPE.STATION_STOP);
22492249
newAction.SetParam(distancesM[1], 0.0f, distancesM[0], DistanceTravelledM);
22502250
requiredActions.InsertAction(newAction);
2251+
ApproachTriggerSet = false;
22512252

22522253
#if DEBUG_REPORTS
22532254
if (StationStops[0].ActualStopType == StationStop.STOPTYPE.STATION_STOP)
@@ -3980,6 +3981,7 @@ public override void UpdateStationState(float elapsedClockSeconds, int presentTi
39803981
Delay = TimeSpan.FromSeconds((presentTime - thisStation.DepartTime) % (24 * 3600));
39813982
}
39823983
}
3984+
if (Cars[0] is MSTSLocomotive) Cars[0].SignalEvent(Event.AITrainLeavingStation);
39833985

39843986
#if DEBUG_REPORTS
39853987
DateTime baseDTd = new DateTime();
@@ -4501,7 +4503,7 @@ public override void UpdateBrakingState(float elapsedClockSeconds, int presentTi
45014503
}
45024504
else if (nextActionInfo.RequiredSpeedMpS == 0)
45034505
{
4504-
// Check if stopped at signal
4506+
// Check if stopped at signal
45054507
NextStopDistanceM = distanceToGoM;
45064508
float stopDistanceM = signalApproachDistanceM;
45074509

@@ -4571,6 +4573,13 @@ public override void UpdateBrakingState(float elapsedClockSeconds, int presentTi
45714573
}
45724574
}
45734575

4576+
if (nextActionInfo != null && nextActionInfo.NextAction == AIActionItem.AI_ACTION_TYPE.STATION_STOP &&
4577+
distanceToGoM < 150 + StationStops[0].PlatformItem.Length && !ApproachTriggerSet)
4578+
{
4579+
if (Cars[0] is MSTSLocomotive) Cars[0].SignalEvent(Event.AITrainApproachingStation);
4580+
ApproachTriggerSet = true;
4581+
}
4582+
45744583
// Keep speed within required speed band
45754584
// Preset, also valid for reqSpeed > 0
45764585
float lowestSpeedMpS = requiredSpeedMpS;

Source/RunActivity/Viewer3D/RollingStock/MSTSWagonViewer.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,14 +1460,19 @@ protected void LoadCarSound(string wagonFolderSlash, string filename)
14601460
try
14611461
{
14621462
Viewer.SoundProcess.AddSoundSource(this, new SoundSource(Viewer, MSTSWagon, smsFilePath));
1463-
if (MSTSWagon is MSTSLocomotive && MSTSWagon.Train != null && MSTSWagon.Train.TrainType == Simulation.Physics.Train.TRAINTYPE.AI)
1463+
if (MSTSWagon is MSTSLocomotive && MSTSWagon.Train != null && MSTSWagon.Train.TrainType == Train.TRAINTYPE.AI)
14641464
{
14651465
if (MSTSWagon.CarID == MSTSWagon.Train.Cars[0].CarID)
14661466
// Lead loco, enable AI train trigger
1467-
MSTSWagon.SignalEvent(Orts.Common.Event.AITrainLeadLoco);
1467+
MSTSWagon.SignalEvent(Event.AITrainLeadLoco);
14681468
// AI train helper loco
1469-
else MSTSWagon.SignalEvent(Orts.Common.Event.AITrainHelperLoco);
1469+
else MSTSWagon.SignalEvent(Event.AITrainHelperLoco);
14701470
}
1471+
else if (MSTSWagon == Viewer.PlayerLocomotive)
1472+
MSTSWagon.SignalEvent(Event.PlayerTrainLeadLoco);
1473+
else if (MSTSWagon.Train != null && (MSTSWagon.Train.TrainType == Train.TRAINTYPE.PLAYER ||
1474+
MSTSWagon.Train.TrainType == Train.TRAINTYPE.AI_PLAYERDRIVEN || MSTSWagon.Train.TrainType == Train.TRAINTYPE.AI_PLAYERHOSTING))
1475+
MSTSWagon.SignalEvent(Event.PlayerTrainHelperLoco);
14711476
}
14721477
catch (Exception error)
14731478
{

0 commit comments

Comments
 (0)