From 2ac6b01cc300b33018ca1e74c77f6586d04fd430 Mon Sep 17 00:00:00 2001 From: Marc Riera Date: Fri, 25 Oct 2024 12:17:04 +0200 Subject: [PATCH] Doors: make AI play door closing sound --- src/Devices/Doors.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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; + } } } }