Codefix: Documentation comment in IndustryDirectoryWindow (#13059)
[openttd-github.git] / src / newgrf_industrytiles.h
blobe9431edf002dcfd36c9497166cc0f7728d9635d1
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 newgrf_industrytiles.h NewGRF handling of industry tiles. */
10 #ifndef NEWGRF_INDUSTRYTILES_H
11 #define NEWGRF_INDUSTRYTILES_H
13 #include "newgrf_animation_type.h"
14 #include "newgrf_industries.h"
15 #include "core/random_func.hpp"
17 /** Resolver for the industry tiles scope. */
18 struct IndustryTileScopeResolver : public ScopeResolver {
19 Industry *industry; ///< Industry owning the tiles.
20 TileIndex tile; ///< %Tile being resolved.
22 /**
23 * Constructor of the scope resolver for the industry tile.
24 * @param ro Surrounding resolver.
25 * @param industry %Industry owning the tile.
26 * @param tile %Tile of the industry.
28 IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
29 : ScopeResolver(ro), industry(industry), tile(tile)
33 uint32_t GetRandomBits() const override;
34 uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override;
35 uint32_t GetTriggers() const override;
38 /** Resolver for industry tiles. */
39 struct IndustryTileResolverObject : public ResolverObject {
40 IndustryTileScopeResolver indtile_scope; ///< Scope resolver for the industry tile.
41 IndustriesScopeResolver ind_scope; ///< Scope resolver for the industry owning the tile.
42 IndustryGfx gfx;
44 IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
45 CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0);
47 ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, uint8_t relative = 0) override
49 switch (scope) {
50 case VSG_SCOPE_SELF: return &indtile_scope;
51 case VSG_SCOPE_PARENT: return &ind_scope;
52 default: return ResolverObject::GetScope(scope, relative);
56 GrfSpecFeature GetFeature() const override;
57 uint32_t GetDebugID() const override;
60 bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
61 uint16_t GetIndustryTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile);
62 CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type);
64 void AnimateNewIndustryTile(TileIndex tile);
65 bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32_t random = Random());
66 bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat);
69 /** Available industry tile triggers. */
70 enum IndustryTileTrigger {
71 INDTILE_TRIGGER_TILE_LOOP = 0x01, ///< The tile of the industry has been triggered during the tileloop.
72 INDUSTRY_TRIGGER_INDUSTRY_TICK = 0x02, ///< The industry has been triggered via its tick.
73 INDUSTRY_TRIGGER_RECEIVED_CARGO = 0x04, ///< Cargo has been delivered.
75 void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger);
76 void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger);
78 #endif /* NEWGRF_INDUSTRYTILES_H */