diff --git a/src/Devices/Doors.cs b/src/Devices/Doors.cs index d5fb9d3..26ed1e4 100644 --- a/src/Devices/Doors.cs +++ b/src/Devices/Doors.cs @@ -30,6 +30,9 @@ namespace OpenbveFcmbTrainPlugin /// Whether to trigger a door lock. private bool TriggerDoorLock; + /// Whether the AI should trigger the door closing sound. + private bool AiTriggerDoorClosingSound; + /// Is called when the device state should be updated. /// The current train. @@ -105,6 +108,10 @@ namespace OpenbveFcmbTrainPlugin } } + // Check if AI needs to trigger the door closing sound + // TODO: check departure time + AiTriggerDoorClosingSound |= (train.DoorState != DoorStates.None && DoorClosingSoundCounter > DoorClosingSoundDuration + DoorClosingSoundTimeout); + // Update panel variables for door selection state train.Panel[50] = (RequestedDoorInterlock == DoorInterlockStates.Left || RequestedDoorInterlock == DoorInterlockStates.Unlocked) || (((train.DoorState & DoorStates.Left) != 0) && !LeftDoorsClosing) ? 1 : 0; train.Panel[51] = (RequestedDoorInterlock == DoorInterlockStates.Right || RequestedDoorInterlock == DoorInterlockStates.Unlocked) || (((train.DoorState & DoorStates.Right) != 0) && !RightDoorsClosing) ? 1 : 0; @@ -310,6 +317,13 @@ namespace OpenbveFcmbTrainPlugin break; } } + if (AiTriggerDoorClosingSound) + { + KeyChange(VirtualKeys.F, true, train); + data.Response = AIResponse.Short; + KeyChange(VirtualKeys.F, false, train); + AiTriggerDoorClosingSound = false; + } } } }