/** * Returns the RailTileType (normal with or without signals, * waypoint or depot). * @param t the tile to get the information from * @pre IsTileType(t, MP_RAILWAY) * @return the RailTileType */ public static RailTileType GetRailTileType(this TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_RAILWAY)); return((RailTileType)BitMath.GB(Map._m[t].m5, 6, 2)); }
/** * Sets the counter used to advance to the next clear density/field type. * @param t the tile to set the counter of * @param c the amount to set the counter to * @pre TileMap.IsTileType(t, TileType.MP_CLEAR) */ public static void SetClearCounter(this TileIndex t, uint c) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); // XXX incomplete Map._m[t].m5 = BitMath.SB(Map._m[t].m5, 5, 3, (byte)c); }
/** * Test if a tile is covered with snow. * @param t the tile to check * @pre TileMap.IsTileType(t, TileType.MP_CLEAR) * @return whether the tile is covered with snow. */ public static bool IsSnowTile(this TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); return(BitMath.HasBit(Map._m[t].m3, 4)); }
/** * Increment the density of a non-field clear tile. * @param t the tile to increment the density of * @param d the amount to increment the density with * @pre TileMap.IsTileType(t, TileType.MP_CLEAR) */ public static void AddClearDensity(this TileIndex t, int d) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); // XXX incomplete Map._m[t].m5 += (byte)d; }
/** * Get the counter used to advance to the next clear density/field type. * @param t the tile to get the counter of * @pre TileMap.IsTileType(t, TileType.MP_CLEAR) * @return the value of the counter */ public static uint GetClearCounter(this TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); return(BitMath.GB(Map._m[t].m5, 5, 3)); }
/** * Get the type of the road tile. * @param t Tile to query. * @pre IsTileType(t, MP_ROAD) * @return The road tile type. */ public static RoadTileType GetRoadTileType(this TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_ROAD)); return((RoadTileType)BitMath.GB(Map._m[t].m5, 6, 2)); }
/** * checks if there is a bridge on this tile * @param t The tile to analyze * @return true if a bridge is present */ public static bool IsBridgeTile(TileIndex t) { return(TileMap.IsTileType(t, TileType.MP_TUNNELBRIDGE) && IsBridge(t)); }
/** * Returns the 'density' of a tile with trees. * * This function returns the density of a tile which got trees. Note * that this value doesn't count the number of trees on a tile, use * #GetTreeCount instead. This function instead returns some kind of * groundtype of the tile. As the map-array is finite in size and * the informations about the trees must be saved somehow other * informations about a tile must be saved somewhere encoded in the * tile. So this function returns the density of a tile for sub arctic * and sub tropical games. This means for sub arctic the type of snowline * (0 to 3 for all 4 types of snowtiles) and for sub tropical the value * 3 for a desert (and 0 for non-desert). The function name is not read as * "get the tree density of a tile" but "get the density of a tile which got trees". * * @param t The tile to get the 'density' * @pre Tile must be of type TileType.MP_TREES) * @see GetTreeCount */ public static uint GetTreeDensity(TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TREES)); return(BitMath.GB(Map._m[t].m2, 4, 2)); }
/** * Set the density and ground type of a tile with trees. * * This functions saves the ground type and the density which belongs to it * for a given tile. * * @param t The tile to set the density and ground type * @param g The ground type to save * @param d The density to save with * @pre Tile must be of type TileType.MP_TREES) */ public static void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TREES)); // XXX incomplete Map._m[t].m2 = BitMath.SB(Map._m[t].m2, 4, 2, d); Map._m[t].m2 = BitMath.SB(Map._m[t].m2, 6, 3, g); }
/** * Returns the treetype of a tile. * * This function returns the treetype of a given tile. As there are more * possible treetypes for a tile in a game as the enumeration #TreeType defines * this function may be return a value which isn't catch by an entry of the * enumeration #TreeType. But there is no problem known about it. * * @param t The tile to get the treetype from * @return The treetype of the given tile with trees * @pre Tile t must be of type TileType.MP_TREES) */ public static TreeType GetTreeType(TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TREES)); return((TreeType)Map._m[t].m3); }
/** * Returns the groundtype for tree tiles. * * This function returns the groundtype of a tile with trees. * * @param t The tile to get the groundtype from * @return The groundtype of the tile * @pre Tile must be of type MP_TREES */ public static TreeGround GetTreeGround(TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TREES)); return((TreeGround)BitMath.GB(Map._m[t].m2, 6, 3)); }
/** * Checks whether the tile is a rail tile or rail tile with signals. * @param t the tile to get the information from * @return true if and only if the tile is normal rail (with or without signals) */ public static bool IsPlainRailTile(this TileIndex t) { return(TileMap.IsTileType(t, TileType.MP_RAILWAY) && IsPlainRail(t)); }
/** * 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))); }
/** * 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)))); }
/** * Return whether a tile is a road depot tile. * @param t Tile to query. * @return True if road depot tile. */ public static bool IsRoadDepotTile(this TileIndex t) { return(TileMap.IsTileType(t, TileType.MP_ROAD) && IsRoadDepot(t)); }
/** * Returns the tree growth status. * * This function returns the tree growth status of a tile with trees. * * @param t The tile to get the tree growth status * @return The tree growth status * @pre Tile must be of type TileType.MP_TREES) */ public static uint GetTreeGrowth(TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TREES)); return(BitMath.GB(Map._m[t].m5, 0, 3)); }
/** * Set the present road types of a tile. * @param t The tile to change. * @param rt The new road types. */ public static void SetRoadTypes(this TileIndex t, RoadTypes rt) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_ROAD) || TileMap.IsTileType(t, TileType.MP_STATION) || TileMap.IsTileType(t, TileType.MP_TUNNELBRIDGE)); Map._me[t].m7 = BitMath.SB(Map._me[t].m7, 6, 2, rt); }
/** * Sets the tree growth status of a tile. * * This function sets the tree growth status of a tile directly with * the given value. * * @param t The tile to change the tree growth status * @param g The new value * @pre Tile must be of type TileType.MP_TREES) */ public static void SetTreeGrowth(TileIndex t, uint g) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TREES)); // XXX incomplete Map._m[t].m5 = BitMath.SB(Map._m[t].m5, 0, 3, g); }
/** * Checks if this is a bridge, instead of a tunnel * @param t The tile to analyze * @pre IsTileType(t, MP_TUNNELBRIDGE) * @return true if the structure is a bridge one */ public static bool IsBridge(TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TUNNELBRIDGE)); return(BitMath.HasBit(Map._m[t].m5, 7)); }
/** * Get the tick counter of a tree tile. * * Returns the saved tick counter of a given tile. * * @param t The tile to get the counter value from * @pre Tile must be of type TileType.MP_TREES) */ public static uint GetTreeCounter(TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TREES)); return(BitMath.GB(Map._m[t].m2, 0, 4)); }
/** * Get the density of a non-field clear tile. * @param t the tile to get the density of * @pre TileMap.IsTileType(t, TileType.MP_CLEAR) * @return the density */ public static uint GetClearDensity(this TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); return(BitMath.GB(Map._m[t].m5, 0, 2)); }
/** * Add a value on the tick counter of a tree-tile * * This function adds a value on the tick counter of a tree-tile. * * @param t The tile to add the value on * @param a The value to add on the tick counter * @pre Tile must be of type TileType.MP_TREES) */ public static void AddTreeCounter(TileIndex t, int a) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TREES)); // XXX incomplete Map._m[t].m2 += a; }
/** * Set the density of a non-field clear tile. * @param t the tile to set the density of * @param d the new density * @pre TileMap.IsTileType(t, TileType.MP_CLEAR) */ public static void SetClearDensity(this TileIndex t, uint d) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); Map._m[t].m5 = BitMath.SB(Map._m[t].m5, 0, 2, (byte)d); }
/** * Set the tick counter for a tree-tile * * This function sets directly the tick counter for a tree-tile. * * @param t The tile to set the tick counter * @param c The new tick counter value * @pre Tile must be of type TileType.MP_TREES) */ public static void SetTreeCounter(TileIndex t, uint c) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_TREES)); // XXX incomplete Map._m[t].m2 = BitMath.SB(Map._m[t].m2, 0, 4, c); }
/** * Increments the counter used to advance to the next clear density/field type. * @param t the tile to increment the counter of * @param c the amount to increment the counter with * @pre TileMap.IsTileType(t, TileType.MP_CLEAR) */ public static void AddClearCounter(this TileIndex t, int c) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); // XXX incomplete Map._m[t].m5 += (byte)(c << 5); }
/** * Return whether a tile is a normal road tile. * @param t Tile to query. * @return True if normal road tile. */ public static bool IsNormalRoadTile(this TileIndex t) { return(TileMap.IsTileType(t, TileType.MP_ROAD) && IsNormalRoad(t)); }
/** * Sets ground type and density in one go, also sets the counter to 0 * @param t the tile to set the ground type and density for * @param type the new ground type of the tile * @param density the density of the ground tile * @pre TileMap.IsTileType(t, TileType.MP_CLEAR) */ public static void SetClearGroundDensity(this TileIndex t, ClearGround type, uint density) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); // XXX incomplete Map._m[t].m5 = (byte)(0 << 5 | (byte)type << 2 | density); }
/** * Return whether a tile is a level crossing tile. * @param t Tile to query. * @return True if level crossing tile. */ public static bool IsLevelCrossingTile(this TileIndex t) { return(TileMap.IsTileType(t, TileType.MP_ROAD) && IsLevelCrossing(t)); }
/** * Get the type of clear tile but never return CLEAR_SNOW. * @param t the tile to get the clear ground type of * @pre TileMap.IsTileType(t, TileType.MP_CLEAR) * @return the ground type */ public static ClearGround GetRawClearGround(this TileIndex t) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); return((ClearGround)BitMath.GB(Map._m[t].m5, 2, 3)); }
/** * Is this tile rail tile and a rail depot? * @param t the tile to get the information from * @return true if and only if the tile is a rail depot */ public static bool IsRailDepotTile(this TileIndex t) { return(TileMap.IsTileType(t, TileType.MP_RAILWAY) && IsRailDepot(t)); }