//================================================================================================// /// <summary> /// check if any trains occupy track /// Check based on direction /// </summary> public bool Occupied(int direction, bool stationary) { return(OccupationState.Where(state => (state.Value == direction && state.Key.Train.SpeedMpS > 0.5f) || (stationary && state.Key.Train.SpeedMpS <= 0.5)).Any()); }
//================================================================================================// /// <summary> /// check if any trains occupy track /// Check for other train based on direction /// </summary> public bool OccupiedByOtherTrains(int direction, bool stationary, Train.TrainRouted train) { return(OccupationState.Where(state => (state.Key != train) && ((state.Value == direction && state.Key.Train.SpeedMpS > 0.5f) || (stationary && state.Key.Train.SpeedMpS <= 0.5))).Any()); }
//================================================================================================// /// <summary> /// Get list of trains occupying track /// Check based on direction /// </summary> public List <Train.TrainRouted> TrainsOccupying(int direction) { return(OccupationState.Where(state => state.Value == direction).Select(state => state.Key).ToList()); }