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);
}
}
}
}