Codechange: Use cached town, station, industry names for list window sorting
[openttd-github.git] / src / newgrf_industrytiles.h
blob838dcc53326d63505772825292f71574f4a72a9a
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 GetRandomBits() const override;
34 uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
35 uint32 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.
43 IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
44 CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
46 ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
48 switch (scope) {
49 case VSG_SCOPE_SELF: return &indtile_scope;
50 case VSG_SCOPE_PARENT: return &ind_scope;
51 default: return ResolverObject::GetScope(scope, relative);
56 bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
57 uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile);
58 CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type);
60 void AnimateNewIndustryTile(TileIndex tile);
61 bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random = Random());
62 bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat);
65 /** Available industry tile triggers. */
66 enum IndustryTileTrigger {
67 INDTILE_TRIGGER_TILE_LOOP = 0x01, ///< The tile of the industry has been triggered during the tileloop.
68 INDUSTRY_TRIGGER_INDUSTRY_TICK = 0x02, ///< The industry has been triggered via its tick.
69 INDUSTRY_TRIGGER_RECEIVED_CARGO = 0x04, ///< Cargo has been delivered.
71 void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger);
72 void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger);
74 #endif /* NEWGRF_INDUSTRYTILES_H */