Skip to content

Commit f1681df

Browse files
committed
Add end of loco being lead of an AI train
1 parent 801ad4a commit f1681df

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Source/Orts.Simulation/Common/Events.cs

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public enum Event
3434
PlayerTrainHelperLoco,
3535
PlayerTrainLeadLoco,
3636
StaticTrainLoco,
37+
EndAITrainLeadLoco,
3738
BatterySwitchOff,
3839
BatterySwitchOn,
3940
BatterySwitchCommandOff,
@@ -576,6 +577,7 @@ public static Event From(Source source, int eventID)
576577
case 334: return Event.AITrainApproachingStation;
577578
case 335: return Event.AITrainLeavingStation;
578579
case 336: return Event.StaticTrainLoco;
580+
case 337: return Event.EndAITrainLeadLoco;
579581

580582
default: return 0;
581583
}

Source/Orts.Simulation/Simulation/Physics/Train.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -13849,7 +13849,11 @@ public void RedefineAITriggers()
1384913849
car.SignalEvent(Event.AITrainLeadLoco);
1385013850
leadFound = true;
1385113851
}
13852-
else car.SignalEvent(Event.AITrainHelperLoco);
13852+
else
13853+
{
13854+
car.SignalEvent(Event.AITrainHelperLoco);
13855+
car.SignalEvent(Event.EndAITrainLeadLoco);
13856+
}
1385313857
}
1385413858
}
1385513859
}
@@ -13863,9 +13867,13 @@ public void RedefinePlayerTrainTriggers()
1386313867
Simulator.PlayerLocomotive.SignalEvent(Event.PlayerTrainLeadLoco);
1386413868
foreach (var car in Cars)
1386513869
{
13866-
if (car is MSTSLocomotive && car != Simulator.PlayerLocomotive)
13870+
if (car is MSTSLocomotive)
1386713871
{
13868-
car.SignalEvent(Event.PlayerTrainHelperLoco);
13872+
if (car != Simulator.PlayerLocomotive)
13873+
{
13874+
car.SignalEvent(Event.PlayerTrainHelperLoco);
13875+
}
13876+
car.SignalEvent(Event.EndAITrainLeadLoco);
1386913877
}
1387013878
}
1387113879
}
@@ -13879,7 +13887,10 @@ public void RedefineStaticTrainTriggers()
1387913887
foreach (var car in Cars)
1388013888
{
1388113889
if (car is MSTSLocomotive)
13890+
{
1388213891
car.SignalEvent(Event.StaticTrainLoco);
13892+
car.SignalEvent(Event.EndAITrainLeadLoco);
13893+
}
1388313894
}
1388413895
}
1388513896

0 commit comments

Comments
 (0)