OpenBve.TrainManager.ApplyEmergencyBrake C# (CSharp) Method

ApplyEmergencyBrake() static private method

Applies the emergency brake
static private ApplyEmergencyBrake ( Train Train ) : void
Train Train The train
return void
		internal static void ApplyEmergencyBrake(Train Train)
		{
			// sound
			if (!Train.Specs.CurrentEmergencyBrake.Driver)
			{
				Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.BrakeHandleMax.Buffer;
				if (buffer != null)
				{
					OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.BrakeHandleMax.Position;
					Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
				}
				for (int i = 0; i < Train.Cars.Length; i++)
				{
					buffer = Train.Cars[Train.DriverCar].Sounds.EmrBrake.Buffer;
					if (buffer != null)
					{
						OpenBveApi.Math.Vector3 pos = Train.Cars[i].Sounds.EmrBrake.Position;
						Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
					}
				}
			}
			// apply
			ApplyNotch(Train, 0, !Train.Specs.SingleHandle, Train.Specs.MaximumBrakeNotch, true);
			ApplyAirBrakeHandle(Train, AirBrakeHandleState.Service);
			Train.Specs.CurrentEmergencyBrake.Driver = true;
			Train.Specs.CurrentHoldBrake.Driver = false;
			Train.Specs.CurrentConstSpeed = false;
			// plugin
			if (Train.Plugin == null) return;
			Train.Plugin.UpdatePower();
			Train.Plugin.UpdateBrake();
		}

Usage Example

Beispiel #1
0
        /// <summary>
        /// main timer interrupt
        /// </summary>
        static private void MainTimerProcess(object state)
        {
            if (Interlocked.Exchange(ref inTimer_Main, 1) == 0)
            {
                try
                {
                    nowControl = TrainManager.PlayerTrain;
                    //Master key
                    if (!MasterKey)
                    {
                        SetAutoPilot(0);
                        SetBrake(0);
                        SetPower(0);
                        ReverserNeutral();
                    }

                    //emergency
                    if (Emergency)
                    {
                        SetAutoPilot(0);
                        TrainManager.ApplyEmergencyBrake(nowControl);
                    }
                    else
                    {
                        TrainManager.UnapplyEmergencyBrake(nowControl);
                    }

                    //signal
                    if (GetSignal() == 0)
                    {
                        inRedLight = true;
                    }
                    else
                    {
                        if (inRedLight)
                        {
                            SetBrake(nowControl.Handles.Brake.MaximumNotch);
                            SetReverser(0);
                            SetAutoPilot(0);
                        }
                        inRedLight = false;
                    }
                }
                catch (Exception ex) { }
                Interlocked.Exchange(ref inTimer_Main, 0);
            }
        }
All Usage Examples Of OpenBve.TrainManager::ApplyEmergencyBrake