OpenBve.TrainManager.CloseTrainDoors C# (CSharp) Method

CloseTrainDoors() static private method

Closes the left-hand or right-hand doors for the specified train
static private CloseTrainDoors ( Train Train, bool Left, bool Right ) : void
Train Train The train
Left bool Whether to close the left-hand doors
Right bool Whether to close the right-hand doors
return void
		internal static void CloseTrainDoors(Train Train, bool Left, bool Right)
		{
			bool sl = false, sr = false;
			for (int i = 0; i < Train.Cars.Length; i++)
			{
				if (Left & Train.Cars[i].Specs.AnticipatedLeftDoorsOpened)
				{
					Train.Cars[i].Specs.AnticipatedLeftDoorsOpened = false;
					sl = true;
				}
				if (Right & Train.Cars[i].Specs.AnticipatedRightDoorsOpened)
				{
					Train.Cars[i].Specs.AnticipatedRightDoorsOpened = false;
					sr = true;
				}
			}
			if (sl)
			{
				for (int i = 0; i < Train.Cars.Length; i++)
				{
					Sounds.SoundBuffer buffer = Train.Cars[i].Sounds.DoorCloseL.Buffer;
					if (buffer != null)
					{
						OpenBveApi.Math.Vector3 pos = Train.Cars[i].Sounds.DoorCloseL.Position;
						Sounds.PlaySound(buffer, Train.Cars[i].Specs.DoorClosePitch, 1.0, pos, Train, i, false);
					}
				}
			}
			if (sr)
			{
				for (int i = 0; i < Train.Cars.Length; i++)
				{
					Sounds.SoundBuffer buffer = Train.Cars[i].Sounds.DoorCloseR.Buffer;
					if (buffer != null)
					{
						OpenBveApi.Math.Vector3 pos = Train.Cars[i].Sounds.DoorCloseR.Position;
						Sounds.PlaySound(buffer, Train.Cars[i].Specs.DoorClosePitch, 1.0, pos, Train, i, false);
					}
				}
			}
		}

Usage Example

Esempio n. 1
0
 /// <summary>
 /// close left door
 /// </summary>
 static public void RightDoorClose()
 {
     try
     {
         TrainManager.CloseTrainDoors(TrainManager.PlayerTrain, false, true);
     }
     catch (Exception ex) { }
 }
All Usage Examples Of OpenBve.TrainManager::CloseTrainDoors