internal static void OpenTrainDoors(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 = true;
sl = true;
}
if (Right & !Train.Cars[i].Specs.AnticipatedRightDoorsOpened)
{
Train.Cars[i].Specs.AnticipatedRightDoorsOpened = true;
sr = true;
}
}
if (sl)
{
for (int i = 0; i < Train.Cars.Length; i++)
{
Sounds.SoundBuffer buffer = Train.Cars[i].Sounds.DoorOpenL.Buffer;
if (buffer != null)
{
OpenBveApi.Math.Vector3 pos = Train.Cars[i].Sounds.DoorOpenL.Position;
Sounds.PlaySound(buffer, Train.Cars[i].Specs.DoorOpenPitch, 1.0, pos, Train, i, false);
}
for (int j = 0; j < Train.Cars[i].Specs.Doors.Length; j++)
{
if (Train.Cars[i].Specs.Doors[j].Direction == -1)
{
Train.Cars[i].Specs.Doors[j].DoorLockDuration = 0.0;
}
}
}
}
if (sr)
{
for (int i = 0; i < Train.Cars.Length; i++)
{
Sounds.SoundBuffer buffer = Train.Cars[i].Sounds.DoorOpenR.Buffer;
if (buffer != null)
{
OpenBveApi.Math.Vector3 pos = Train.Cars[i].Sounds.DoorOpenR.Position;
Sounds.PlaySound(buffer, Train.Cars[i].Specs.DoorClosePitch, 1.0, pos, Train, i, false);
}
for (int j = 0; j < Train.Cars[i].Specs.Doors.Length; j++)
{
if (Train.Cars[i].Specs.Doors[j].Direction == 1)
{
Train.Cars[i].Specs.Doors[j].DoorLockDuration = 0.0;
}
}
}
}
}