Fixes
parent
bcc0f1d4b9
commit
06bb2e2ee0
|
@ -76,6 +76,9 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
/// <param name="train">The current train.</param>
|
/// <param name="train">The current train.</param>
|
||||||
internal override void KeyChange(VirtualKeys key, bool pressed, Train train)
|
internal override void KeyChange(VirtualKeys key, bool pressed, Train train)
|
||||||
{
|
{
|
||||||
|
double speed = train.State.Speed.KilometersPerHour;
|
||||||
|
bool stopped = speed < 0.05;
|
||||||
|
|
||||||
if (pressed)
|
if (pressed)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
|
@ -87,7 +90,7 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
Counter = 0;
|
Counter = 0;
|
||||||
DeviceState = DeviceStates.Active;
|
DeviceState = DeviceStates.Active;
|
||||||
}
|
}
|
||||||
else if (DeviceState == DeviceStates.Emergency & Math.Abs(train.State.Speed.KilometersPerHour) < 0.01)
|
else if (DeviceState == DeviceStates.Emergency && stopped)
|
||||||
{
|
{
|
||||||
// Reset the counter after the train has stopped
|
// Reset the counter after the train has stopped
|
||||||
Counter = 0;
|
Counter = 0;
|
||||||
|
|
|
@ -94,13 +94,10 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
// Accidental departure beacon/transponder
|
// Accidental departure beacon/transponder
|
||||||
case 2:
|
case 2:
|
||||||
// Check if there is a potential SPAD and change to emergency mode
|
// Check if there is a potential SPAD and change to emergency mode
|
||||||
if (beacon.Signal.Aspect == 0)
|
if (beacon.Signal.Aspect == 0 && DeviceState == DeviceStates.Active)
|
||||||
{
|
|
||||||
if (DeviceState == DeviceStates.Active)
|
|
||||||
{
|
{
|
||||||
DeviceState = DeviceStates.Emergency;
|
DeviceState = DeviceStates.Emergency;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,8 +109,11 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
/// <param name="route">The current route.</param>
|
/// <param name="route">The current route.</param>
|
||||||
internal override void PerformAI(AIData data, Train train, Route route)
|
internal override void PerformAI(AIData data, Train train, Route route)
|
||||||
{
|
{
|
||||||
|
double speed = train.State.Speed.KilometersPerHour;
|
||||||
|
bool stopped = speed < 0.05;
|
||||||
|
|
||||||
// Reset device in case of emergency, once the train has stopped
|
// Reset device in case of emergency, once the train has stopped
|
||||||
if (DeviceState == DeviceStates.Emergency && train.State.Speed.KilometersPerHour < 0.05)
|
if (DeviceState == DeviceStates.Emergency && stopped)
|
||||||
{
|
{
|
||||||
data.Handles.BrakeNotch = train.Specs.BrakeNotches;
|
data.Handles.BrakeNotch = train.Specs.BrakeNotches;
|
||||||
KeyChange(VirtualKeys.C2, true, train);
|
KeyChange(VirtualKeys.C2, true, train);
|
||||||
|
|
|
@ -124,6 +124,7 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
/// <param name="beacon">The beacon data.</param>
|
/// <param name="beacon">The beacon data.</param>
|
||||||
public void SetBeacon(BeaconData beacon)
|
public void SetBeacon(BeaconData beacon)
|
||||||
{
|
{
|
||||||
|
Train.SetBeacon(beacon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Is called when the plugin should perform the AI.</summary>
|
/// <summary>Is called when the plugin should perform the AI.</summary>
|
||||||
|
|
Loading…
Reference in New Issue