OpenTTD

newgrf_industrytiles.h
Go to the documentation of this file.
1 /* $Id: newgrf_industrytiles.h 27984 2018-03-11 13:19:41Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef NEWGRF_INDUSTRYTILES_H
13 #define NEWGRF_INDUSTRYTILES_H
14
15 #include "newgrf_animation_type.h"
16 #include "newgrf_industries.h"
17 #include "core/random_func.hpp"
18
20 struct IndustryTileScopeResolver : public ScopeResolver {
21 Industry *industry;
22 TileIndex tile;
23
30 IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
31 : ScopeResolver(ro), industry(industry), tile(tile)
32 {
33 }
34
35 /* virtual */ uint32 GetRandomBits() const;
36 /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
37 /* virtual */ uint32 GetTriggers() const;
38 };
39
41 struct IndustryTileResolverObject : public ResolverObject {
42 IndustryTileScopeResolver indtile_scope;
43 IndustriesScopeResolver ind_scope;
44
45 IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
46 CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
47
48 /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
49 {
50 switch (scope) {
51 case VSG_SCOPE_SELF: return &indtile_scope;
52 case VSG_SCOPE_PARENT: return &ind_scope;
53 default: return ResolverObject::GetScope(scope, relative);
54 }
55 }
56 };
57
58 bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
59 uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile);
60 CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type);
61
62 void AnimateNewIndustryTile(TileIndex tile);
63 bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random = Random());
64 bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat);
65
66
68 enum IndustryTileTrigger {
69 INDTILE_TRIGGER_TILE_LOOP = 0x01,
70 INDUSTRY_TRIGGER_INDUSTRY_TICK = 0x02,
71 INDUSTRY_TRIGGER_RECEIVED_CARGO = 0x04,
72 };
73 void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger);
74 void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger);
75
76 #endif /* NEWGRF_INDUSTRYTILES_H */
ScopeResolver
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope)...
Definition: newgrf_spritegroup.h:291
TileInfo
Tile information, used while rendering the tile.
Definition: tile_cmd.h:44
IndustryAnimationTrigger
IndustryAnimationTrigger
Animation triggers of the industries.
Definition: newgrf_animation_type.h:39
IndustryTileScopeResolver
Resolver for the industry tiles scope.
Definition: newgrf_industrytiles.h:20
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition: newgrf_spritegroup.h:292
VarSpriteGroupScope
VarSpriteGroupScope
Definition: newgrf_spritegroup.h:100
IndustryTileResolverObject::GetScope
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Definition: newgrf_industrytiles.h:48
INDUSTRY_TRIGGER_RECEIVED_CARGO
Cargo has been delivered.
Definition: newgrf_industrytiles.h:71
newgrf_industries.h
Functions for NewGRF industries.
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:310
newgrf_animation_type.h
Definitions related to NewGRF animation.
Industry
Defines the internal data of a functional industry.
Definition: industry.h:39
CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Definition: newgrf_callbacks.h:24
PerformIndustryTileSlopeCheck
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
Check the slope of a tile of a new industry.
Definition: newgrf_industrytiles.cpp:221
ResolverObject::GetScope
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Definition: newgrf_spritegroup.cpp:142
CommandCost
Common return value for all commands.
Definition: command_type.h:25
random_func.hpp
Pseudo random number generator.
IndustriesScopeResolver
Resolver for industry scopes.
Definition: newgrf_industries.h:18
IndustryTileResolverObject
Resolver for industry tiles.
Definition: newgrf_industrytiles.h:41
IndustryTileTrigger
IndustryTileTrigger
Available industry tile triggers.
Definition: newgrf_industrytiles.h:68
IndustryTileScopeResolver::GetRandomBits
uint32 GetRandomBits() const
Get a few random bits.
Definition: newgrf_industrytiles.cpp:104
TriggerIndustry
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
Trigger a random trigger for all industry tiles.
Definition: newgrf_industrytiles.cpp:363
IndustryTileScopeResolver::GetVariable
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const
Get a variable value.
Definition: newgrf_industrytiles.cpp:63
IndustryTileResolverObject::indtile_scope
IndustryTileScopeResolver indtile_scope
Scope resolver for the industry tile.
Definition: newgrf_industrytiles.h:42
IndustryAvailabilityCallType
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
Definition: newgrf_industries.h:81
IndustryTileScopeResolver::industry
Industry * industry
Industry owning the tiles.
Definition: newgrf_industrytiles.h:21
VSG_SCOPE_SELF
Resolved object itself.
Definition: newgrf_spritegroup.h:103
IndustryTileResolverObject::ind_scope
IndustriesScopeResolver ind_scope
Scope resolver for the industry owning the tile.
Definition: newgrf_industrytiles.h:43
IndustryTileScopeResolver::tile
TileIndex tile
Tile being resolved.
Definition: newgrf_industrytiles.h:22
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
VSG_SCOPE_PARENT
Related object of the resolved one.
Definition: newgrf_spritegroup.h:104
IndustryTileScopeResolver::IndustryTileScopeResolver
IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
Constructor of the scope resolver for the industry tile.
Definition: newgrf_industrytiles.h:30
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition: newgrf_callbacks.h:22
IndustryTileSpec
Defines the data structure of each individual tile of an industry.
Definition: industrytype.h:148
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
INDTILE_TRIGGER_TILE_LOOP
The tile of the industry has been triggered during the tileloop.
Definition: newgrf_industrytiles.h:69
IndustryTileScopeResolver::GetTriggers
uint32 GetTriggers() const
Get the triggers.
Definition: newgrf_industrytiles.cpp:112
TriggerIndustryTile
void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger)
Trigger a random trigger for a single industry tile.
Definition: newgrf_industrytiles.cpp:350
INDUSTRY_TRIGGER_INDUSTRY_TICK
The industry has been triggered via its tick.
Definition: newgrf_industrytiles.h:70