00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef AI_TILE_HPP
00013 #define AI_TILE_HPP
00014
00015 #include "ai_list.hpp"
00016 #include "ai_error.hpp"
00017 #include "ai_company.hpp"
00018
00022 class AITile : public AIObject {
00023 public:
00025 static const char *GetClassName() { return "AITile"; }
00026
00030 enum ErrorMessages {
00031
00033 ERR_TILE_BASE = AIError::ERR_CAT_TILE << AIError::ERR_CAT_BIT_SIZE,
00034
00036 ERR_TILE_TOO_HIGH,
00037
00039 ERR_TILE_TOO_LOW,
00040
00042 ERR_AREA_ALREADY_FLAT,
00043
00045 ERR_EXCAVATION_WOULD_DAMAGE,
00046 };
00047
00051 enum Corner {
00052 CORNER_W = 0,
00053 CORNER_S = 1,
00054 CORNER_E = 2,
00055 CORNER_N = 3,
00056
00057 CORNER_INVALID = 0xFF,
00058 };
00059
00067 enum Slope {
00068
00069 SLOPE_FLAT = 0x00,
00070 SLOPE_W = 1 << CORNER_W,
00071 SLOPE_S = 1 << CORNER_S,
00072 SLOPE_E = 1 << CORNER_E,
00073 SLOPE_N = 1 << CORNER_N,
00074 SLOPE_STEEP = 0x10,
00075 SLOPE_NW = SLOPE_N | SLOPE_W,
00076 SLOPE_SW = SLOPE_S | SLOPE_W,
00077 SLOPE_SE = SLOPE_S | SLOPE_E,
00078 SLOPE_NE = SLOPE_N | SLOPE_E,
00079 SLOPE_EW = SLOPE_E | SLOPE_W,
00080 SLOPE_NS = SLOPE_N | SLOPE_S,
00081 SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W,
00082 SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S,
00083 SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E,
00084 SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N,
00085 SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W,
00086 SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS,
00087 SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE,
00088 SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN,
00089 SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW,
00090
00091 SLOPE_INVALID = 0xFFFF,
00092 };
00093
00097 enum TransportType {
00098
00099 TRANSPORT_RAIL = 0,
00100 TRANSPORT_ROAD = 1,
00101 TRANSPORT_WATER = 2,
00102 TRANSPORT_AIR = 3,
00103
00104 TRANSPORT_INVALID = -1,
00105 };
00106
00110 enum BuildType {
00111 BT_FOUNDATION,
00112 BT_TERRAFORM,
00113 BT_BUILD_TREES,
00114 BT_CLEAR_GRASS,
00115 BT_CLEAR_ROUGH,
00116 BT_CLEAR_ROCKY,
00117 BT_CLEAR_FIELDS,
00118 BT_CLEAR_HOUSE,
00119 };
00120
00132 static bool IsBuildable(TileIndex tile);
00133
00143 static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
00144
00151 static bool IsWaterTile(TileIndex tile);
00152
00161 static bool IsCoastTile(TileIndex tile);
00162
00169 static bool IsStationTile(TileIndex tile);
00170
00178 static bool IsSteepSlope(Slope slope);
00179
00188 static bool IsHalftileSlope(Slope slope);
00189
00196 static bool HasTreeOnTile(TileIndex tile);
00197
00204 static bool IsFarmTile(TileIndex tile);
00205
00212 static bool IsRockTile(TileIndex tile);
00213
00220 static bool IsRoughTile(TileIndex tile);
00221
00228 static bool IsSnowTile(TileIndex tile);
00229
00236 static bool IsDesertTile(TileIndex tile);
00237
00245 static Slope GetSlope(TileIndex tile);
00246
00256 static Slope GetComplementSlope(Slope slope);
00257
00265 static int32 GetMinHeight(TileIndex tile);
00266
00274 static int32 GetMaxHeight(TileIndex tile);
00275
00284 static int32 GetCornerHeight(TileIndex tile, Corner corner);
00285
00293 static AICompany::CompanyID GetOwner(TileIndex tile);
00294
00311 static bool HasTransportType(TileIndex tile, TransportType transport_type);
00312
00328 static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00329
00344 static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00345
00352 static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
00353
00360 static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
00361
00376 static bool RaiseTile(TileIndex tile, int32 slope);
00377
00392 static bool LowerTile(TileIndex tile, int32 slope);
00393
00410 static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
00411
00419 static bool DemolishTile(TileIndex tile);
00420
00427 static bool PlantTree(TileIndex tile);
00428
00439 static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
00440
00448 static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
00449
00456 static TownID GetClosestTown(TileIndex tile);
00457
00463 static Money GetBuildCost(BuildType build_type);
00464 };
00465
00466 #endif