1 /* $Id: script_industry.hpp 23614 2011-12-19 20:57:23Z truebrain $ */
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file script_industry.hpp Everything to query and build industries. */
12 #ifndef SCRIPT_INDUSTRY_HPP
13 #define SCRIPT_INDUSTRY_HPP
15 #include "script_object.hpp"
18 * Class that handles all industry related functions.
21 class ScriptIndustry
: public ScriptObject
{
23 /** Ways for an industry to accept a cargo. */
24 enum CargoAcceptState
{
25 CAS_NOT_ACCEPTED
, ///< The CargoID is not accepted by this industry.
26 CAS_ACCEPTED
, ///< The industry currently accepts this CargoID.
27 CAS_TEMP_REFUSED
, ///< The industry temporarily refuses to accept this CargoID but may do so again in the future.
31 * Gets the number of industries.
32 * @return The number of industries.
33 * @note The maximum valid IndustryID can be higher than the value returned.
35 static int32
GetIndustryCount();
38 * Checks whether the given industry index is valid.
39 * @param industry_id The index to check.
40 * @return True if and only if the industry is valid.
42 static bool IsValidIndustry(IndustryID industry_id
);
45 * Get the IndustryID of a tile, if there is an industry.
46 * @param tile The tile to find the IndustryID of.
47 * @return IndustryID of the industry.
48 * @post Use IsValidIndustry() to see if the industry is valid.
49 * @note GetIndustryID will return an invalid IndustryID for the
50 * station tile of industries with a dock/heliport.
52 static IndustryID
GetIndustryID(TileIndex tile
);
55 * Get the name of the industry.
56 * @param industry_id The industry to get the name of.
57 * @pre IsValidIndustry(industry_id).
58 * @return The name of the industry.
60 static char *GetName(IndustryID industry_id
);
63 * See whether an industry currently accepts a certain cargo.
64 * @param industry_id The index of the industry.
65 * @param cargo_id The index of the cargo.
66 * @pre IsValidIndustry(industry_id).
67 * @pre ScriptCargo::IsValidCargo(cargo_id).
68 * @return Whether the industry accepts, temporarily refuses or never accepts this cargo.
70 static CargoAcceptState
IsCargoAccepted(IndustryID industry_id
, CargoID cargo_id
);
73 * Get the amount of cargo stockpiled for processing.
74 * @param industry_id The index of the industry.
75 * @param cargo_id The index of the cargo.
76 * @pre IsValidIndustry(industry_id).
77 * @pre ScriptCargo::IsValidCargo(cargo_id).
78 * @return The amount of cargo that is waiting for processing.
80 static int32
GetStockpiledCargo(IndustryID industry_id
, CargoID cargo_id
);
83 * Get the total last month's production of the given cargo at an industry.
84 * @param industry_id The index of the industry.
85 * @param cargo_id The index of the cargo.
86 * @pre IsValidIndustry(industry_id).
87 * @pre ScriptCargo::IsValidCargo(cargo_id).
88 * @return The last month's production of the given cargo for this industry.
90 static int32
GetLastMonthProduction(IndustryID industry_id
, CargoID cargo_id
);
93 * Get the total amount of cargo transported from an industry last month.
94 * @param industry_id The index of the industry.
95 * @param cargo_id The index of the cargo.
96 * @pre IsValidIndustry(industry_id).
97 * @pre ScriptCargo::IsValidCargo(cargo_id).
98 * @return The amount of given cargo transported from this industry last month.
100 static int32
GetLastMonthTransported(IndustryID industry_id
, CargoID cargo_id
);
103 * Get the percentage of cargo transported from an industry last month.
104 * @param industry_id The index of the industry.
105 * @param cargo_id The index of the cargo.
106 * @pre IsValidIndustry(industry_id).
107 * @pre ScriptCargo::IsValidCargo(cargo_id).
108 * @return The percentage of given cargo transported from this industry last month.
110 static int32
GetLastMonthTransportedPercentage(IndustryID industry_id
, CargoID cargo_id
);
113 * Gets the location of the industry.
114 * @param industry_id The index of the industry.
115 * @pre IsValidIndustry(industry_id).
116 * @return The location of the industry.
118 static TileIndex
GetLocation(IndustryID industry_id
);
121 * Get the number of stations around an industry. All stations that can
122 * service the industry are counted, your own stations but also your
123 * opponents stations.
124 * @param industry_id The index of the industry.
125 * @pre IsValidIndustry(industry_id).
126 * @return The number of stations around an industry.
128 static int32
GetAmountOfStationsAround(IndustryID industry_id
);
131 * Get the manhattan distance from the tile to the ScriptIndustry::GetLocation()
133 * @param industry_id The industry to get the distance to.
134 * @param tile The tile to get the distance to.
135 * @pre IsValidIndustry(industry_id).
136 * @pre ScriptMap::IsValidTile(tile).
137 * @return The distance between industry and tile.
139 static int32
GetDistanceManhattanToTile(IndustryID industry_id
, TileIndex tile
);
142 * Get the square distance from the tile to the ScriptIndustry::GetLocation()
144 * @param industry_id The industry to get the distance to.
145 * @param tile The tile to get the distance to.
146 * @pre IsValidIndustry(industry_id).
147 * @pre ScriptMap::IsValidTile(tile).
148 * @return The distance between industry and tile.
150 static int32
GetDistanceSquareToTile(IndustryID industry_id
, TileIndex tile
);
153 * Is this industry built on water.
154 * @param industry_id The index of the industry.
155 * @pre IsValidIndustry(industry_id).
156 * @return True when the industry is built on water.
158 static bool IsBuiltOnWater(IndustryID industry_id
);
161 * Does this industry have a heliport?
162 * @param industry_id The index of the industry.
163 * @pre IsValidIndustry(industry_id).
164 * @return True when the industry has a heliport.
166 static bool HasHeliport(IndustryID industry_id
);
169 * Gets the location of the industry's heliport.
170 * @param industry_id The index of the industry.
171 * @pre IsValidIndustry(industry_id).
172 * @pre HasHeliport(industry_id).
173 * @return The location of the industry's heliport.
175 static TileIndex
GetHeliportLocation(IndustryID industry_id
);
178 * Does this industry have a dock?
179 * @param industry_id The index of the industry.
180 * @pre IsValidIndustry(industry_id).
181 * @return True when the industry has a dock.
183 static bool HasDock(IndustryID industry_id
);
186 * Gets the location of the industry's dock.
187 * @param industry_id The index of the industry.
188 * @pre IsValidIndustry(industry_id).
189 * @pre HasDock(industry_id).
190 * @return The location of the industry's dock.
192 static TileIndex
GetDockLocation(IndustryID industry_id
);
195 * Get the IndustryType of the industry.
196 * @param industry_id The index of the industry.
197 * @pre IsValidIndustry(industry_id).
198 * @return The IndustryType of the industry.
200 static IndustryType
GetIndustryType(IndustryID industry_id
);
203 #endif /* SCRIPT_INDUSTRY_HPP */