internal static TrainDoorState GetDoorsState(Train Train, bool Left, bool Right)
{
bool opened = false, closed = false, mixed = false;
for (int i = 0; i < Train.Cars.Length; i++)
{
for (int j = 0; j < Train.Cars[i].Specs.Doors.Length; j++)
{
if (Left & Train.Cars[i].Specs.Doors[j].Direction == -1 | Right & Train.Cars[i].Specs.Doors[j].Direction == 1)
{
if (Train.Cars[i].Specs.Doors[j].State == 0.0)
{
closed = true;
}
else if (Train.Cars[i].Specs.Doors[j].State == 1.0)
{
opened = true;
}
else
{
mixed = true;
}
}
}
}
TrainDoorState Result = TrainDoorState.None;
if (opened) Result |= TrainDoorState.Opened;
if (closed) Result |= TrainDoorState.Closed;
if (mixed) Result |= TrainDoorState.Mixed;
if (opened & !closed & !mixed) Result |= TrainDoorState.AllOpened;
if (!opened & closed & !mixed) Result |= TrainDoorState.AllClosed;
if (!opened & !closed & mixed) Result |= TrainDoorState.AllMixed;
return Result;
}
}