Пример #1
0
/**
 * Make the given tile a buoy tile.
 * @param t the tile to make a buoy
 * @param sid the station to which this tile belongs
 * @param wc the type of water on this tile
 */
        public static void MakeBuoy(this TileIndex t, StationID sid, WaterClass wc)
        {
            /* Make the owner of the buoy tile the same as the current owner of the
             * water tile. In this way, we can reset the owner of the water to its
             * original state when the buoy gets removed. */
            MakeStation(t, TileMap.GetTileOwner(t), sid, StationType.STATION_BUOY, 0, wc);
        }
Пример #2
0
 /**
  * Set the water class at a tile.
  * @param t  Water tile to change.
  * @param wc New water class.
  * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
  */
 //inline
 public static void SetWaterClass(TileIndex t, WaterClass wc)
 {
     if (HasTileWaterClass(t) == false)
     {
         throw new ArgumentException(nameof(t));
     }
     BitMath.SB(ref Map._m[t].m1, 5, 2, (uint)wc);
 }
Пример #3
0
/**
 * Make a water lock.
 * @param t Tile to place the water lock section.
 * @param o Owner of the lock.
 * @param d Direction of the water lock.
 * @param wc_lower Original water class of the lower part.
 * @param wc_upper Original water class of the upper part.
 * @param wc_middle Original water class of the middle part.
 */
/*inline*/

        public static void MakeLock(TileIndex t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper,
                                    WaterClass wc_middle)
        {
            TileIndexDiff delta = Map.TileOffsByDiagDir(d);

            /* Keep the current waterclass and owner for the tiles.
             * It allows to restore them after the lock is deleted */
            MakeLockTile(t, o, LockPart.LOCK_PART_MIDDLE, d, wc_middle);
            MakeLockTile((uint)(t - delta), IsWaterTile((uint)(t - delta)) ? TileMap.GetTileOwner((uint)(t - delta)) : o, LockPart.LOCK_PART_LOWER, d, wc_lower);
            MakeLockTile((uint)(t + delta), IsWaterTile((uint)(t + delta)) ? TileMap.GetTileOwner((uint)(t + delta)) : o, LockPart.LOCK_PART_UPPER, d, wc_upper);
        }
Пример #4
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;
        }
Пример #5
0
/**
 * 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;
        }
Пример #6
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;
        }
Пример #7
0
/**
 * 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;
        }
Пример #8
0
/**
 * Make the given tile an oilrig tile.
 * @param t the tile to make an oilrig
 * @param sid the station to which this tile belongs
 * @param wc the type of water on this tile
 */
        public static void MakeOilrig(this TileIndex t, StationID sid, WaterClass wc)
        {
            MakeStation(t, Owner.OWNER_NONE, sid, StationType.STATION_OILRIG, 0, wc);
        }
Пример #9
0
/**
 * Make the given tile a dock tile.
 * @param t the tile to make a dock
 * @param o the owner of the dock
 * @param sid the station to which this tile belongs
 * @param d the direction of the dock
 * @param wc the type of water on this tile
 */
        public static void MakeDock(this TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
        {
            MakeStation(t, o, sid, StationType.STATION_DOCK, d);
            MakeStation(t + Map.TileOffsByDiagDir(d), o, sid, StationType.STATION_DOCK,
                        GFX_DOCK_BASE_WATER_PART + d.DiagDirToAxis(), wc);
        }
Пример #10
0
/**
 * Make the given tile an airport tile.
 * @param t the tile to make a airport
 * @param o the owner of the airport
 * @param sid the station to which this tile belongs
 * @param section the StationGfx to be used for this tile
 * @param wc the type of water on this tile
 */
        public static void MakeAirport(this TileIndex t, Owner o, StationID sid, byte section, WaterClass wc)
        {
            MakeStation(t, o, sid, StationType.STATION_AIRPORT, section, wc);
        }