OpenTTD Source  1.11.0-beta2
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 
21 
30  {
31  }
32 
33  uint32 GetRandomBits() const override;
34  uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
35  uint32 GetTriggers() const override;
36 };
37 
42  IndustryGfx gfx;
43 
44  IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
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 GetDebugID() const override;
58 };
59 
60 bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
61 uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 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 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type);
63 
64 void AnimateNewIndustryTile(TileIndex tile);
65 bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random = Random());
66 bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat);
67 
68 
74 };
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
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
VarSpriteGroupScope
VarSpriteGroupScope
Definition: newgrf_spritegroup.h:100
ResolverObject::callback_param1
uint32 callback_param1
First parameter (var 10) of the callback.
Definition: newgrf_spritegroup.h:334
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:42
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:315
IndustryTileScopeResolver::GetRandomBits
uint32 GetRandomBits() const override
Get a few random bits.
Definition: newgrf_industrytiles.cpp:102
PerformIndustryTileSlopeCheck
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)
Check the slope of a tile of a new industry.
Definition: newgrf_industrytiles.cpp:230
IndustryAnimationTrigger
IndustryAnimationTrigger
Animation triggers of the industries.
Definition: newgrf_animation_type.h:37
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:104
Industry
Defines the internal data of a functional industry.
Definition: industry.h:66
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:296
VSG_SCOPE_SELF
@ VSG_SCOPE_SELF
Resolved object itself.
Definition: newgrf_spritegroup.h:103
IndustryTileScopeResolver
Resolver for the industry tiles scope.
Definition: newgrf_industrytiles.h:18
ResolverObject::callback_param2
uint32 callback_param2
Second parameter (var 18) of the callback.
Definition: newgrf_spritegroup.h:335
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
IndustryTileScopeResolver::GetVariable
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override
Get a variable value.
Definition: newgrf_industrytiles.cpp:61
IndustriesScopeResolver
Resolver for industry scopes.
Definition: newgrf_industries.h:16
IndustryTileResolverObject::IndustryTileResolverObject
IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus, CallbackID callback=CBID_NO_CALLBACK, uint32 callback_param1=0, uint32 callback_param2=0)
Constructor of the industry tiles scope resolver.
Definition: newgrf_industrytiles.cpp:138
IndustryTileResolverObject::GetFeature
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
Definition: newgrf_industrytiles.cpp:148
ResolverObject::GetScope
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Definition: newgrf_spritegroup.cpp:153
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
TriggerIndustryTile
void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger)
Trigger a random trigger for a single industry tile.
Definition: newgrf_industrytiles.cpp:359
ResolverObject::callback
CallbackID callback
Callback being resolved.
Definition: newgrf_spritegroup.h:333
random_func.hpp
IndustryTileScopeResolver::GetTriggers
uint32 GetTriggers() const override
Get the triggers.
Definition: newgrf_industrytiles.cpp:110
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:297
IndustryTileSpec
Defines the data structure of each individual tile of an industry.
Definition: industrytype.h:156
newgrf_animation_type.h
IndustryTileTrigger
IndustryTileTrigger
Available industry tile triggers.
Definition: newgrf_industrytiles.h:70
IndustryTileResolverObject::GetDebugID
uint32 GetDebugID() const override
Get an identifier for the item being resolved.
Definition: newgrf_industrytiles.cpp:153