00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef AI_TILE_HPP
00013 #define AI_TILE_HPP
00014
00015 #include "ai_abstractlist.hpp"
00016 #include "ai_error.hpp"
00017 #include "ai_company.hpp"
00018
00022 class AITile : public AIObject {
00023 public:
00024 static const char *GetClassName() { return "AITile"; }
00025
00029 enum ErrorMessages {
00030
00032 ERR_TILE_BASE = AIError::ERR_CAT_TILE << AIError::ERR_CAT_BIT_SIZE,
00033
00035 ERR_TILE_TOO_HIGH,
00036
00038 ERR_TILE_TOO_LOW,
00039
00041 ERR_AREA_ALREADY_FLAT,
00042
00044 ERR_EXCAVATION_WOULD_DAMAGE,
00045 };
00046
00050 enum Corner {
00051 CORNER_W = 0,
00052 CORNER_S = 1,
00053 CORNER_E = 2,
00054 CORNER_N = 3,
00055
00056 CORNER_INVALID = 0xFF,
00057 };
00058
00066 enum Slope {
00067
00068 SLOPE_FLAT = 0x00,
00069 SLOPE_W = 1 << CORNER_W,
00070 SLOPE_S = 1 << CORNER_S,
00071 SLOPE_E = 1 << CORNER_E,
00072 SLOPE_N = 1 << CORNER_N,
00073 SLOPE_STEEP = 0x10,
00074 SLOPE_NW = SLOPE_N | SLOPE_W,
00075 SLOPE_SW = SLOPE_S | SLOPE_W,
00076 SLOPE_SE = SLOPE_S | SLOPE_E,
00077 SLOPE_NE = SLOPE_N | SLOPE_E,
00078 SLOPE_EW = SLOPE_E | SLOPE_W,
00079 SLOPE_NS = SLOPE_N | SLOPE_S,
00080 SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W,
00081 SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S,
00082 SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E,
00083 SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N,
00084 SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W,
00085 SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS,
00086 SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE,
00087 SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN,
00088 SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW,
00089
00090 SLOPE_INVALID = 0xFFFF,
00091 };
00092
00096 enum TransportType {
00097
00098 TRANSPORT_RAIL = 0,
00099 TRANSPORT_ROAD = 1,
00100 TRANSPORT_WATER = 2,
00101 TRANSPORT_AIR = 3,
00102
00103 TRANSPORT_INVALID = -1,
00104 };
00105
00109 enum BuildType {
00110 BT_FOUNDATION,
00111 BT_TERRAFORM,
00112 BT_BUILD_TREES,
00113 BT_CLEAR_GRASS,
00114 BT_CLEAR_ROUGH,
00115 BT_CLEAR_ROCKY,
00116 BT_CLEAR_FIELDS,
00117 BT_CLEAR_HOUSE,
00118 };
00119
00131 static bool IsBuildable(TileIndex tile);
00132
00142 static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
00143
00150 static bool IsWaterTile(TileIndex tile);
00151
00160 static bool IsCoastTile(TileIndex tile);
00161
00168 static bool IsStationTile(TileIndex tile);
00169
00177 static bool IsSteepSlope(Slope slope);
00178
00187 static bool IsHalftileSlope(Slope slope);
00188
00195 static bool HasTreeOnTile(TileIndex tile);
00196
00203 static bool IsFarmTile(TileIndex tile);
00204
00211 static bool IsRockTile(TileIndex tile);
00212
00219 static bool IsRoughTile(TileIndex tile);
00220
00227 static bool IsSnowTile(TileIndex tile);
00228
00235 static bool IsDesertTile(TileIndex tile);
00236
00244 static Slope GetSlope(TileIndex tile);
00245
00255 static Slope GetComplementSlope(Slope slope);
00256
00264 static int32 GetMinHeight(TileIndex tile);
00265
00273 static int32 GetMaxHeight(TileIndex tile);
00274
00283 static int32 GetCornerHeight(TileIndex tile, Corner corner);
00284
00292 static AICompany::CompanyID GetOwner(TileIndex tile);
00293
00306 static bool HasTransportType(TileIndex tile, TransportType transport_type);
00307
00323 static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00324
00339 static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00340
00347 static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
00348
00355 static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
00356
00371 static bool RaiseTile(TileIndex tile, int32 slope);
00372
00387 static bool LowerTile(TileIndex tile, int32 slope);
00388
00405 static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
00406
00414 static bool DemolishTile(TileIndex tile);
00415
00422 static bool PlantTree(TileIndex tile);
00423
00434 static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
00435
00443 static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
00444
00451 static TownID GetClosestTown(TileIndex tile);
00452
00458 static Money GetBuildCost(BuildType build_type);
00459 };
00460
00461 #endif