File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Source/Orts.Simulation/Simulation Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1328,6 +1328,9 @@ private void RemoveTrains()
1328
1328
{
1329
1329
car . Train = null ; // WorldPosition.XNAMatrix.M42 -= 1000;
1330
1330
car . IsPartOfActiveTrain = false ; // to stop sounds
1331
+ // remove continers if any
1332
+ if ( car . FreightAnimations ? . Animations != null )
1333
+ car . FreightAnimations ? . RemoveLoads ( ) ;
1331
1334
}
1332
1335
}
1333
1336
}
Original file line number Diff line number Diff line change @@ -863,6 +863,22 @@ public bool CheckForMerge(int i)
863
863
}
864
864
return false ;
865
865
}
866
+
867
+ /// <summary>
868
+ /// Removes loads (e.g. containers) when AI train is deleted
869
+ /// </summary>
870
+
871
+ public void RemoveLoads ( )
872
+ {
873
+ foreach ( var animation in Animations )
874
+ {
875
+ if ( animation is FreightAnimationDiscrete discreteAnimation && discreteAnimation . Container != null )
876
+ {
877
+ Wagon . Simulator . ContainerManager . Containers . Remove ( discreteAnimation . Container ) ;
878
+ }
879
+ }
880
+
881
+ }
866
882
}
867
883
868
884
You can’t perform that action at this time.
0 commit comments