script_tile.hpp

Go to the documentation of this file.
00001 /* $Id: script_tile.hpp 23633 2011-12-19 21:05:36Z truebrain $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
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,                     // [STR_ERROR_ALREADY_AT_SEA_LEVEL]
00036 
00038     ERR_TILE_TOO_LOW,                      // [STR_ERROR_ALREADY_AT_SEA_LEVEL]
00039 
00041     ERR_AREA_ALREADY_FLAT,                 // [STR_ERROR_ALREADY_LEVELLED]
00042 
00044     ERR_EXCAVATION_WOULD_DAMAGE,           // [STR_ERROR_EXCAVATION_WOULD_DAMAGE]
00045   };
00046 
00050   enum Corner {
00051     /* Note: these values represent part of the in-game Corner enum */
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     /* Note: these values represent part of the in-game Slope enum */
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     /* Custom added value, only valid for this API */
00092     SLOPE_INVALID  = 0xFFFF,           
00093   };
00094 
00098   enum TransportType {
00099     /* Note: these values represent part of the in-game TransportType enum */
00100     TRANSPORT_RAIL    =  ::TRANSPORT_RAIL,  
00101     TRANSPORT_ROAD    =  ::TRANSPORT_ROAD,  
00102     TRANSPORT_WATER   =  ::TRANSPORT_WATER, 
00103     TRANSPORT_AIR     =  ::TRANSPORT_AIR,   
00104 
00105     /* Custom added value, only valid for this API */
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 /* SCRIPT_TILE_HPP */