OpenTTD Source: src/newgrf_industrytiles.h Source File

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef NEWGRF_INDUSTRYTILES_H
11#define NEWGRF_INDUSTRYTILES_H
12
13#include "newgrf_animation_type.h"
14#include "newgrf_industries.h"
15
17 struct IndustryTileScopeResolver : public ScopeResolver {
18 Industry *industry;
19 TileIndex tile;
20
27 IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
28 : ScopeResolver(ro), industry(industry), tile(tile)
29 {
30 }
31
32 uint32_t GetRandomBits() const override;
33 uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override;
34 uint32_t GetRandomTriggers() const override;
35};
36
38 struct IndustryTileResolverObject : public SpecializedResolverObject<IndustryRandomTriggers> {
39 IndustryTileScopeResolver indtile_scope;
40 IndustriesScopeResolver ind_scope;
41 IndustryGfx gfx;
42
43 IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
44 CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0);
45
46 ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, uint8_t relative = 0) override
47 {
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);
52 }
53 }
54
55 GrfSpecFeature GetFeature() const override;
56 uint32_t GetDebugID() const override;
57};
58
59bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
60uint16_t GetIndustryTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile, std::span<int32_t> regs100 = {});
61 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);
62
63void AnimateNewIndustryTile(TileIndex tile);
64bool TriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat);
65bool TriggerIndustryTileAnimation_ConstructionStageChanged(TileIndex tile, bool first_call);
66bool TriggerIndustryAnimation(const Industry *ind, IndustryAnimationTrigger iat);
67
68void TriggerIndustryTileRandomisation(TileIndex t, IndustryRandomTrigger trigger);
69void TriggerIndustryRandomisation(Industry *ind, IndustryRandomTrigger trigger);
70
71#endif /* NEWGRF_INDUSTRYTILES_H */
CommandCost
Common return value for all commands.
Definition command_type.h:24
IndustryRandomTrigger
IndustryRandomTrigger
Available industry random triggers.
Definition industry_type.h:25
IndustryAnimationTrigger
IndustryAnimationTrigger
Animation triggers of the industries.
Definition industry_type.h:33
GrfSpecFeature
GrfSpecFeature
Definition newgrf.h:68
newgrf_animation_type.h
Definitions related to NewGRF animation.
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition newgrf_callbacks.h:22
CBID_NO_CALLBACK
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Definition newgrf_callbacks.h:24
newgrf_industries.h
Functions for NewGRF industries.
IndustryAvailabilityCallType
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
Definition newgrf_industries.h:81
TriggerIndustryTileRandomisation
void TriggerIndustryTileRandomisation(TileIndex t, IndustryRandomTrigger trigger)
Trigger a random trigger for a single industry tile.
Definition newgrf_industrytiles.cpp:375
PerformIndustryTileSlopeCheck
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.
Definition newgrf_industrytiles.cpp:232
TriggerIndustryRandomisation
void TriggerIndustryRandomisation(Industry *ind, IndustryRandomTrigger trigger)
Trigger a random trigger for all industry tiles.
Definition newgrf_industrytiles.cpp:388
VarSpriteGroupScope
VarSpriteGroupScope
Definition newgrf_spritegroup.h:82
VSG_SCOPE_SELF
@ VSG_SCOPE_SELF
Resolved object itself.
Definition newgrf_spritegroup.h:85
VSG_SCOPE_PARENT
@ VSG_SCOPE_PARENT
Related object of the resolved one.
Definition newgrf_spritegroup.h:86
IndustriesScopeResolver
Resolver for industry scopes.
Definition newgrf_industries.h:16
IndustryTileResolverObject
Resolver for industry tiles.
Definition newgrf_industrytiles.h:38
IndustryTileResolverObject::GetFeature
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
Definition newgrf_industrytiles.cpp:151
IndustryTileResolverObject::ind_scope
IndustriesScopeResolver ind_scope
Scope resolver for the industry owning the tile.
Definition newgrf_industrytiles.h:40
IndustryTileResolverObject::GetDebugID
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
Definition newgrf_industrytiles.cpp:156
IndustryTileResolverObject::indtile_scope
IndustryTileScopeResolver indtile_scope
Scope resolver for the industry tile.
Definition newgrf_industrytiles.h:39
IndustryTileResolverObject::GetScope
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0) override
Get a resolver for the scope.
Definition newgrf_industrytiles.h:46
IndustryTileScopeResolver
Resolver for the industry tiles scope.
Definition newgrf_industrytiles.h:17
IndustryTileScopeResolver::IndustryTileScopeResolver
IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
Constructor of the scope resolver for the industry tile.
Definition newgrf_industrytiles.h:27
IndustryTileScopeResolver::GetRandomBits
uint32_t GetRandomBits() const override
Get a few random bits.
Definition newgrf_industrytiles.cpp:105
IndustryTileScopeResolver::industry
Industry * industry
Industry owning the tiles.
Definition newgrf_industrytiles.h:18
IndustryTileScopeResolver::GetVariable
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
Definition newgrf_industrytiles.cpp:62
IndustryTileScopeResolver::tile
TileIndex tile
Tile being resolved.
Definition newgrf_industrytiles.h:19
IndustryTileScopeResolver::GetRandomTriggers
uint32_t GetRandomTriggers() const override
Get the triggers.
Definition newgrf_industrytiles.cpp:113
IndustryTileSpec
Defines the data structure of each individual tile of an industry.
Definition industrytype.h:152
Industry
Defines the internal data of a functional industry.
Definition industry.h:62
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition newgrf_spritegroup.h:288
ResolverObject::callback_param2
uint32_t callback_param2
Second parameter (var 18) of the callback.
Definition newgrf_spritegroup.h:342
ResolverObject::callback
CallbackID callback
Callback being resolved.
Definition newgrf_spritegroup.h:340
ResolverObject::callback_param1
uint32_t callback_param1
First parameter (var 10) of the callback.
Definition newgrf_spritegroup.h:341
ResolverObject::GetScope
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0)
Get a resolver for the scope.
Definition newgrf_spritegroup.cpp:133
ScopeResolver
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
Definition newgrf_spritegroup.h:269
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition newgrf_spritegroup.h:270
SpecializedResolverObject
Specialization of ResolverObject with type-safe access to RandomTriggers.
Definition newgrf_spritegroup.h:450
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
TileInfo
Tile information, used while rendering the tile.
Definition tile_cmd.h:30