예제 #1
0
파일: rail_map.cs 프로젝트: lmxdk/Nopenttd
/**
 * Gets the state of the signal along the given trackdir.
 *
 * Along meaning if you are currently driving on the given trackdir, this is
 * the signal that is facing us (for which we stop when it's red).
 */
        public static SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
        {
            Debug.Assert(IsValidTrackdir(trackdir));
            Debug.Assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)));
            return(GetSignalStates(tile) & SignalAlongTrackdir(trackdir)
                ? SignalState.SIGNAL_STATE_GREEN
                : SignalState.SIGNAL_STATE_RED);
        }
예제 #2
0
파일: rail_map.cs 프로젝트: lmxdk/Nopenttd
/**
 * Sets the state of the signal along the given trackdir.
 */
        public static void SetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir, SignalState state)
        {
            if (state == SignalState.SIGNAL_STATE_GREEN)
            {
                // set 1
                SetSignalStates(tile, GetSignalStates(tile) | SignalAlongTrackdir(trackdir));
            }
            else
            {
                SetSignalStates(tile, GetSignalStates(tile) & ~SignalAlongTrackdir(trackdir));
            }
        }
예제 #3
0
파일: rail_map.cs 프로젝트: lmxdk/Nopenttd
/**
 * Is a one-way signal blocking the trackdir? A one-way signal on the
 * trackdir against will block, but signals on both trackdirs won't.
 * @param tile the tile to check
 * @param td the trackdir to check
 */
        public static bool HasOnewaySignalBlockingTrackdir(TileIndex tile, Trackdir td)
        {
            return(TileMap.IsTileType(tile, TileType.MP_RAILWAY) && HasSignalOnTrackdir(tile, ReverseTrackdir(td)) &&
                   !HasSignalOnTrackdir(tile, td) && IsOnewaySignal(tile, TrackdirToTrack(td)));
        }
예제 #4
0
파일: rail_map.cs 프로젝트: lmxdk/Nopenttd
/**
 * Is a pbs signal present along the trackdir?
 * @param tile the tile to check
 * @param td the trackdir to check
 */
        public static bool HasPbsSignalOnTrackdir(TileIndex tile, Trackdir td)
        {
            return(TileMap.IsTileType(tile, TileType.MP_RAILWAY) && HasSignalOnTrackdir(tile, td) &&
                   IsPbsSignal(GetSignalType(tile, TrackdirToTrack(td))));
        }
예제 #5
0
파일: rail_map.cs 프로젝트: lmxdk/Nopenttd
/**
 * Checks for the presence of signals along the given trackdir on the given
 * rail tile.
 *
 * Along meaning if you are currently driving on the given trackdir, this is
 * the signal that is facing us (for which we stop when it's red).
 */
        public static bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
        {
            Debug.Assert(IsValidTrackdir(trackdir));
            return(GetRailTileType(tile) == RailTileType.RAIL_TILE_SIGNALS &&
                   GetPresentSignals(tile) & SignalAlongTrackdir(trackdir));
        }