00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef SCRIPT_TILE_HPP
00013 #define SCRIPT_TILE_HPP
00014
00015 #include "script_error.hpp"
00016 #include "script_company.hpp"
00017 #include "../../slope_type.h"
00018 #include "../../transport_type.h"
00019
00024 class ScriptTile : public ScriptObject {
00025 public:
00029 enum ErrorMessages {
00030
00032 ERR_TILE_BASE = ScriptError::ERR_CAT_TILE << ScriptError::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
00052 CORNER_W = ::CORNER_W,
00053 CORNER_S = ::CORNER_S,
00054 CORNER_E = ::CORNER_E,
00055 CORNER_N = ::CORNER_N,
00056
00057 CORNER_INVALID = ::CORNER_INVALID,
00058 };
00059
00067 enum Slope {
00068
00069 SLOPE_FLAT = ::SLOPE_FLAT,
00070 SLOPE_W = ::SLOPE_W,
00071 SLOPE_S = ::SLOPE_S,
00072 SLOPE_E = ::SLOPE_E,
00073 SLOPE_N = ::SLOPE_N,
00074 SLOPE_STEEP = ::SLOPE_STEEP,
00075 SLOPE_NW = ::SLOPE_NW,
00076 SLOPE_SW = ::SLOPE_SW,
00077 SLOPE_SE = ::SLOPE_SE,
00078 SLOPE_NE = ::SLOPE_NE,
00079 SLOPE_EW = ::SLOPE_EW,
00080 SLOPE_NS = ::SLOPE_NS,
00081 SLOPE_ELEVATED = ::SLOPE_ELEVATED,
00082 SLOPE_NWS = ::SLOPE_NWS,
00083 SLOPE_WSE = ::SLOPE_WSE,
00084 SLOPE_SEN = ::SLOPE_SEN,
00085 SLOPE_ENW = ::SLOPE_ENW,
00086 SLOPE_STEEP_W = ::SLOPE_STEEP_W,
00087 SLOPE_STEEP_S = ::SLOPE_STEEP_S,
00088 SLOPE_STEEP_E = ::SLOPE_STEEP_E,
00089 SLOPE_STEEP_N = ::SLOPE_STEEP_N,
00090
00091
00092 SLOPE_INVALID = 0xFFFF,
00093 };
00094
00098 enum TransportType {
00099
00100 TRANSPORT_RAIL = ::TRANSPORT_RAIL,
00101 TRANSPORT_ROAD = ::TRANSPORT_ROAD,
00102 TRANSPORT_WATER = ::TRANSPORT_WATER,
00103 TRANSPORT_AIR = ::TRANSPORT_AIR,
00104
00105
00106 TRANSPORT_INVALID = -1,
00107 };
00108
00112 enum BuildType {
00113 BT_FOUNDATION,
00114 BT_TERRAFORM,
00115 BT_BUILD_TREES,
00116 BT_CLEAR_GRASS,
00117 BT_CLEAR_ROUGH,
00118 BT_CLEAR_ROCKY,
00119 BT_CLEAR_FIELDS,
00120 BT_CLEAR_HOUSE,
00121 };
00122
00134 static bool IsBuildable(TileIndex tile);
00135
00145 static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
00146
00153 static bool IsWaterTile(TileIndex tile);
00154
00163 static bool IsCoastTile(TileIndex tile);
00164
00171 static bool IsStationTile(TileIndex tile);
00172
00180 static bool IsSteepSlope(Slope slope);
00181
00190 static bool IsHalftileSlope(Slope slope);
00191
00198 static bool HasTreeOnTile(TileIndex tile);
00199
00206 static bool IsFarmTile(TileIndex tile);
00207
00214 static bool IsRockTile(TileIndex tile);
00215
00222 static bool IsRoughTile(TileIndex tile);
00223
00230 static bool IsSnowTile(TileIndex tile);
00231
00238 static bool IsDesertTile(TileIndex tile);
00239
00247 static Slope GetSlope(TileIndex tile);
00248
00258 static Slope GetComplementSlope(Slope slope);
00259
00267 static int32 GetMinHeight(TileIndex tile);
00268
00276 static int32 GetMaxHeight(TileIndex tile);
00277
00286 static int32 GetCornerHeight(TileIndex tile, Corner corner);
00287
00295 static ScriptCompany::CompanyID GetOwner(TileIndex tile);
00296
00313 static bool HasTransportType(TileIndex tile, TransportType transport_type);
00314
00331 static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00332
00348 static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00349
00356 static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
00357
00364 static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
00365
00381 static bool RaiseTile(TileIndex tile, int32 slope);
00382
00398 static bool LowerTile(TileIndex tile, int32 slope);
00399
00417 static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
00418
00427 static bool DemolishTile(TileIndex tile);
00428
00436 static bool PlantTree(TileIndex tile);
00437
00449 static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
00450
00459 static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
00460
00468 static TownID GetTownAuthority(TileIndex tile);
00469
00476 static TownID GetClosestTown(TileIndex tile);
00477
00483 static Money GetBuildCost(BuildType build_type);
00484 };
00485
00486 #endif