Doors: Split into 3 devices
This commit is contained in:
parent
9abbab8e81
commit
0d696fb381
7 changed files with 274 additions and 192 deletions
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenbveFcmbTrainPlugin", "src/OpenbveFcmbTrainPlugin.csproj", "{9197FFA4-D95A-410C-A705-4E7CD187546A}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenbveFcmbTrainPlugin", "src\OpenbveFcmbTrainPlugin.csproj", "{9197FFA4-D95A-410C-A705-4E7CD187546A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
187
src/Devices/DoorClosingSound.cs
Normal file
187
src/Devices/DoorClosingSound.cs
Normal file
|
@ -0,0 +1,187 @@
|
|||
using System;
|
||||
using OpenBveApi.Runtime;
|
||||
|
||||
namespace OpenbveFcmbTrainPlugin
|
||||
{
|
||||
/// <summary>A device controlling the door operation.</summary>
|
||||
internal class DoorClosingSound : Device
|
||||
{
|
||||
/// <summary>Whether the door closing sound is required to be played to close the doors.</summary>
|
||||
private readonly bool RequireDoorClosingSound;
|
||||
|
||||
/// <summary>The duration of the door closing sound, in seconds.</summary>
|
||||
private readonly double DoorClosingSoundDuration;
|
||||
|
||||
/// <summary>The timeout after which the door closing sound needs to be played again, in seconds.</summary>
|
||||
private readonly double DoorClosingSoundTimeout;
|
||||
|
||||
/// <summary>The counter for the door closing sound.</summary>
|
||||
private double DoorClosingSoundCounter;
|
||||
|
||||
/// <summary>Whether the AI should trigger the door closing sound.</summary>
|
||||
private bool AiTriggerDoorClosingSound;
|
||||
|
||||
/// <summary>The index of the door closing sound.</summary>
|
||||
private readonly int DoorClosingSoundIndex;
|
||||
|
||||
/// <summary>The current time.</summary>
|
||||
private Time CurrentTime = new Time(0);
|
||||
|
||||
/// <summary>The time when the doors last opened.</summary>
|
||||
private Time DoorOpenTime = new Time(0);
|
||||
|
||||
/// <summary>Whether the door closing sound is required to be played to close the doors.</summary>
|
||||
/// <param name="requireClosingSound">The delay before the brakes are applied, in seconds.</param>
|
||||
/// <param name="closingSoundDuration">The duration of the door closing sound, in seconds.</param>
|
||||
/// <param name="closingSoundTimeout">The timeout after which the door closing sound needs to be played again, in seconds.</param>
|
||||
/// <param name="closingSoundIndex">The index of the door closing sound.</param>
|
||||
internal DoorClosingSound(bool requireClosingSound, double closingSoundDuration, double closingSoundTimeout, int closingSoundIndex)
|
||||
{
|
||||
RequireDoorClosingSound = requireClosingSound;
|
||||
DoorClosingSoundDuration = closingSoundDuration;
|
||||
DoorClosingSoundTimeout = closingSoundTimeout;
|
||||
DoorClosingSoundIndex = closingSoundIndex;
|
||||
}
|
||||
|
||||
/// <summary>Is called when the device state should be updated.</summary>
|
||||
/// <param name="train">The current train.</param>
|
||||
/// <param name="route">The current route.</param>
|
||||
/// <param name="init">Whether the device should initialize.</param>
|
||||
/// <param name="elapsedTime">The time elapsed since the previous call.</param>
|
||||
internal override void Update(Train train, Route route, bool init, Time elapsedTime)
|
||||
{
|
||||
// Update current time
|
||||
CurrentTime = route.CurrentTime;
|
||||
|
||||
if (init)
|
||||
{
|
||||
// Set door closing counter to value higher than maximum where doors are allowed to close
|
||||
DoorClosingSoundCounter = DoorClosingSoundDuration + DoorClosingSoundTimeout;
|
||||
}
|
||||
|
||||
// Update door closing sound counter
|
||||
DoorClosingSoundCounter += elapsedTime.Seconds;
|
||||
|
||||
// Lock and unlock doors depending on whether the door closing sound has been played
|
||||
if (RequireDoorClosingSound && train.DoorState != DoorStates.None)
|
||||
{
|
||||
if (DoorClosingSoundCounter > DoorClosingSoundDuration + DoorClosingSoundTimeout)
|
||||
{
|
||||
switch (train.DoorState)
|
||||
{
|
||||
case DoorStates.Both:
|
||||
RequestedDoorInterlock = DoorInterlockStates.Locked;
|
||||
break;
|
||||
case DoorStates.Left:
|
||||
RequestedDoorInterlock = DoorInterlockStates.Right;
|
||||
break;
|
||||
case DoorStates.Right:
|
||||
RequestedDoorInterlock = DoorInterlockStates.Left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (DoorClosingSoundCounter > DoorClosingSoundDuration)
|
||||
{
|
||||
switch (train.DoorState)
|
||||
{
|
||||
case DoorStates.Both:
|
||||
RequestedDoorInterlock = DoorInterlockStates.Unlocked;
|
||||
break;
|
||||
case DoorStates.Left:
|
||||
RequestedDoorInterlock = DoorInterlockStates.Left;
|
||||
break;
|
||||
case DoorStates.Right:
|
||||
RequestedDoorInterlock = DoorInterlockStates.Right;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RequestedDoorInterlock = DoorInterlockStates.Unlocked;
|
||||
}
|
||||
|
||||
// Check if AI needs to trigger the door closing sound
|
||||
if (train.DoorState != DoorStates.None && DoorClosingSoundCounter > DoorClosingSoundDuration + DoorClosingSoundTimeout)
|
||||
{
|
||||
if (route.CurrentStation.Type == StationType.Normal || route.CurrentStation.Type == StationType.RequestStop)
|
||||
{
|
||||
// The current station is an intermediate stop
|
||||
if (route.CurrentStation.DepartureTime < 0)
|
||||
{
|
||||
// The current station has dwell time, not a specific departure time
|
||||
// Calculate departure time from the time when the doors opened
|
||||
AiTriggerDoorClosingSound |= CurrentTime.Seconds >= DoorOpenTime.Seconds + (route.CurrentStation.StopTime - DoorClosingSoundDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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
|
||||
{
|
||||
AiTriggerDoorClosingSound = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AiTriggerDoorClosingSound = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Is called when the state of a key changes.</summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="pressed">Whether the key is pressed or released.</param>
|
||||
/// <param name="train">The current train.</param>
|
||||
internal override void KeyChange(VirtualKeys key, bool pressed, Train train)
|
||||
{
|
||||
if (pressed)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case VirtualKeys.F:
|
||||
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
||||
{
|
||||
// Play the door closing sound and reset timeout
|
||||
DoorClosingSoundCounter = 0;
|
||||
if (!SoundManager.Playing(DoorClosingSoundIndex))
|
||||
{
|
||||
SoundManager.Play(DoorClosingSoundIndex, 1, 1, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Is called when the state of the doors changes.</summary>
|
||||
/// <param name="oldState">The old state of the doors.</param>
|
||||
/// <param name="newState">The new state of the doors.</param>
|
||||
internal override void DoorChange(DoorStates oldState, DoorStates newState)
|
||||
{
|
||||
// Set arrival time when doors open
|
||||
if (oldState == DoorStates.None && newState != DoorStates.None)
|
||||
{
|
||||
DoorOpenTime = CurrentTime;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Is called when the device should perform the AI.</summary>
|
||||
/// <param name="data">The AI data.</param>
|
||||
/// <param name="train">The current train.</param>
|
||||
/// <param name="route">The current route.</param>
|
||||
internal override void PerformAI(AIData data, Train train, Route route)
|
||||
{
|
||||
if (AiTriggerDoorClosingSound)
|
||||
{
|
||||
KeyChange(VirtualKeys.F, true, train);
|
||||
data.Response = AIResponse.Short;
|
||||
KeyChange(VirtualKeys.F, false, train);
|
||||
AiTriggerDoorClosingSound = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ using OpenBveApi.Runtime;
|
|||
namespace OpenbveFcmbTrainPlugin
|
||||
{
|
||||
/// <summary>A device controlling the door operation.</summary>
|
||||
internal class Doors : Device
|
||||
internal class DoorSelection : Device
|
||||
{
|
||||
/// <summary>Whether the left doors are closing.</summary>
|
||||
private bool LeftDoorsClosing;
|
||||
|
@ -12,48 +12,6 @@ namespace OpenbveFcmbTrainPlugin
|
|||
/// <summary>Whether the right doors are closing.</summary>
|
||||
private bool RightDoorsClosing;
|
||||
|
||||
/// <summary>Whether the door closing sound is required to be played to close the doors.</summary>
|
||||
private bool RequireDoorClosingSound;
|
||||
|
||||
/// <summary>The duration of the door closing sound, in seconds.</summary>
|
||||
private double DoorClosingSoundDuration;
|
||||
|
||||
/// <summary>The timeout after which the door closing sound needs to be played again, in seconds.</summary>
|
||||
private double DoorClosingSoundTimeout;
|
||||
|
||||
/// <summary>The counter for the door closing sound.</summary>
|
||||
private double DoorClosingSoundCounter;
|
||||
|
||||
/// <summary>Whether to trigger a door unlock.</summary>
|
||||
private bool TriggerDoorUnlock;
|
||||
|
||||
/// <summary>Whether to trigger a door lock.</summary>
|
||||
private bool TriggerDoorLock;
|
||||
|
||||
/// <summary>Whether the AI should trigger the door closing sound.</summary>
|
||||
private bool AiTriggerDoorClosingSound;
|
||||
|
||||
/// <summary>The index of the door closing sound.</summary>
|
||||
private int DoorClosingSoundIndex;
|
||||
|
||||
/// <summary>The current time.</summary>
|
||||
private Time CurrentTime = new Time(0);
|
||||
|
||||
/// <summary>The time when the doors last opened.</summary>
|
||||
private Time DoorOpenTime = new Time(0);
|
||||
|
||||
/// <summary>Whether the door closing sound is required to be played to close the doors.</summary>
|
||||
/// <param name="requireClosingSound">The delay before the brakes are applied, in seconds.</param>
|
||||
/// <param name="closingSoundDuration">The duration of the door closing sound, in seconds.</param>
|
||||
/// <param name="closingSoundTimeout">The timeout after which the door closing sound needs to be played again, in seconds.</param>
|
||||
/// <param name="closingSoundIndex">The index of the door closing sound.</param>
|
||||
internal Doors(bool requireClosingSound, double closingSoundDuration, double closingSoundTimeout, int closingSoundIndex)
|
||||
{
|
||||
RequireDoorClosingSound = requireClosingSound;
|
||||
DoorClosingSoundDuration = closingSoundDuration;
|
||||
DoorClosingSoundTimeout = closingSoundTimeout;
|
||||
DoorClosingSoundIndex = closingSoundIndex;
|
||||
}
|
||||
|
||||
/// <summary>Is called when the device state should be updated.</summary>
|
||||
/// <param name="train">The current train.</param>
|
||||
|
@ -62,12 +20,7 @@ namespace OpenbveFcmbTrainPlugin
|
|||
/// <param name="elapsedTime">The time elapsed since the previous call.</param>
|
||||
internal override void Update(Train train, Route route, bool init, Time elapsedTime)
|
||||
{
|
||||
// Update current time
|
||||
CurrentTime = route.CurrentTime;
|
||||
|
||||
if (init)
|
||||
{
|
||||
if (!RequireDoorClosingSound)
|
||||
{
|
||||
// Set the selection state of the doors during initialization
|
||||
switch (train.DoorState)
|
||||
|
@ -84,81 +37,6 @@ namespace OpenbveFcmbTrainPlugin
|
|||
break;
|
||||
}
|
||||
}
|
||||
// Set door closing counter to value higher than maximum where doors are allowed to close
|
||||
DoorClosingSoundCounter = DoorClosingSoundDuration + DoorClosingSoundTimeout;
|
||||
}
|
||||
|
||||
// Cut power when the doors are open
|
||||
RequestedPowerNotch = (train.DoorState != DoorStates.None) ? 0 : -1;
|
||||
|
||||
// Update door closing sound counter
|
||||
DoorClosingSoundCounter += elapsedTime.Seconds;
|
||||
|
||||
// Unlock doors for closing if the door closing sound has been played
|
||||
if (RequireDoorClosingSound)
|
||||
{
|
||||
if (DoorClosingSoundCounter > DoorClosingSoundDuration && TriggerDoorUnlock)
|
||||
{
|
||||
switch (train.DoorState)
|
||||
{
|
||||
case DoorStates.Both:
|
||||
RequestedDoorInterlock = DoorInterlockStates.Unlocked;
|
||||
break;
|
||||
case DoorStates.Left:
|
||||
RequestedDoorInterlock = RequestedDoorInterlock == DoorInterlockStates.Right ? DoorInterlockStates.Unlocked : DoorInterlockStates.Left;
|
||||
break;
|
||||
case DoorStates.Right:
|
||||
RequestedDoorInterlock = RequestedDoorInterlock == DoorInterlockStates.Left ? DoorInterlockStates.Unlocked : DoorInterlockStates.Right;
|
||||
break;
|
||||
}
|
||||
TriggerDoorUnlock = false;
|
||||
TriggerDoorLock = true;
|
||||
}
|
||||
else if (DoorClosingSoundCounter > DoorClosingSoundDuration + DoorClosingSoundTimeout && TriggerDoorLock)
|
||||
{
|
||||
switch (train.DoorState)
|
||||
{
|
||||
case DoorStates.Both:
|
||||
RequestedDoorInterlock = DoorInterlockStates.Locked;
|
||||
break;
|
||||
case DoorStates.Left:
|
||||
RequestedDoorInterlock = RequestedDoorInterlock == DoorInterlockStates.Unlocked ? DoorInterlockStates.Right : DoorInterlockStates.Locked;
|
||||
break;
|
||||
case DoorStates.Right:
|
||||
RequestedDoorInterlock = RequestedDoorInterlock == DoorInterlockStates.Unlocked ? DoorInterlockStates.Left : DoorInterlockStates.Locked;
|
||||
break;
|
||||
}
|
||||
TriggerDoorLock = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if AI needs to trigger the door closing sound
|
||||
if (train.DoorState != DoorStates.None && DoorClosingSoundCounter > DoorClosingSoundDuration + DoorClosingSoundTimeout)
|
||||
{
|
||||
if (route.CurrentStation.Type == StationType.Normal || route.CurrentStation.Type == StationType.RequestStop)
|
||||
{
|
||||
// The current station is an intermediate stop
|
||||
if (route.CurrentStation.DepartureTime < 0)
|
||||
{
|
||||
// The current station has dwell time, not a specific departure time
|
||||
// Calculate departure time from the time when the doors opened
|
||||
AiTriggerDoorClosingSound |= CurrentTime.Seconds >= DoorOpenTime.Seconds + (route.CurrentStation.StopTime - DoorClosingSoundDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use departure time - door closing sound duration
|
||||
AiTriggerDoorClosingSound |= CurrentTime.Seconds >= route.CurrentStation.DepartureTime - DoorClosingSoundDuration;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AiTriggerDoorClosingSound = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AiTriggerDoorClosingSound = false;
|
||||
}
|
||||
|
||||
// Update panel variables for door selection state
|
||||
train.Panel[50] = (RequestedDoorInterlock == DoorInterlockStates.Left || RequestedDoorInterlock == DoorInterlockStates.Unlocked) || (((train.DoorState & DoorStates.Left) != 0) && !LeftDoorsClosing) ? 1 : 0;
|
||||
|
@ -175,18 +53,6 @@ namespace OpenbveFcmbTrainPlugin
|
|||
{
|
||||
switch (key)
|
||||
{
|
||||
case VirtualKeys.F:
|
||||
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
||||
{
|
||||
// Play the door closing sound and reset timeout
|
||||
DoorClosingSoundCounter = 0;
|
||||
TriggerDoorUnlock = true;
|
||||
if (!SoundManager.Playing(DoorClosingSoundIndex))
|
||||
{
|
||||
SoundManager.Play(DoorClosingSoundIndex, 1, 1, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VirtualKeys.G:
|
||||
// Change the selection state of the left doors
|
||||
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
||||
|
@ -241,7 +107,7 @@ namespace OpenbveFcmbTrainPlugin
|
|||
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
||||
{
|
||||
// Unselect doors automatically when closing
|
||||
if ((train.DoorState & DoorStates.Left) > 0 && !LeftDoorsClosing && (RequestedDoorInterlock == DoorInterlockStates.Left || RequestedDoorInterlock == DoorInterlockStates.Unlocked))
|
||||
if ((train.DoorState & DoorStates.Left) > 0 && !LeftDoorsClosing && (train.DoorInterlockState == DoorInterlockStates.Left || train.DoorInterlockState == DoorInterlockStates.Unlocked))
|
||||
{
|
||||
LeftDoorsClosing = true;
|
||||
RequestedDoorInterlock = RequestedDoorInterlock == DoorInterlockStates.Left ? DoorInterlockStates.Locked : DoorInterlockStates.Right;
|
||||
|
@ -256,7 +122,7 @@ namespace OpenbveFcmbTrainPlugin
|
|||
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
||||
{
|
||||
// Unselect doors automatically when closing
|
||||
if ((train.DoorState & DoorStates.Right) > 0 && !RightDoorsClosing && (RequestedDoorInterlock == DoorInterlockStates.Right || RequestedDoorInterlock == DoorInterlockStates.Unlocked))
|
||||
if ((train.DoorState & DoorStates.Right) > 0 && !RightDoorsClosing && (train.DoorInterlockState == DoorInterlockStates.Right || train.DoorInterlockState == DoorInterlockStates.Unlocked))
|
||||
{
|
||||
RightDoorsClosing = true;
|
||||
RequestedDoorInterlock = RequestedDoorInterlock == DoorInterlockStates.Right ? DoorInterlockStates.Locked : DoorInterlockStates.Left;
|
||||
|
@ -295,23 +161,6 @@ namespace OpenbveFcmbTrainPlugin
|
|||
RequestedDoorInterlock = RequestedDoorInterlock == DoorInterlockStates.Right ? DoorInterlockStates.Locked : DoorInterlockStates.Left;
|
||||
}
|
||||
}
|
||||
if (RequireDoorClosingSound)
|
||||
{
|
||||
if ((oldState == DoorStates.None || oldState == DoorStates.Left) && (newState == DoorStates.Both || newState == DoorStates.Right))
|
||||
{
|
||||
RequestedDoorInterlock = RequestedDoorInterlock == DoorInterlockStates.Left ? DoorInterlockStates.Left : DoorInterlockStates.Locked;
|
||||
}
|
||||
if ((oldState == DoorStates.None || oldState == DoorStates.Right) && (newState == DoorStates.Both || newState == DoorStates.Left))
|
||||
{
|
||||
RequestedDoorInterlock = RequestedDoorInterlock == DoorInterlockStates.Right ? DoorInterlockStates.Right : DoorInterlockStates.Locked;
|
||||
}
|
||||
}
|
||||
|
||||
// Set arrival time when doors open
|
||||
if (oldState == DoorStates.None && newState != DoorStates.None)
|
||||
{
|
||||
DoorOpenTime = CurrentTime;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Is called when the device should perform the AI.</summary>
|
||||
|
@ -383,13 +232,6 @@ namespace OpenbveFcmbTrainPlugin
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (AiTriggerDoorClosingSound)
|
||||
{
|
||||
KeyChange(VirtualKeys.F, true, train);
|
||||
data.Response = AIResponse.Short;
|
||||
KeyChange(VirtualKeys.F, false, train);
|
||||
AiTriggerDoorClosingSound = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
src/Devices/DoorTractionCut.cs
Normal file
21
src/Devices/DoorTractionCut.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using OpenBveApi.Runtime;
|
||||
|
||||
namespace OpenbveFcmbTrainPlugin
|
||||
{
|
||||
/// <summary>A device cutting power if doors are open.</summary>
|
||||
internal class DoorTractionCut : Device
|
||||
{
|
||||
/// <summary>Is called when the device state should be updated.</summary>
|
||||
/// <param name="train">The current train.</param>
|
||||
/// <param name="route">The current route.</param>
|
||||
/// <param name="init">Whether the device should initialize.</param>
|
||||
/// <param name="elapsedTime">The time elapsed since the previous call.</param>
|
||||
internal override void Update(Train train, Route route, bool init, Time elapsedTime)
|
||||
{
|
||||
// Cut power when the doors are open
|
||||
RequestedPowerNotch = (train.DoorState != DoorStates.None) ? 0 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,16 +8,18 @@ namespace OpenbveFcmbTrainPlugin
|
|||
/// <summary>Represents a collection of plugin settings.</summary>
|
||||
internal class SettingsCollection
|
||||
{
|
||||
internal bool DoorsDeviceEnabled;
|
||||
internal bool DoorSelectionDeviceEnabled;
|
||||
internal bool DoorClosingSoundDeviceEnabled;
|
||||
internal bool DoorTractionCutDeviceEnabled;
|
||||
internal bool DeadmanDeviceEnabled;
|
||||
internal bool TrainStopDeviceEnabled;
|
||||
internal bool AtcBombardierDeviceEnabled;
|
||||
internal bool AtcDimetronicDeviceEnabled;
|
||||
|
||||
internal bool DoorsRequireClosingSound;
|
||||
internal int DoorsClosingSoundDuration = 5;
|
||||
internal int DoorsClosingSoundTimeout = 15;
|
||||
internal int DoorsClosingSoundIndex = 10;
|
||||
internal bool DoorClosingSoundRequired;
|
||||
internal int DoorClosingSoundDuration = 5;
|
||||
internal int DoorClosingSoundTimeout = 15;
|
||||
internal int DoorClosingSoundIndex = 10;
|
||||
|
||||
internal int DeadmanBrakeDelay = 5;
|
||||
internal bool DeadmanRequireFullStop;
|
||||
|
@ -68,41 +70,57 @@ namespace OpenbveFcmbTrainPlugin
|
|||
}
|
||||
switch (Section)
|
||||
{
|
||||
case "doors":
|
||||
case "doorselection":
|
||||
switch (Key)
|
||||
{
|
||||
case "enabled":
|
||||
PluginSettings.DoorsDeviceEnabled = string.Compare(Value, "false", StringComparison.OrdinalIgnoreCase) != 0;
|
||||
PluginSettings.DoorSelectionDeviceEnabled = string.Compare(Value, "false", StringComparison.OrdinalIgnoreCase) != 0;
|
||||
break;
|
||||
case "requireclosingsound":
|
||||
PluginSettings.DoorsRequireClosingSound = string.Compare(Value, "false", StringComparison.OrdinalIgnoreCase) != 0;
|
||||
}
|
||||
break;
|
||||
case "closingsoundduration":
|
||||
case "doorclosingsound":
|
||||
switch (Key)
|
||||
{
|
||||
case "enabled":
|
||||
PluginSettings.DoorClosingSoundDeviceEnabled = string.Compare(Value, "false", StringComparison.OrdinalIgnoreCase) != 0;
|
||||
break;
|
||||
case "required":
|
||||
PluginSettings.DoorClosingSoundRequired = string.Compare(Value, "false", StringComparison.OrdinalIgnoreCase) != 0;
|
||||
break;
|
||||
case "duration":
|
||||
{
|
||||
if (int.TryParse(Value, out int a))
|
||||
{
|
||||
PluginSettings.DoorsClosingSoundDuration = a;
|
||||
PluginSettings.DoorClosingSoundDuration = a;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "closingsoundtimeout":
|
||||
case "timeout":
|
||||
{
|
||||
if (int.TryParse(Value, out int a))
|
||||
{
|
||||
PluginSettings.DoorsClosingSoundTimeout = a;
|
||||
PluginSettings.DoorClosingSoundTimeout = a;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "closingsoundindex":
|
||||
case "index":
|
||||
{
|
||||
if (int.TryParse(Value, out int a))
|
||||
{
|
||||
PluginSettings.DoorsClosingSoundIndex = a;
|
||||
PluginSettings.DoorClosingSoundIndex = a;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "doortractioncut":
|
||||
switch (Key)
|
||||
{
|
||||
case "enabled":
|
||||
PluginSettings.DoorTractionCutDeviceEnabled = string.Compare(Value, "false", StringComparison.OrdinalIgnoreCase) != 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "deadman":
|
||||
switch (Key)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<Compile Include="OpenbveFcmbTrainPlugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Devices\Device.cs" />
|
||||
<Compile Include="Devices\Doors.cs" />
|
||||
<Compile Include="Devices\DoorTractionCut.cs" />
|
||||
<Compile Include="Train\Train.cs" />
|
||||
<Compile Include="Devices\TrainStop.cs" />
|
||||
<Compile Include="Devices\Deadman.cs" />
|
||||
|
@ -47,6 +47,8 @@
|
|||
<Compile Include="Managers\MessageManager.cs" />
|
||||
<Compile Include="Devices\AtcDimetronic.cs" />
|
||||
<Compile Include="Managers\ConfigManager.cs" />
|
||||
<Compile Include="Devices\DoorSelection.cs" />
|
||||
<Compile Include="Devices\DoorClosingSound.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Devices\" />
|
||||
|
|
|
@ -27,6 +27,9 @@ namespace OpenbveFcmbTrainPlugin
|
|||
/// <summary>The current state of the train doors.</summary>
|
||||
internal DoorStates DoorState { get; private set; }
|
||||
|
||||
/// <summary>The current interlock state of the train doors.</summary>
|
||||
internal DoorInterlockStates DoorInterlockState { get; private set; }
|
||||
|
||||
/// <summary>The previous state of the train doors.</summary>
|
||||
internal DoorStates PreviousDoorState { get; private set; }
|
||||
|
||||
|
@ -69,9 +72,17 @@ namespace OpenbveFcmbTrainPlugin
|
|||
// Create list of devices and populate it according to settings
|
||||
Devices = new List<Device>();
|
||||
ConfigManager.SettingsCollection settings = ConfigManager.PluginSettings;
|
||||
if (settings.DoorsDeviceEnabled)
|
||||
if (settings.DoorSelectionDeviceEnabled)
|
||||
{
|
||||
Devices.Add(new Doors(settings.DoorsRequireClosingSound, settings.DoorsClosingSoundDuration, settings.DoorsClosingSoundTimeout, settings.DoorsClosingSoundIndex));
|
||||
Devices.Add(new DoorSelection());
|
||||
}
|
||||
if (settings.DoorClosingSoundDeviceEnabled)
|
||||
{
|
||||
Devices.Add(new DoorClosingSound(settings.DoorClosingSoundRequired, settings.DoorClosingSoundDuration, settings.DoorClosingSoundTimeout, settings.DoorClosingSoundIndex));
|
||||
}
|
||||
if (settings.DoorTractionCutDeviceEnabled)
|
||||
{
|
||||
Devices.Add(new DoorTractionCut());
|
||||
}
|
||||
if (settings.DeadmanDeviceEnabled)
|
||||
{
|
||||
|
@ -114,6 +125,7 @@ namespace OpenbveFcmbTrainPlugin
|
|||
internal void Elapse(ElapseData data, Route route)
|
||||
{
|
||||
State = data.Vehicle;
|
||||
DoorInterlockState = data.DoorInterlockState;
|
||||
|
||||
// Reset data to be passed to the simulator
|
||||
data.DoorInterlockState = DoorInterlockStates.Unlocked;
|
||||
|
|
Loading…
Add table
Reference in a new issue