Update: Translations from eints
[openttd-github.git] / src / script / api / script_industrytype.hpp
blobdfa4586f029d6f627540ebf14489d9ea314c653c
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file script_industrytype.hpp Everything to query and build industries. */
10 #ifndef SCRIPT_INDUSTRYTYPE_HPP
11 #define SCRIPT_INDUSTRYTYPE_HPP
13 #include "script_list.hpp"
15 /**
16 * Class that handles all industry-type related functions.
17 * @api ai game
19 class ScriptIndustryType : public ScriptObject {
20 public:
21 /**
22 * Special IndustryTypes.
24 enum SpecialIndustryType {
25 INDUSTRYTYPE_UNKNOWN = 0xFE, ///< Unknown/unspecific industrytype. (Usable for ScriptRail::BuildNewGRFRailStation())
26 INDUSTRYTYPE_TOWN = 0xFF, ///< No industry, but town. (Usable for ScriptRail::BuildNewGRFRailStation())
29 /**
30 * Checks whether the given industry-type is valid.
31 * @param industry_type The type check.
32 * @return True if and only if the industry-type is valid.
34 static bool IsValidIndustryType(IndustryType industry_type);
36 /**
37 * Get the name of an industry-type.
38 * @param industry_type The type to get the name for.
39 * @pre IsValidIndustryType(industry_type).
40 * @return The name of an industry.
42 static std::optional<std::string> GetName(IndustryType industry_type);
44 /**
45 * Get a list of CargoID possible produced by this industry-type.
46 * @warning This function only returns the default cargoes of the industry type.
47 * Industries can specify new cargotypes on construction.
48 * @param industry_type The type to get the CargoIDs for.
49 * @pre IsValidIndustryType(industry_type).
50 * @return The CargoIDs of all cargotypes this industry could produce.
52 static ScriptList *GetProducedCargo(IndustryType industry_type);
54 /**
55 * Get a list of CargoID accepted by this industry-type.
56 * @warning This function only returns the default cargoes of the industry type.
57 * Industries can specify new cargotypes on construction.
58 * @param industry_type The type to get the CargoIDs for.
59 * @pre IsValidIndustryType(industry_type).
60 * @return The CargoIDs of all cargotypes this industry accepts.
62 static ScriptList *GetAcceptedCargo(IndustryType industry_type);
64 /**
65 * Is this industry type a raw industry?
66 * Raw industries usually produce cargo without any prerequisites.
67 * ("Usually" means that advanced NewGRF industry concepts might not fit the "raw"/"processing"
68 * classification, so it's up to the interpretation of the NewGRF author.)
69 * @param industry_type The type of the industry.
70 * @pre IsValidIndustryType(industry_type).
71 * @return True if it should be handled as a raw industry.
72 * @note Industries might be neither raw nor processing.
73 * This is usually the case for industries which produce nothing (e.g. power plants),
74 * but also for weird industries like temperate banks and tropic lumber mills.
76 static bool IsRawIndustry(IndustryType industry_type);
78 /**
79 * Is this industry type a processing industry?
80 * Processing industries usually produce cargo when delivered with input cargo.
81 * ("Usually" means that advanced NewGRF industry concepts might not fit the "raw"/"processing"
82 * classification, so it's up to the interpretation of the NewGRF author.)
83 * @param industry_type The type of the industry.
84 * @pre IsValidIndustryType(industry_type).
85 * @return True if it is a processing industry.
86 * @note Industries might be neither raw nor processing.
87 * This is usually the case for industries which produce nothing (e.g. power plants),
88 * but also for weird industries like temperate banks and tropic lumber mills.
90 static bool IsProcessingIndustry(IndustryType industry_type);
92 /**
93 * Can the production of this industry increase?
94 * @param industry_type The type of the industry.
95 * @pre IsValidIndustryType(industry_type).
96 * @return True if the production of this industry can increase.
98 static bool ProductionCanIncrease(IndustryType industry_type);
101 * Get the cost for building this industry-type.
102 * @param industry_type The type of the industry.
103 * @pre IsValidIndustryType(industry_type).
104 * @return The cost for building this industry-type.
106 static Money GetConstructionCost(IndustryType industry_type);
109 * Can you build this type of industry?
110 * @param industry_type The type of the industry.
111 * @pre IsValidIndustryType(industry_type).
112 * @return True if you can build this type of industry at locations of your choice.
113 * @ai @note Returns false if you can only prospect this type of industry, or not build it at all.
114 * @game @note When ScriptCompanyMode::IsDeity, this method returns false if you can
115 * @game only prospect this type of industry, or not build it at all.
116 * @game @note When ScriptCompanyMode::IsDeity, the script can
117 * @game build as long as the industry type can be built. (a NewGRF can for example
118 * @game reject construction based on current year)
120 static bool CanBuildIndustry(IndustryType industry_type);
123 * Can you prospect this type of industry?
124 * @param industry_type The type of the industry.
125 * @pre IsValidIndustryType(industry_type).
126 * @return True if you can prospect this type of industry.
127 * @ai @note If the setting "Manual primary industry construction method" is set
128 * @ai to either "None" or "as other industries" this function always returns false.
129 * @game @note When ScriptCompanyMode::IsDeity, and if the setting
130 * @game "Manual primary industry construction method" is set to either "None" or
131 * @game "as other industries" this function always returns false.
132 * @game @note When ScriptCompanyMode::IsDeity, the script can
133 * @game prospect as long as the industry type can be built. (a NewGRF can for
134 * @game example reject construction based on current year)
136 static bool CanProspectIndustry(IndustryType industry_type);
139 * Build an industry of the specified type.
140 * @param industry_type The type of the industry to build.
141 * @param tile The tile to build the industry on.
142 * @pre CanBuildIndustry(industry_type).
143 * @return True if the industry was successfully build.
145 static bool BuildIndustry(IndustryType industry_type, TileIndex tile);
148 * Prospect an industry of this type. Prospecting an industries let the game try to create
149 * an industry on a random place on the map.
150 * @param industry_type The type of the industry.
151 * @pre CanProspectIndustry(industry_type).
152 * @return True if no error occurred while trying to prospect.
153 * @note Even if true is returned there is no guarantee a new industry is build.
154 * @note If true is returned the money is paid, whether a new industry was build or not.
155 * @game @note When ScriptCompanyMode::IsDeity, prospection will not fail
156 * @game due to the general chance that prospection may fail. However prospection can still
157 * @game fail if OpenTTD is unable to find a suitable location to place the industry.
159 static bool ProspectIndustry(IndustryType industry_type);
162 * Is this type of industry built on water.
163 * @param industry_type The type of the industry.
164 * @pre IsValidIndustryType(industry_type).
165 * @return True when this type is built on water.
167 static bool IsBuiltOnWater(IndustryType industry_type);
170 * Does this type of industry have a heliport?
171 * @param industry_type The type of the industry.
172 * @pre IsValidIndustryType(industry_type).
173 * @return True when this type has a heliport.
175 static bool HasHeliport(IndustryType industry_type);
178 * Does this type of industry have a dock?
179 * @param industry_type The type of the industry.
180 * @pre IsValidIndustryType(industry_type).
181 * @return True when this type has a dock.
183 static bool HasDock(IndustryType industry_type);
186 * Get a specific industry-type from a grf.
187 * @param grfid The ID of the NewGRF.
188 * @param grf_local_id The ID of the industry, local to the NewGRF.
189 * @pre 0x00 <= grf_local_id < NUM_INDUSTRYTYPES_PER_GRF.
190 * @return the industry-type ID, local to the current game (this diverges from the grf_local_id).
192 static IndustryType ResolveNewGRFID(SQInteger grfid, SQInteger grf_local_id);
195 #endif /* SCRIPT_INDUSTRYTYPE_HPP */