internal ReverserHandle() { Driver = ReverserPosition.Neutral; Actual = ReverserPosition.Neutral; EngageSound = new CarSound(); ReleaseSound = new CarSound(); }
/// <summary>Called once a frame to update the constant speed device</summary> /// <param name="Acceleration">The current acceleration output of the train</param> /// <param name="Enabled">Whether the constant speed device is enabled (As this refers to the whole train)</param> /// <param name="ReverserPosition">The current position of the reverser handle</param> internal void Update(ref double Acceleration, bool Enabled, ReverserPosition ReverserPosition) { if (!Enabled) { this.CurrentAccelerationOutput = Acceleration; return; } if (Game.SecondsSinceMidnight < this.NextUpdateTime) { return; } this.NextUpdateTime = Game.SecondsSinceMidnight + UpdateInterval; this.CurrentAccelerationOutput -= 0.8 * this.Car.Specs.CurrentAcceleration * (double)ReverserPosition; if (this.CurrentAccelerationOutput < 0.0) { this.CurrentAccelerationOutput = 0.0; } if (Acceleration > CurrentAccelerationOutput) { Acceleration = CurrentAccelerationOutput; } if (Acceleration < 0.0) { Acceleration = 0.0; } }
/// <summary>Called once a frame to update the constant speed device</summary> /// <param name="Acceleration">The current acceleration output of the train</param> /// <param name="Enabled">Whether the constant speed device is enabled (As this refers to the whole train)</param> /// <param name="ReverserPosition">The current position of the reverser handle</param> public void Update(ref double Acceleration, bool Enabled, ReverserPosition ReverserPosition) { if (!Enabled) { this.CurrentAccelerationOutput = Acceleration; return; } if (TrainManagerBase.currentHost.InGameTime >= this.NextUpdateTime) { this.NextUpdateTime = TrainManagerBase.currentHost.InGameTime + UpdateInterval; this.CurrentAccelerationOutput -= 0.8 * this.Car.Specs.Acceleration * (double)ReverserPosition; if (this.CurrentAccelerationOutput < 0.0) { this.CurrentAccelerationOutput = 0.0; } } if (Acceleration > CurrentAccelerationOutput) { Acceleration = CurrentAccelerationOutput; } if (Acceleration < 0.0) { Acceleration = 0.0; } }
public ReverserHandle(TrainBase train) { Driver = ReverserPosition.Neutral; Actual = ReverserPosition.Neutral; EngageSound = new CarSound(); ReleaseSound = new CarSound(); baseTrain = train; }
public void ApplyState(int Value, bool Relative) { if (baseTrain.Handles.HandleType == HandleType.InterlockedReverserHandle && baseTrain.Handles.Power.Driver != 0) { return; } int a = (int)Driver; int r = Relative ? a + Value : Value; if (r < -1) { r = -1; } if (r > 1) { r = 1; } if (a != r) { Driver = (ReverserPosition)r; if (baseTrain.Plugin != null) { baseTrain.Plugin.UpdateReverser(); } TrainManagerBase.currentHost.AddBlackBoxEntry(); // sound if (a == 0 & r != 0) { EngageSound.Play(baseTrain.Cars[baseTrain.DriverCar], false); } else if (a != 0 & r == 0) { ReleaseSound.Play(baseTrain.Cars[baseTrain.DriverCar], false); } } }
internal ReverserHandle() { Driver = ReverserPosition.Neutral; Actual = ReverserPosition.Neutral; }
public void ApplyState(ReverserPosition Value) { ApplyState((int)Value, false); }