OpenBve.TrainManager.ApplyReverser C# (CSharp) Метод

ApplyReverser() статический приватный Метод

Applies a reverser notch
static private ApplyReverser ( Train Train, int Value, bool Relative ) : void
Train Train The train
Value int The notch to apply
Relative bool Whether this is an absolute value or relative to the previous
Результат void
		internal static void ApplyReverser(Train Train, int Value, bool Relative)
		{
			int a = Train.Specs.CurrentReverser.Driver;
			int r = Relative ? a + Value : Value;
			if (r < -1) r = -1;
			if (r > 1) r = 1;
			if (a != r)
			{
				Train.Specs.CurrentReverser.Driver = r;
				if (Train.Plugin != null)
				{
					Train.Plugin.UpdateReverser();
				}
				Game.AddBlackBoxEntry(Game.BlackBoxEventToken.None);
				// sound
				if (a == 0 & r != 0)
				{
					Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.ReverserOn.Buffer;
					if (buffer == null) return;
					OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.ReverserOn.Position;
					Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
				}
				else if (a != 0 & r == 0)
				{
					Sounds.SoundBuffer buffer = Train.Cars[Train.DriverCar].Sounds.ReverserOff.Buffer;
					if (buffer == null) return;
					OpenBveApi.Math.Vector3 pos = Train.Cars[Train.DriverCar].Sounds.ReverserOff.Position;
					Sounds.PlaySound(buffer, 1.0, 1.0, pos, Train, Train.DriverCar, false);
				}
			}
		}
	}

Usage Example

Пример #1
0
 /// <summary>
 /// set reverser
 /// </summary>
 static public void SetReverser(int value)
 {
     try
     {
         TrainManager.ApplyReverser(nowControl, value, false);
         return;
     }
     catch (Exception ex) { }
 }
All Usage Examples Of OpenBve.TrainManager::ApplyReverser