Door closing sound: fix AI stuck between stations and lock doors when opening

This commit is contained in:
Marc Riera 2024-12-13 00:17:13 +01:00
parent 0d696fb381
commit 261c1fa9c1

View file

@ -118,13 +118,20 @@ namespace OpenbveFcmbTrainPlugin
// Use departure time - door closing sound duration
AiTriggerDoorClosingSound |= CurrentTime.Seconds >= route.CurrentStation.DepartureTime - DoorClosingSoundDuration;
}
// TODO: AI gets stuck if doors open between stations, check distance to stop point
}
else
{
// The doors have been opened between stations
if (route.CurrentStation.StopPosition - route.CurrentStation.BackwardTolerance > train.State.Location)
{
AiTriggerDoorClosingSound = true;
}
else
{
AiTriggerDoorClosingSound = false;
}
}
}
else
{
AiTriggerDoorClosingSound = false;
@ -166,6 +173,10 @@ namespace OpenbveFcmbTrainPlugin
{
DoorOpenTime = CurrentTime;
}
// Set door closing counter to value higher than maximum where doors are allowed to close
// This effectively locks the doors when they open
DoorClosingSoundCounter = DoorClosingSoundDuration + DoorClosingSoundTimeout;
}
/// <summary>Is called when the device should perform the AI.</summary>