Exemplo n.º 1
0
        /// <summary>Moves the air brake handle to the specified state</summary>
        /// <param name="newState">The state</param>
        public void ApplyLocoAirBrakeHandle(AirBrakeHandleState newState)
        {
            if (Handles.LocoBrake is LocoAirBrakeHandle)
            {
                if ((int)newState != Handles.LocoBrake.Driver)
                {
                    // sound when moved to service
                    if (newState == AirBrakeHandleState.Service)
                    {
                        Cars[DriverCar].CarBrake.Release.Play(Cars[DriverCar], false);
                    }

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

                    // apply
                    Handles.LocoBrake.Driver = (int)newState;
                    Handles.LocoBrake.Actual = (int)newState;                              //TODO: FIXME
                    TrainManagerBase.currentHost.AddBlackBoxEntry();
                    // plugin
                    if (Plugin != null)
                    {
                        Plugin.UpdatePower();
                        Plugin.UpdateBrake();
                    }
                }
            }
        }
Exemplo n.º 2
0
 internal override void Update()
 {
     if (DelayedValue != AirBrakeHandleState.Invalid)
     {
         if (DelayedTime <= Program.CurrentRoute.SecondsSinceMidnight)
         {
             Actual       = (int)DelayedValue;
             DelayedValue = AirBrakeHandleState.Invalid;
         }
     }
     else
     {
         if (Safety == (int)AirBrakeHandleState.Release & Actual != (int)AirBrakeHandleState.Release)
         {
             DelayedValue = AirBrakeHandleState.Release;
             DelayedTime  = Program.CurrentRoute.SecondsSinceMidnight;
         }
         else if (Safety == (int)AirBrakeHandleState.Service & Actual != (int)AirBrakeHandleState.Service)
         {
             DelayedValue = AirBrakeHandleState.Service;
             DelayedTime  = Program.CurrentRoute.SecondsSinceMidnight;
         }
         else if (Safety == (int)AirBrakeHandleState.Lap)
         {
             Actual = (int)AirBrakeHandleState.Lap;
         }
     }
 }
Exemplo n.º 3
0
 public override void Update()
 {
     if (DelayedValue != AirBrakeHandleState.Invalid)
     {
         if (DelayedTime <= TrainManagerBase.currentHost.InGameTime)
         {
             Actual       = (int)DelayedValue;
             DelayedValue = AirBrakeHandleState.Invalid;
         }
     }
     else
     {
         if (Safety == (int)AirBrakeHandleState.Release & Actual != (int)AirBrakeHandleState.Release)
         {
             DelayedValue = AirBrakeHandleState.Release;
             DelayedTime  = TrainManagerBase.currentHost.InGameTime;
         }
         else if (Safety == (int)AirBrakeHandleState.Service & Actual != (int)AirBrakeHandleState.Service)
         {
             DelayedValue = AirBrakeHandleState.Service;
             DelayedTime  = TrainManagerBase.currentHost.InGameTime;
         }
         else if (Safety == (int)AirBrakeHandleState.Lap)
         {
             Actual = (int)AirBrakeHandleState.Lap;
         }
     }
 }
			internal void Update()
			{
				if (DelayedValue != AirBrakeHandleState.Invalid)
				{
					if (DelayedTime <= Game.SecondsSinceMidnight)
					{
						Actual = DelayedValue;
						DelayedValue = AirBrakeHandleState.Invalid;
					}
				}
				else
				{
					if (Safety == AirBrakeHandleState.Release & Actual != AirBrakeHandleState.Release)
					{
						DelayedValue = AirBrakeHandleState.Release;
						DelayedTime = Game.SecondsSinceMidnight;
					}
					else if (Safety == AirBrakeHandleState.Service & Actual != AirBrakeHandleState.Service)
					{
						DelayedValue = AirBrakeHandleState.Service;
						DelayedTime = Game.SecondsSinceMidnight;
					}
					else if (Safety == AirBrakeHandleState.Lap)
					{
						Actual = AirBrakeHandleState.Lap;
					}
				}
			}
Exemplo n.º 5
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();
                }
            }
        }
Exemplo n.º 6
0
 internal static void ApplyAirBrakeHandle(Train Train, AirBrakeHandleState State)
 {
     if (Train.Cars[Train.DriverCar].Specs.BrakeType == CarBrakeType.AutomaticAirBrake) {
         if (State != Train.Specs.AirBrake.Handle.Driver) {
             // sound when moved to service
             if (State == AirBrakeHandleState.Service) {
                 Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.Brake.Buffer;
                 if (buffer != null) {
                     OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.Brake.Position;
                     Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                 }
             }
             // sound
             if ((int)State < (int)Train.Specs.AirBrake.Handle.Driver) {
                 // brake release
                 if ((int)State > 0) {
                     // brake release (not min)
                     Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleRelease.Buffer;
                     if (buffer != null) {
                         OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleRelease.Position;
                         Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                     }
                 } else {
                     // brake min
                     Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleMin.Buffer;
                     if (buffer != null) {
                         OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleMin.Position;
                         Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                     }
                 }
             } else if ((int)State > (int)Train.Specs.AirBrake.Handle.Driver) {
                 // brake
                 Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleApply.Buffer;
                 if (buffer != null) {
                     OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleApply.Position;
                     Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                 }
             }
             // apply
             Train.Specs.AirBrake.Handle.Driver = State;
             Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
             // plugin
             if (Train.Plugin != null) {
                 Train.Plugin.UpdatePower();
                 Train.Plugin.UpdateBrake();
             }
         }
     }
 }
Exemplo n.º 7
0
            /// <summary>Moves the air brake handle to the specified state</summary>
            /// <param name="newState">The state</param>
            internal void ApplyLocoAirBrakeHandle(AirBrakeHandleState newState)
            {
                if (Handles.LocoBrake is LocoAirBrakeHandle)
                {
                    if ((int)newState != Handles.LocoBrake.Driver)
                    {
                        // sound when moved to service
                        if (newState == AirBrakeHandleState.Service)
                        {
                            SoundBuffer buffer = Cars[DriverCar].Sounds.Brake.Buffer;
                            if (buffer != null)
                            {
                                Vector3 pos = Cars[DriverCar].Sounds.Brake.Position;
                                Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                            }
                        }

                        // sound
                        if ((int)newState < (int)Handles.Brake.Driver)
                        {
                            // brake release
                            if ((int)newState > 0)
                            {
                                // brake release (not min)
                                SoundBuffer buffer;
                                if ((Handles.Brake.Driver - (int)newState > 2 | Cars[DriverCar].Sounds.BrakeHandleFast) && Cars[DriverCar].Sounds.BrakeHandleReleaseFast.Buffer != null)
                                {
                                    buffer = Cars[DriverCar].Sounds.BrakeHandleReleaseFast.Buffer;
                                }
                                else
                                {
                                    buffer = Cars[DriverCar].Sounds.BrakeHandleRelease.Buffer;
                                }
                                if (buffer != null)
                                {
                                    Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleRelease.Position;
                                    Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                                }
                            }
                            else
                            {
                                // brake min
                                SoundBuffer buffer = Cars[DriverCar].Sounds.BrakeHandleMin.Buffer;
                                if (buffer != null)
                                {
                                    Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleMin.Position;
                                    Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                                }
                            }
                        }
                        else if ((int)newState > (int)Handles.LocoBrake.Driver)
                        {
                            // brake
                            SoundBuffer buffer;
                            if (((int)newState - (int)Handles.LocoBrake.Driver > 2 | Cars[DriverCar].Sounds.BrakeHandleFast) && Cars[DriverCar].Sounds.BrakeHandleApplyFast.Buffer != null)
                            {
                                buffer = Cars[DriverCar].Sounds.BrakeHandleApplyFast.Buffer;
                            }
                            else
                            {
                                buffer = Cars[DriverCar].Sounds.BrakeHandleApply.Buffer;
                            }
                            if (buffer != null)
                            {
                                Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleApply.Position;
                                Program.Sounds.PlaySound(buffer, 1.0, 1.0, pos, Cars[DriverCar], false);
                            }
                        }

                        // apply
                        Handles.LocoBrake.Driver = (int)newState;
                        Handles.LocoBrake.Actual = (int)newState;                          //TODO: FIXME
                        Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
                        // plugin
                        if (Plugin != null)
                        {
                            Plugin.UpdatePower();
                            Plugin.UpdateBrake();
                        }
                    }
                }
            }
Exemplo n.º 8
0
        public override void Update(double TimeElapsed, double currentSpeed, AbstractHandle brakeHandle, out double deceleration)
        {
            airSound = null;
            if (emergencyHandle.Actual == true)
            {
                if (brakeType == BrakeType.Main)
                {
                    double r = equalizingReservoir.EmergencyRate;
                    double d = equalizingReservoir.CurrentPressure;
                    double m = equalizingReservoir.NormalPressure;
                    r = GetRate(d / m, r * TimeElapsed);
                    if (r > equalizingReservoir.CurrentPressure)
                    {
                        r = equalizingReservoir.CurrentPressure;
                    }
                    equalizingReservoir.CurrentPressure -= r;
                }
            }
            //First update the main reservoir pressure from the equalizing reservoir
            AirBrakeHandleState state = (AirBrakeHandleState)brakeHandle.Actual;

            switch (state)
            {
            case AirBrakeHandleState.Service:
            {
                double r = equalizingReservoir.ServiceRate;                         //50000
                double d = equalizingReservoir.CurrentPressure;
                double m = equalizingReservoir.NormalPressure;                      //1.05 * max service pressure from train.dat in pascals
                r = GetRate(d / m, r * TimeElapsed);
                if (r > equalizingReservoir.CurrentPressure)
                {
                    r = equalizingReservoir.CurrentPressure;
                }

                equalizingReservoir.CurrentPressure -= r;
                break;
            }

            case AirBrakeHandleState.Release:
            {
                double r = equalizingReservoir.ChargeRate;
                double d = equalizingReservoir.NormalPressure - equalizingReservoir.CurrentPressure;
                double m = equalizingReservoir.NormalPressure;
                r = GetRate(d / m, r * TimeElapsed);
                if (r > d)
                {
                    r = d;
                }

                d = mainReservoir.CurrentPressure - equalizingReservoir.CurrentPressure;
                if (r > d)
                {
                    r = d;
                }

                double f = mainReservoir.EqualizingReservoirCoefficient;
                double s = r * f * TimeElapsed;
                if (s > mainReservoir.CurrentPressure)
                {
                    r *= mainReservoir.CurrentPressure / s;
                    s  = mainReservoir.CurrentPressure;
                }

                equalizingReservoir.CurrentPressure += 0.5 * r;
                mainReservoir.CurrentPressure       -= 0.5 * s;
                break;
            }
            }
            //Fill the brake pipe from the main reservoir
            if (brakeType == BrakeType.Main)
            {
                if (brakePipe.CurrentPressure > equalizingReservoir.CurrentPressure + Tolerance)
                {
                    // brake pipe exhaust valve
                    double r = emergencyHandle.Actual ? brakePipe.EmergencyRate : brakePipe.ServiceRate;
                    double d = brakePipe.CurrentPressure - equalizingReservoir.CurrentPressure;
                    double m = equalizingReservoir.NormalPressure;
                    r = (0.5 + 1.5 * d / m) * r * TimeElapsed;
                    if (r > d)
                    {
                        r = d;
                    }
                    brakePipe.CurrentPressure -= r;
                }
                else if (brakePipe.CurrentPressure + Tolerance < equalizingReservoir.CurrentPressure)
                {
                    // fill brake pipe from main reservoir
                    double r = brakePipe.ChargeRate;
                    double d = equalizingReservoir.CurrentPressure - brakePipe.CurrentPressure;
                    double m = equalizingReservoir.NormalPressure;
                    r = (0.5 + 1.5 * d / m) * r * TimeElapsed;
                    if (r > d)
                    {
                        r = d;
                    }
                    d = brakePipe.NormalPressure - brakePipe.CurrentPressure;
                    if (r > d)
                    {
                        r = d;
                    }
                    double f = mainReservoir.BrakePipeCoefficient;
                    double s = r * f;
                    if (s > mainReservoir.CurrentPressure)
                    {
                        r *= mainReservoir.CurrentPressure / s;
                        s  = mainReservoir.CurrentPressure;
                    }
                    brakePipe.CurrentPressure     += 0.5 * r;
                    mainReservoir.CurrentPressure -= 0.5 * s;
                }
            }

            if (brakePipe.CurrentPressure + Tolerance < auxiliaryReservoir.CurrentPressure)
            {
                if (auxiliaryReservoir.CurrentPressure + Tolerance < brakeCylinder.CurrentPressure)
                {
                    // back-flow from brake cylinder to auxillary reservoir
                    double u = (brakeCylinder.CurrentPressure - auxiliaryReservoir.CurrentPressure - Tolerance) / Tolerance;
                    if (u > 1.0)
                    {
                        u = 1.0;
                    }
                    double f = auxiliaryReservoir.BrakeCylinderCoefficient;
                    double r = brakeCylinder.ServiceChargeRate * f;
                    double d = brakeCylinder.CurrentPressure - auxiliaryReservoir.CurrentPressure;
                    double m = auxiliaryReservoir.MaximumPressure;
                    r = GetRate(d * u / m, r * TimeElapsed);
                    if (auxiliaryReservoir.CurrentPressure + r > m)
                    {
                        r = m - auxiliaryReservoir.CurrentPressure;
                    }
                    if (r > d)
                    {
                        r = d;
                    }
                    double s = r / f;
                    if (s > d)
                    {
                        r *= d / s;
                        s  = d;
                    }
                    if (s > brakeCylinder.CurrentPressure)
                    {
                        r *= brakeCylinder.CurrentPressure / s;
                        s  = brakeCylinder.CurrentPressure;
                    }
                    auxiliaryReservoir.CurrentPressure += 0.5 * r;
                    brakeCylinder.CurrentPressure      -= 0.5 * s;
                }
                else if (auxiliaryReservoir.CurrentPressure > brakeCylinder.CurrentPressure + Tolerance)
                {
                    // refill brake cylinder from auxillary reservoir
                    double u = (auxiliaryReservoir.CurrentPressure - brakeCylinder.CurrentPressure - Tolerance) / Tolerance;
                    if (u > 1.0)
                    {
                        u = 1.0;
                    }
                    double f = auxiliaryReservoir.BrakeCylinderCoefficient;
                    double r = brakeCylinder.ServiceChargeRate * f;
                    double d = auxiliaryReservoir.CurrentPressure - brakeCylinder.CurrentPressure;
                    double m = auxiliaryReservoir.MaximumPressure;
                    r = GetRate(d * u / m, r * TimeElapsed);
                    if (r > auxiliaryReservoir.CurrentPressure)
                    {
                        r = auxiliaryReservoir.CurrentPressure;
                    }
                    if (r > d)
                    {
                        r = d;
                    }
                    double s = r / f;
                    if (s > d)
                    {
                        r *= d / s;
                        s  = d;
                    }
                    d = brakeCylinder.EmergencyMaximumPressure - brakeCylinder.CurrentPressure;
                    if (s > d)
                    {
                        r *= d / s;
                        s  = d;
                    }
                    auxiliaryReservoir.CurrentPressure -= 0.5 * r;
                    brakeCylinder.CurrentPressure      += 0.5 * s;
                }
                // air sound
                brakeCylinder.SoundPlayedForPressure = brakeCylinder.EmergencyMaximumPressure;
            }
            else if (brakePipe.CurrentPressure > auxiliaryReservoir.CurrentPressure + Tolerance)
            {
                double u = (brakePipe.CurrentPressure - auxiliaryReservoir.CurrentPressure - Tolerance) / Tolerance;
                if (u > 1.0)
                {
                    u = 1.0;
                }
                {
                    // refill auxillary reservoir from brake pipe
                    double r = auxiliaryReservoir.ChargeRate;
                    double d = brakePipe.CurrentPressure - auxiliaryReservoir.CurrentPressure;
                    double m = auxiliaryReservoir.MaximumPressure;
                    r = GetRate(d * u / m, r * TimeElapsed);
                    if (r > brakePipe.CurrentPressure)
                    {
                        r = brakePipe.CurrentPressure;
                    }

                    if (r > d)
                    {
                        r = d;
                    }
                    d = auxiliaryReservoir.MaximumPressure - auxiliaryReservoir.CurrentPressure;
                    if (r > d)
                    {
                        r = d;
                    }
                    double f = auxiliaryReservoir.BrakePipeCoefficient;
                    double s = r / f;
                    if (s > brakePipe.CurrentPressure)
                    {
                        r *= brakePipe.CurrentPressure / s;
                        s  = brakePipe.CurrentPressure;
                    }

                    if (s > d)
                    {
                        r *= d / s;
                        s  = d;
                    }

                    auxiliaryReservoir.CurrentPressure += 0.5 * r;
                    brakePipe.CurrentPressure          -= 0.5 * s;
                }
                {
                    // brake cylinder release
                    double r = brakeCylinder.ReleaseRate;
                    double d = brakeCylinder.CurrentPressure;
                    double m = brakeCylinder.EmergencyMaximumPressure;
                    r = GetRate(d * u / m, r * TimeElapsed);
                    if (r > brakeCylinder.CurrentPressure)
                    {
                        r = brakeCylinder.CurrentPressure;
                    }
                    brakeCylinder.CurrentPressure -= r;
                    // air sound
                    if (r > 0.0 & brakeCylinder.CurrentPressure < brakeCylinder.SoundPlayedForPressure)
                    {
                        double p = 0.8 * brakeCylinder.CurrentPressure - 0.2 * brakeCylinder.EmergencyMaximumPressure;
                        if (p < 0.0)
                        {
                            p = 0.0;
                        }
                        brakeCylinder.SoundPlayedForPressure = p;
                        airSound = p <Tolerance?AirZero : brakeCylinder.CurrentPressure> m - Tolerance ? AirHigh : Air;
                    }
                }
            }
            else
            {
                // air sound
                brakeCylinder.SoundPlayedForPressure = brakeCylinder.EmergencyMaximumPressure;
            }
            double pressureratio = brakeCylinder.CurrentPressure / brakeCylinder.ServiceMaximumPressure;

            deceleration = pressureratio * DecelerationAtServiceMaximumPressure(brakeHandle.Actual, currentSpeed);
        }
Exemplo n.º 9
0
 public virtual void ApplyState(AirBrakeHandleState newState)
 {
 }
Exemplo n.º 10
0
            /// <summary>Moves the air brake handle to the specified state</summary>
            /// <param name="State">The state</param>
            internal void ApplyAirBrakeHandle(AirBrakeHandleState State)
            {
                if (Handles.Brake is AirBrakeHandle)
                {
                    if ((int)State != Handles.Brake.Driver)
                    {
                        // sound when moved to service
                        if (State == AirBrakeHandleState.Service)
                        {
                            Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.Brake.Buffer;
                            if (buffer != null)
                            {
                                OpenBveApi.Math.Vector3 pos = Cars[DriverCar].Sounds.Brake.Position;
                                Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                            }
                        }

                        // sound
                        if ((int)State < (int)Handles.Brake.Driver)
                        {
                            // brake release
                            if ((int)State > 0)
                            {
                                // brake release (not min)
                                Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.BrakeHandleRelease.Buffer;
                                if (buffer != null)
                                {
                                    OpenBveApi.Math.Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleRelease.Position;
                                    Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                                }
                            }
                            else
                            {
                                // brake min
                                Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.BrakeHandleMin.Buffer;
                                if (buffer != null)
                                {
                                    OpenBveApi.Math.Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleMin.Position;
                                    Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                                }
                            }
                        }
                        else if ((int)State > (int)Handles.Brake.Driver)
                        {
                            // brake
                            Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.BrakeHandleApply.Buffer;
                            if (buffer != null)
                            {
                                OpenBveApi.Math.Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleApply.Position;
                                Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                            }
                        }

                        // apply
                        Handles.Brake.Driver = (int)State;
                        Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
                        // plugin
                        if (Plugin != null)
                        {
                            Plugin.UpdatePower();
                            Plugin.UpdateBrake();
                        }
                    }
                }
            }
Exemplo n.º 11
0
 /// <summary>Moves the air brake handle to the specified state</summary>
 /// <param name="Train">The train</param>
 /// <param name="State">The state</param>
 internal static void ApplyAirBrakeHandle(Train Train, AirBrakeHandleState State)
 {
     if (Train.Cars[Train.DriverCar].Specs.BrakeType == CarBrakeType.AutomaticAirBrake)
     {
         if (State != Train.Specs.AirBrake.Handle.Driver)
         {
             // sound when moved to service
             if (State == AirBrakeHandleState.Service)
             {
                 Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.Brake.Buffer;
                 if (buffer != null)
                 {
                     OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.Brake.Position;
                     Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                 }
             }
             // sound
             if ((int)State < (int)Train.Specs.AirBrake.Handle.Driver)
             {
                 // brake release
                 if ((int)State > 0)
                 {
                     // brake release (not min)
                     Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleRelease.Buffer;
                     if (buffer != null)
                     {
                         OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleRelease.Position;
                         Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                     }
                 }
                 else
                 {
                     // brake min
                     Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleMin.Buffer;
                     if (buffer != null)
                     {
                         OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleMin.Position;
                         Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                     }
                 }
             }
             else if ((int)State > (int)Train.Specs.AirBrake.Handle.Driver)
             {
                 // brake
                 Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleApply.Buffer;
                 if (buffer != null)
                 {
                     OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleApply.Position;
                     Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
                 }
             }
             // apply
             Train.Specs.AirBrake.Handle.Driver = State;
             Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
             // plugin
             if (Train.Plugin != null)
             {
                 Train.Plugin.UpdatePower();
                 Train.Plugin.UpdateBrake();
             }
         }
     }
 }