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/>.
8 /** @file script_objecttype.hpp Everything to query and build industries. */
10 #ifndef SCRIPT_OBJECTTYPE_HPP
11 #define SCRIPT_OBJECTTYPE_HPP
13 #include "script_list.hpp"
15 #include "../../newgrf_object.h"
18 * Class that handles all object-type related functions.
21 class ScriptObjectType
: public ScriptObject
{
24 * Checks whether the given object-type is valid.
25 * @param object_type The type to check.
26 * @return True if and only if the object-type is valid.
28 static bool IsValidObjectType(ObjectType object_type
);
31 * Get the name of an object-type.
32 * @param object_type The type to get the name for.
33 * @pre IsValidObjectType(object_type).
34 * @return The name of an object.
36 static std::optional
<std::string
> GetName(ObjectType object_type
);
39 * Get the number of views for an object-type.
40 * @param object_type The type to get the number of views for.
41 * @pre IsValidObjectType(object_type).
42 * @return The number of views for an object.
44 static SQInteger
GetViews(ObjectType object_type
);
47 * Build an object of the specified type.
48 * @param object_type The type of the object to build.
49 * @param view The view for teh object.
50 * @param tile The tile to build the object on.
51 * @pre IsValidObjectType(object_type).
52 * @return True if the object was successfully build.
54 static bool BuildObject(ObjectType object_type
, SQInteger view
, TileIndex tile
);
57 * Get a specific object-type from a grf.
58 * @param grfid The ID of the NewGRF.
59 * @param grf_local_id The ID of the object, local to the NewGRF.
60 * @pre 0x00 <= grf_local_id < NUM_OBJECTS_PER_GRF.
61 * @return the object-type ID, local to the current game (this diverges from the grf_local_id).
63 static ObjectType
ResolveNewGRFID(SQInteger grfid
, SQInteger grf_local_id
);
66 #endif /* SCRIPT_OBJECTTYPE_HPP */