OpenTTD Source: src/newgrf_industrytiles.h Source File

OpenTTD Source 14.0-beta1

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
13 #include "newgrf_animation_type.h"
14 #include "newgrf_industries.h"
15 #include "core/random_func.hpp"
16
18 struct IndustryTileScopeResolver : public ScopeResolver {
19 Industry *industry;
20 TileIndex tile;
21
28 IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
29 : ScopeResolver(ro), industry(industry), tile(tile)
30 {
31 }
32
33 uint32_t GetRandomBits() const override;
34 uint32_t GetVariable(byte variable, [[maybe_unused]] uint32_t parameter, bool *available) const override;
35 uint32_t GetTriggers() const override;
36 };
37
39 struct IndustryTileResolverObject : public ResolverObject {
40 IndustryTileScopeResolver indtile_scope;
41 IndustriesScopeResolver ind_scope;
42 IndustryGfx gfx;
43
44 IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
45 CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0);
46
47 ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte 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
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);
63
64 void AnimateNewIndustryTile(TileIndex tile);
65 bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32_t random = Random());
66 bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat);
67
68
70 enum IndustryTileTrigger {
71 INDTILE_TRIGGER_TILE_LOOP = 0x01,
72 INDUSTRY_TRIGGER_INDUSTRY_TICK = 0x02,
73 INDUSTRY_TRIGGER_RECEIVED_CARGO = 0x04,
74 };
75 void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger);
76 void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger);
77
78 #endif /* NEWGRF_INDUSTRYTILES_H */
IndustryTileScopeResolver::industry
Industry * industry
Industry owning the tiles.
Definition: newgrf_industrytiles.h:19
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:230
VarSpriteGroupScope
VarSpriteGroupScope
Definition: newgrf_spritegroup.h:97
IndustryTileResolverObject::GetScope
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0) override
Get a resolver for the scope.
Definition: newgrf_industrytiles.h:47
IndustryTileResolverObject::indtile_scope
IndustryTileScopeResolver indtile_scope
Scope resolver for the industry tile.
Definition: newgrf_industrytiles.h:40
TileInfo
Tile information, used while rendering the tile.
Definition: tile_cmd.h:43
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:307
IndustryTileResolverObject::GetDebugID
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
Definition: newgrf_industrytiles.cpp:153
IndustryAnimationTrigger
IndustryAnimationTrigger
Animation triggers of the industries.
Definition: newgrf_animation_type.h:37
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition: newgrf_callbacks.h:20
VSG_SCOPE_PARENT
@ VSG_SCOPE_PARENT
Related object of the resolved one.
Definition: newgrf_spritegroup.h:101
Industry
Defines the internal data of a functional industry.
Definition: industry.h:68
INDUSTRY_TRIGGER_INDUSTRY_TICK
@ INDUSTRY_TRIGGER_INDUSTRY_TICK
The industry has been triggered via its tick.
Definition: newgrf_industrytiles.h:72
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
ScopeResolver
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
Definition: newgrf_spritegroup.h:288
IndustryTileResolverObject::IndustryTileResolverObject
IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Constructor of the industry tiles scope resolver.
Definition: newgrf_industrytiles.cpp:138
IndustryTileScopeResolver::GetRandomBits
uint32_t GetRandomBits() const override
Get a few random bits.
Definition: newgrf_industrytiles.cpp:102
VSG_SCOPE_SELF
@ VSG_SCOPE_SELF
Resolved object itself.
Definition: newgrf_spritegroup.h:100
IndustryTileScopeResolver
Resolver for the industry tiles scope.
Definition: newgrf_industrytiles.h:18
INDUSTRY_TRIGGER_RECEIVED_CARGO
@ INDUSTRY_TRIGGER_RECEIVED_CARGO
Cargo has been delivered.
Definition: newgrf_industrytiles.h:73
CommandCost
Common return value for all commands.
Definition: command_type.h:23
IndustryTileResolverObject
Resolver for industry tiles.
Definition: newgrf_industrytiles.h:39
CBID_NO_CALLBACK
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Definition: newgrf_callbacks.h:22
IndustryTileResolverObject::ind_scope
IndustriesScopeResolver ind_scope
Scope resolver for the industry owning the tile.
Definition: newgrf_industrytiles.h:41
IndustryTileScopeResolver::IndustryTileScopeResolver
IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
Constructor of the scope resolver for the industry tile.
Definition: newgrf_industrytiles.h:28
TriggerIndustry
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
Trigger a random trigger for all industry tiles.
Definition: newgrf_industrytiles.cpp:372
IndustriesScopeResolver
Resolver for industry scopes.
Definition: newgrf_industries.h:16
IndustryTileResolverObject::GetFeature
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
Definition: newgrf_industrytiles.cpp:148
IndustryTileScopeResolver::GetTriggers
uint32_t GetTriggers() const override
Get the triggers.
Definition: newgrf_industrytiles.cpp:110
ResolverObject::GetScope
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Definition: newgrf_spritegroup.cpp:135
IndustryAvailabilityCallType
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
Definition: newgrf_industries.h:82
GrfSpecFeature
GrfSpecFeature
Definition: newgrf.h:66
INDTILE_TRIGGER_TILE_LOOP
@ INDTILE_TRIGGER_TILE_LOOP
The tile of the industry has been triggered during the tileloop.
Definition: newgrf_industrytiles.h:71
ResolverObject::callback_param2
uint32_t callback_param2
Second parameter (var 18) of the callback.
Definition: newgrf_spritegroup.h:327
TriggerIndustryTile
void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger)
Trigger a random trigger for a single industry tile.
Definition: newgrf_industrytiles.cpp:359
IndustryTileScopeResolver::GetVariable
uint32_t GetVariable(byte variable, [[maybe_unused]] uint32_t parameter, bool *available) const override
Get a variable value.
Definition: newgrf_industrytiles.cpp:61
ResolverObject::callback
CallbackID callback
Callback being resolved.
Definition: newgrf_spritegroup.h:325
ResolverObject::callback_param1
uint32_t callback_param1
First parameter (var 10) of the callback.
Definition: newgrf_spritegroup.h:326
random_func.hpp
IndustryTileScopeResolver::tile
TileIndex tile
Tile being resolved.
Definition: newgrf_industrytiles.h:20
newgrf_industries.h
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition: newgrf_spritegroup.h:289
IndustryTileSpec
Defines the data structure of each individual tile of an industry.
Definition: industrytype.h:154
newgrf_animation_type.h
IndustryTileTrigger
IndustryTileTrigger
Available industry tile triggers.
Definition: newgrf_industrytiles.h:70