Doors: make AI play door closing sound

main
Marc Riera 2024-10-25 12:17:04 +02:00
parent fe26296daa
commit 2ac6b01cc3
1 changed files with 14 additions and 0 deletions

View File

@ -30,6 +30,9 @@ namespace OpenbveFcmbTrainPlugin
/// <summary>Whether to trigger a door lock.</summary> /// <summary>Whether to trigger a door lock.</summary>
private bool TriggerDoorLock; private bool TriggerDoorLock;
/// <summary>Whether the AI should trigger the door closing sound.</summary>
private bool AiTriggerDoorClosingSound;
/// <summary>Is called when the device state should be updated.</summary> /// <summary>Is called when the device state should be updated.</summary>
/// <param name="train">The current train.</param> /// <param name="train">The current train.</param>
@ -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 // 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[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; train.Panel[51] = (RequestedDoorInterlock == DoorInterlockStates.Right || RequestedDoorInterlock == DoorInterlockStates.Unlocked) || (((train.DoorState & DoorStates.Right) != 0) && !RightDoorsClosing) ? 1 : 0;
@ -310,6 +317,13 @@ namespace OpenbveFcmbTrainPlugin
break; break;
} }
} }
if (AiTriggerDoorClosingSound)
{
KeyChange(VirtualKeys.F, true, train);
data.Response = AIResponse.Short;
KeyChange(VirtualKeys.F, false, train);
AiTriggerDoorClosingSound = false;
}
} }
} }
} }