00001
00002
00005 #ifndef AI_TILE_HPP
00006 #define AI_TILE_HPP
00007
00008 #include "ai_abstractlist.hpp"
00009 #include "ai_error.hpp"
00010 #include "ai_company.hpp"
00011
00015 class AITile : public AIObject {
00016 public:
00017 static const char *GetClassName() { return "AITile"; }
00018
00022 enum ErrorMessages {
00023
00025 ERR_TILE_BASE = AIError::ERR_CAT_TILE << AIError::ERR_CAT_BIT_SIZE,
00026
00028 ERR_TILE_TOO_HIGH,
00029
00031 ERR_TILE_TOO_LOW,
00032
00034 ERR_AREA_ALREADY_FLAT,
00035
00037 ERR_EXCAVATION_WOULD_DAMAGE,
00038 };
00039
00043 enum Corner {
00044 CORNER_W = 0,
00045 CORNER_S = 1,
00046 CORNER_E = 2,
00047 CORNER_N = 3,
00048
00049 CORNER_INVALID = 0xFF,
00050 };
00051
00059 enum Slope {
00060
00061 SLOPE_FLAT = 0x00,
00062 SLOPE_W = 1 << CORNER_W,
00063 SLOPE_S = 1 << CORNER_S,
00064 SLOPE_E = 1 << CORNER_E,
00065 SLOPE_N = 1 << CORNER_N,
00066 SLOPE_STEEP = 0x10,
00067 SLOPE_NW = SLOPE_N | SLOPE_W,
00068 SLOPE_SW = SLOPE_S | SLOPE_W,
00069 SLOPE_SE = SLOPE_S | SLOPE_E,
00070 SLOPE_NE = SLOPE_N | SLOPE_E,
00071 SLOPE_EW = SLOPE_E | SLOPE_W,
00072 SLOPE_NS = SLOPE_N | SLOPE_S,
00073 SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W,
00074 SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S,
00075 SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E,
00076 SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N,
00077 SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W,
00078 SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS,
00079 SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE,
00080 SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN,
00081 SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW,
00082
00083 SLOPE_INVALID = 0xFFFF,
00084 };
00085
00089 enum TransportType {
00090
00091 TRANSPORT_RAIL = 0,
00092 TRANSPORT_ROAD = 1,
00093 TRANSPORT_WATER = 2,
00094 TRANSPORT_AIR = 3,
00095
00096 TRANSPORT_INVALID = -1,
00097 };
00098
00110 static bool IsBuildable(TileIndex tile);
00111
00121 static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
00122
00129 static bool IsWaterTile(TileIndex tile);
00130
00138 static bool IsCoastTile(TileIndex tile);
00139
00146 static bool IsStationTile(TileIndex tile);
00147
00155 static bool IsSteepSlope(Slope slope);
00156
00165 static bool IsHalftileSlope(Slope slope);
00166
00173 static bool HasTreeOnTile(TileIndex tile);
00174
00181 static bool IsFarmTile(TileIndex tile);
00182
00189 static bool IsRockTile(TileIndex tile);
00190
00197 static bool IsRoughTile(TileIndex tile);
00198
00205 static bool IsSnowTile(TileIndex tile);
00206
00213 static bool IsDesertTile(TileIndex tile);
00214
00222 static Slope GetSlope(TileIndex tile);
00223
00233 static Slope GetComplementSlope(Slope slope);
00234
00243 static int32 GetHeight(TileIndex tile);
00244
00252 static int32 GetMinHeight(TileIndex tile);
00253
00261 static int32 GetMaxHeight(TileIndex tile);
00262
00271 static int32 GetCornerHeight(TileIndex tile, Corner corner);
00272
00280 static AICompany::CompanyID GetOwner(TileIndex tile);
00281
00294 static bool HasTransportType(TileIndex tile, TransportType transport_type);
00295
00308 static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
00309
00323 static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
00324
00331 static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
00332
00339 static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
00340
00355 static bool RaiseTile(TileIndex tile, int32 slope);
00356
00371 static bool LowerTile(TileIndex tile, int32 slope);
00372
00389 static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
00390
00398 static bool DemolishTile(TileIndex tile);
00399
00406 static bool PlantTree(TileIndex tile);
00407
00418 static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
00419
00427 static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
00428
00435 static TownID GetClosestTown(TileIndex tile);
00436 };
00437
00438 #endif