OpenBve.TrainManager.GetDoorsState C# (CSharp) Method

GetDoorsState() static private method

Returns the combination of door states encountered in a train.
static private GetDoorsState ( Train Train, bool Left, bool Right ) : TrainDoorState
Train Train The train to consider.
Left bool Whether to include left doors.
Right bool Whether to include right doors.
return TrainDoorState
		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;
		}
	}