public static void MakeRailDepot(this TileIndex t, Owner o, DepotID did, DiagDirection d, RailType r) { TileMap.SetTileType(t, TileType.MP_RAILWAY); TileMap.SetTileOwner(t, o); Map._m[t].m2 = did; Map._m[t].m3 = (byte)r; Map._m[t].m4 = 0; Map._m[t].m5 = (byte)((int)RailTileType.RAIL_TILE_DEPOT << 6 | (int)d); BitMath.SB(Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; }
/** * Makes a rail tunnel entrance * @param t the entrance of the tunnel * @param o the owner of the entrance * @param d the direction facing out of the tunnel * @param r the rail type used in the tunnel */ public static void MakeRailTunnel(this TileIndex t, Owner o, DiagDirection d, RailType r) { TileMap.SetTileType(t, TileType.MP_TUNNELBRIDGE); TileMap.SetTileOwner(t, o); Map._m[t].m2 = 0; Map._m[t].m3 = (byte)r; Map._m[t].m4 = 0; Map._m[t].m5 = (byte)((int)TransportType.TRANSPORT_RAIL << 2 | d); Map._me[t].m6 = BitMath.SB(Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; }
public static void MakeRailNormal(this TileIndex t, Owner o, TrackBits b, RailType r) { TileMap.SetTileType(t, TileType.MP_RAILWAY); TileMap.SetTileOwner(t, o); Map._m[t].m2 = 0; Map._m[t].m3 = (byte)r; Map._m[t].m4 = 0; Map._m[t].m5 = (byte)((int)RailTileType.RAIL_TILE_NORMAL << 6 | b); BitMath.SB(Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; }
/** * Helper function for making a watery tile. * @param t The tile to change into water * @param o The owner of the water * @param wc The class of water the tile has to be * @param random_bits Eventual random bits to be set for this tile */ /*inline*/ public static void MakeWater(TileIndex t, Owner o, WaterClass wc, byte random_bits) { TileMap.SetTileType(t, TileType.MP_WATER); TileMap.SetTileOwner(t, o); SetWaterClass(t, wc); Map._m[t].m2 = 0; Map._m[t].m3 = 0; Map._m[t].m4 = random_bits; Map._m[t].m5 = (int)WaterTileTypeBitLayout.WBL_TYPE_NORMAL << (int)WaterTileTypeBitLayout.WBL_TYPE_BEGIN; BitMath.SB(ref Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; }
/** * Helper function to make a coast tile. * @param t The tile to change into water */ /*inline*/ public static void MakeShore(TileIndex t) { TileMap.SetTileType(t, TileType.MP_WATER); TileMap.SetTileOwner(t, Owner.OWNER_WATER); SetWaterClass(t, WaterClass.WATER_CLASS_SEA); Map._m[t].m2 = 0; Map._m[t].m3 = 0; Map._m[t].m4 = 0; Map._m[t].m5 = ((int)WaterTileTypeBitLayout.WBL_TYPE_NORMAL << (int)WaterTileTypeBitLayout.WBL_TYPE_BEGIN | 1 << (int)WaterTileTypeBitLayout.WBL_COAST_FLAG); BitMath.SB(ref Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; }
/** * Make a tree-tile. * * This functions change the tile to a tile with trees and all informations which belongs to it. * * @param t The tile to make a tree-tile from * @param type The type of the tree * @param count the number of trees * @param growth the growth status * @param ground the ground type * @param density the density (not the number of trees) */ public static void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density) { TileMap.SetTileType(t, TileType.MP_TREES); TileMap.SetTileOwner(t, Owner.OWNER_NONE); Map._m[t].m2 = (ushort)(ground << 6 | density << 4 | 0); Map._m[t].m3 = (byte)type; Map._m[t].m4 = 0 << 5 | 0 << 2; Map._m[t].m5 = (byte)(count << 6 | growth); BitMath.SB(Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; }
/** * Make a nice void tile ;) * @param t the tile to make void */ public static void MakeVoid(this TileIndex t) { TileMap.SetTileType(t, TileType.MP_VOID); TileMap.SetTileHeight(t, 0); Map._m[t].m1 = 0; Map._m[t].m2 = 0; Map._m[t].m3 = 0; Map._m[t].m4 = 0; Map._m[t].m5 = 0; Map._me[t].m6 = 0; Map._me[t].m7 = 0; }
/** * Make a clear tile. * @param t the tile to make a clear tile * @param g the type of ground * @param density the density of the grass/snow/desert etc */ public static void MakeClear(this TileIndex t, ClearGround g, uint density) { TileMap.SetTileType(t, TileType.MP_CLEAR); Map._m[t].m1 = 0; TileMap.SetTileOwner(t, Owner.OWNER_NONE); Map._m[t].m2 = 0; Map._m[t].m3 = 0; Map._m[t].m4 = 0 << 5 | 0 << 2; SetClearGroundDensity(t, g, density); // Sets m5 Map._me[t].m6 = 0; Map._me[t].m7 = 0; }
/** * Make a (farm) field tile. * @param t the tile to make a farm field * @param field_type the 'growth' level of the field * @param industry the industry this tile belongs to */ public static void MakeField(this TileIndex t, uint field_type, IndustryID industry) { TileMap.SetTileType(t, TileType.MP_CLEAR); Map._m[t].m1 = 0; TileMap.SetTileOwner(t, Owner.OWNER_NONE); Map._m[t].m2 = industry; Map._m[t].m3 = (byte)field_type; Map._m[t].m4 = 0 << 5 | 0 << 2; SetClearGroundDensity(t, ClearGround.CLEAR_FIELDS, 3); Map._me[t].m6 = BitMath.SB(Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; }
/** * Make a road depot. * @param t Tile to make a level crossing. * @param owner New owner of the depot. * @param did New depot ID. * @param dir Direction of the depot exit. * @param rt Road type of the depot. */ public static void MakeRoadDepot(this TileIndex t, Owner owner, DepotID did, DiagDirection dir, RoadType rt) { TileMap.SetTileType(t, TileType.MP_ROAD); TileMap.SetTileOwner(t, owner); Map._m[t].m2 = did; Map._m[t].m3 = 0; Map._m[t].m4 = 0; Map._m[t].m5 = RoadTileType.ROAD_TILE_DEPOT << 6 | dir; Map._me[t].m6 = BitMath.SB(Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = RoadTypeToRoadTypes(rt) << 6 | owner; SetRoadOwner(t, RoadType.ROADTYPE_TRAM, owner); }
/** * Generic part to make a bridge ramp for both roads and rails. * @param t the tile to make a bridge ramp * @param o the new owner of the bridge ramp * @param bridgetype the type of bridge this bridge ramp belongs to * @param d the direction this ramp must be facing * @param tt the transport type of the bridge * @param rt the road or rail type * @note this function should not be called directly. */ public static void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt, RailType rt) { TileMap.SetTileType(t, TileType.MP_TUNNELBRIDGE); TileMap.SetTileOwner(t, o); Map._m[t].m2 = 0; Map._m[t].m3 = (byte)rt; Map._m[t].m4 = 0; Map._m[t].m5 = (byte)(1 << 7 | (byte)tt << 2 | (byte)d); BitMath.SB(ref Map._me[t].m6, 2, 4, bridgetype); Map._me[t].m7 = 0; }
/** * Make a level crossing. * @param t Tile to make a level crossing. * @param road New owner of road. * @param tram New owner of tram tracks. * @param rail New owner of the rail track. * @param roaddir Axis of the road. * @param rat New rail type. * @param rot New present road types. * @param town Town ID if the road is a town-owned road. */ public static void MakeRoadCrossing(this TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadTypes rot, uint town) { TileMap.SetTileType(t, TileType.MP_ROAD); TileMap.SetTileOwner(t, rail); Map._m[t].m2 = town; Map._m[t].m3 = rat; Map._m[t].m4 = 0; Map._m[t].m5 = RoadTileType.ROAD_TILE_CROSSING << 6 | roaddir; Map._me[t].m6 = BitMath.SB(Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = rot << 6 | road; SetRoadOwner(t, RoadType.ROADTYPE_TRAM, tram); }
/** * Make the given tile a station tile. * @param t the tile to make a station tile * @param o the owner of the station * @param sid the station to which this tile belongs * @param st the type this station tile * @param section the StationGfx to be used for this tile * @param wc The water class of the station */ public static void MakeStation(this TileIndex t, Owner o, StationID sid, StationType st, byte section, WaterClass wc = WaterClass.WATER_CLASS_INVALID) { TileMap.SetTileType(t, TileType.MP_STATION); TileMap.SetTileOwner(t, o); WaterMap.SetWaterClass(t, wc); Map._m[t].m2 = sid; Map._m[t].m3 = 0; Map._m[t].m4 = 0; Map._m[t].m5 = section; Map._me[t].m6 = BitMath.SB(Map._me[t].m6, 2, 1, 0); Map._me[t].m6 = BitMath.SB(Map._me[t].m6, 3, 3, st); Map._me[t].m7 = 0; }
/** * Make a normal road tile. * @param t Tile to make a normal road. * @param bits Road bits to set for all present road types. * @param rot New present road types. * @param town Town ID if the road is a town-owned road. * @param road New owner of road. * @param tram New owner of tram tracks. */ public static void MakeRoadNormal(this TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram) { TileMap.SetTileType(t, TileType.MP_ROAD); TileMap.SetTileOwner(t, road); Map._m[t].m2 = town; Map._m[t].m3 = (BitMath.HasBit(rot, RoadType.ROADTYPE_TRAM) ? bits : 0); Map._m[t].m4 = 0; Map._m[t].m5 = (BitMath.HasBit(rot, RoadType.ROADTYPE_ROAD) ? bits : 0) | RoadTileType.ROAD_TILE_NORMAL << 6; BitMath.SB(Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = rot << 6; SetRoadOwner(t, RoadType.ROADTYPE_TRAM, tram); }
/** * Make the tile a house. * @param t tile index * @param tid Town index * @param counter of construction step * @param stage of construction (used for drawing) * @param type of house. Index into house specs array * @param random_bits required for newgrf houses * @pre TileMap.IsTileType(t, MP_CLEAR) */ public static void MakeHouseTile(this TileIndex t, ushort tid, byte counter, byte stage, HouseID type, byte random_bits) { Debug.Assert(TileMap.IsTileType(t, TileType.MP_CLEAR)); TileMap.SetTileType(t, TileType.MP_HOUSE); Map._m[t].m1 = random_bits; Map._m[t].m2 = tid; Map._m[t].m3 = 0; SetHouseType(t, type); SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED); Map._m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter); SetAnimationFrame(t, 0); SetHouseProcessingTime(t, HouseSpec.Get(type).processing_time); }
/** * Makes a road tunnel entrance * @param t the entrance of the tunnel * @param o the owner of the entrance * @param d the direction facing out of the tunnel * @param r the road type used in the tunnel */ public static void MakeRoadTunnel(this TileIndex t, Owner o, DiagDirection d, RoadTypes r) { TileMap.SetTileType(t, TileType.MP_TUNNELBRIDGE); TileMap.SetTileOwner(t, o); Map._m[t].m2 = 0; Map._m[t].m3 = 0; Map._m[t].m4 = 0; Map._m[t].m5 = (byte)((int)TransportType.TRANSPORT_ROAD << 2 | (int)d); Map._me[t].m6 = BitMath.SB(Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; t.SetRoadOwner(RoadType.ROADTYPE_ROAD, o); if (o != Owner.OWNER_TOWN) { t.SetRoadOwner(RoadType.ROADTYPE_TRAM, o); } t.SetRoadTypes(r); }
/** * Make a ship depot section. * @param t Tile to place the ship depot section. * @param o Owner of the depot. * @param did Depot ID. * @param part Depot part (either #DEPOT_PART_NORTH or #DEPOT_PART_SOUTH). * @param a Axis of the depot. * @param original_water_class Original water class. */ /*inline*/ public static void MakeShipDepot(TileIndex t, Owner o, DepotID did, DepotPart part, Axis a, WaterClass original_water_class) { TileMap.SetTileType(t, TileType.MP_WATER); TileMap.SetTileOwner(t, o); SetWaterClass(t, original_water_class); Map._m[t].m2 = did; Map._m[t].m3 = 0; Map._m[t].m4 = 0; Map._m[t].m5 = (byte) ((int)WaterTileTypeBitLayout.WBL_TYPE_DEPOT << (int)WaterTileTypeBitLayout.WBL_TYPE_BEGIN | (int)part << (int)WaterTileTypeBitLayout.WBL_DEPOT_PART | (int)a << (int)WaterTileTypeBitLayout.WBL_DEPOT_AXIS); BitMath.SB(ref Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; }
/** * Make a lock section. * @param t Tile to place the water lock section. * @param o Owner of the lock. * @param part Part to place. * @param dir Lock orientation * @param original_water_class Original water class. * @see MakeLock */ /*inline*/ public static void MakeLockTile(TileIndex t, Owner o, LockPart part, DiagDirection dir, WaterClass original_water_class) { TileMap.SetTileType(t, TileType.MP_WATER); TileMap.SetTileOwner(t, o); SetWaterClass(t, original_water_class); Map._m[t].m2 = 0; Map._m[t].m3 = 0; Map._m[t].m4 = 0; Map._m[t].m5 = (byte) ((int)WaterTileTypeBitLayout.WBL_TYPE_LOCK << (int)WaterTileTypeBitLayout.WBL_TYPE_BEGIN | (int)part << (int)WaterTileTypeBitLayout.WBL_LOCK_PART_BEGIN | (int)dir << (int)WaterTileTypeBitLayout.WBL_LOCK_ORIENT_BEGIN); BitMath.SB(ref Map._me[t].m6, 2, 4, 0); Map._me[t].m7 = 0; }