Exemple #1
0
        public override void ApplyState(AirBrakeHandleState newState)
        {
            if ((int)newState != Driver)
            {
                // sound when moved to service
                if (newState == AirBrakeHandleState.Service)
                {
                    baseTrain.Cars[baseTrain.DriverCar].CarBrake.Release.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                }

                // sound
                if ((int)newState < Driver)
                {
                    // brake release
                    if (newState > 0)
                    {
                        // brake release (not min)
                        if (Driver - (int)newState > 2 | ContinuousMovement && DecreaseFast.Buffer != null)
                        {
                            DecreaseFast.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                        }
                        else
                        {
                            Decrease.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                        }
                    }
                    else
                    {
                        // brake min
                        Min.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                    }
                }
                else if ((int)newState > Driver)
                {
                    // brake
                    if ((int)newState - Driver > 2 | ContinuousMovement && IncreaseFast.Buffer != null)
                    {
                        IncreaseFast.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                    }
                    else
                    {
                        Increase.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                    }
                }

                Driver = (int)newState;
                TrainManagerBase.currentHost.AddBlackBoxEntry();
                // plugin
                if (baseTrain.Plugin != null)
                {
                    baseTrain.Plugin.UpdatePower();
                    baseTrain.Plugin.UpdateBrake();
                }
            }
        }
Exemple #2
0
        public override void ApplyState(int newState, bool relativeChange, bool isOverMaxDriverNotch = false)
        {
            // determine notch
            int p = relativeChange ? newState + Driver : newState;

            if (p < 0)
            {
                p = 0;
            }
            else if (p > MaximumNotch)
            {
                p = MaximumNotch;
            }
            if (!isOverMaxDriverNotch && p > MaximumDriverNotch)
            {
                p = MaximumDriverNotch;
            }

            // power sound
            if (p < Driver)
            {
                if (p > 0)
                {
                    // down (not min)
                    if (Driver - p > 2 | ContinuousMovement && DecreaseFast.Buffer != null)
                    {
                        DecreaseFast.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                    }
                    else
                    {
                        Decrease.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                    }
                }
                else
                {
                    // min
                    Min.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                }
            }
            else if (p > Driver)
            {
                if (p < MaximumDriverNotch)
                {
                    // up (not max)
                    if (Driver - p > 2 | ContinuousMovement && IncreaseFast.Buffer != null)
                    {
                        IncreaseFast.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                    }
                    else
                    {
                        Increase.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                    }
                }
                else
                {
                    // max
                    Max.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                }
            }

            if (baseTrain.Handles.HandleType != HandleType.TwinHandle && baseTrain.Handles.Brake.Driver != 0)
            {
                p = 0;
            }
            Driver = p;
            TrainManagerBase.currentHost.AddBlackBoxEntry();
            // plugin
            if (baseTrain.Plugin != null)
            {
                baseTrain.Plugin.UpdatePower();
                baseTrain.Plugin.UpdateBrake();
            }
        }
Exemple #3
0
        public override void ApplyState(int BrakeValue, bool BrakeRelative, bool IsOverMaxDriverNotch = false)
        {
            int b = BrakeRelative ? BrakeValue + Driver : BrakeValue;

            if (b < 0)
            {
                b = 0;
            }
            else if (b > MaximumNotch)
            {
                b = MaximumNotch;
            }
            if (!IsOverMaxDriverNotch && b > MaximumDriverNotch)
            {
                b = MaximumDriverNotch;
            }

            // brake sound
            if (b < Driver)
            {
                // brake release
                baseTrain.Cars[baseTrain.DriverCar].CarBrake.Release.Play(baseTrain.Cars[baseTrain.DriverCar], false);

                if (b > 0)
                {
                    // brake release (not min)
                    if (Driver - b > 2 | ContinuousMovement && DecreaseFast.Buffer != null)
                    {
                        DecreaseFast.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                    }
                    else
                    {
                        Decrease.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                    }
                }
                else
                {
                    // brake min
                    Min.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                }
            }
            else if (b > Driver)
            {
                // brake
                if (b - Driver > 2 | ContinuousMovement && IncreaseFast.Buffer != null)
                {
                    IncreaseFast.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                }
                else
                {
                    Increase.Play(baseTrain.Cars[baseTrain.DriverCar], false);
                }
            }

            Driver = b;
            TrainManagerBase.currentHost.AddBlackBoxEntry();
            // plugin
            if (baseTrain.Plugin != null)
            {
                baseTrain.Plugin.UpdatePower();
                baseTrain.Plugin.UpdateBrake();
            }
        }