OpenTTD Source 20250529-master-g10c159a79f
newgrf_industrytiles.h
Go to the documentation of this file.
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 */
7
10#ifndef NEWGRF_INDUSTRYTILES_H
11#define NEWGRF_INDUSTRYTILES_H
12
14#include "newgrf_industries.h"
15#include "core/random_func.hpp"
16
21
32
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 GetRandomTriggers() const override;
36};
37
39struct IndustryTileResolverObject : public SpecializedResolverObject<IndustryRandomTriggers> {
42 IndustryGfx gfx;
43
44 IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
46
47 ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, uint8_t relative = 0) override
48 {
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);
53 }
54 }
55
56 GrfSpecFeature GetFeature() const override;
57 uint32_t GetDebugID() const override;
58};
59
60bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
61uint16_t GetIndustryTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile, std::span<int32_t> regs100 = {});
62CommandCost 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);
63
64void AnimateNewIndustryTile(TileIndex tile);
65bool TriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat);
66bool TriggerIndustryTileAnimation_ConstructionStageChanged(TileIndex tile, bool first_call);
67bool TriggerIndustryAnimation(const Industry *ind, IndustryAnimationTrigger iat);
68
71
72#endif /* NEWGRF_INDUSTRYTILES_H */
Common return value for all commands.
IndustryRandomTrigger
Available industry random triggers.
IndustryAnimationTrigger
Animation triggers of the industries.
GrfSpecFeature
Definition newgrf.h:69
Definitions related to NewGRF animation.
CallbackID
List of implemented NewGRF callbacks.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Functions for NewGRF industries.
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
void TriggerIndustryTileRandomisation(TileIndex t, IndustryRandomTrigger trigger)
Trigger a random trigger for a single industry tile.
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)
Check the slope of a tile of a new industry.
void TriggerIndustryRandomisation(Industry *ind, IndustryRandomTrigger trigger)
Trigger a random trigger for all industry tiles.
VarSpriteGroupScope
@ VSG_SCOPE_SELF
Resolved object itself.
@ VSG_SCOPE_PARENT
Related object of the resolved one.
Pseudo random number generator.
Resolver for industry scopes.
Resolver for industry tiles.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
IndustriesScopeResolver ind_scope
Scope resolver for the industry owning the tile.
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
IndustryTileScopeResolver indtile_scope
Scope resolver for the industry tile.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0) override
Get a resolver for the scope.
Resolver for the industry tiles scope.
IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
Constructor of the scope resolver for the industry tile.
uint32_t GetRandomBits() const override
Get a few random bits.
Industry * industry
Industry owning the tiles.
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
TileIndex tile
Tile being resolved.
uint32_t GetRandomTriggers() const override
Get the triggers.
Defines the data structure of each individual tile of an industry.
Defines the internal data of a functional industry.
Definition industry.h:64
Interface for SpriteGroup-s to access the gamestate.
uint32_t callback_param2
Second parameter (var 18) of the callback.
CallbackID callback
Callback being resolved.
uint32_t callback_param1
First parameter (var 10) of the callback.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0)
Get a resolver for the scope.
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
ResolverObject & ro
Surrounding resolver object.
Specialization of ResolverObject with type-safe access to RandomTriggers.
Tile information, used while rendering the tile.
Definition tile_cmd.h:29