OpenTTD
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 
29  : ScopeResolver(ro), industry(industry), tile(tile)
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 
43  IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
44  CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
45 
46  ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte 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 
56 bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
57 uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile);
58 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);
59 
60 void AnimateNewIndustryTile(TileIndex tile);
61 bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random = Random());
62 bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat);
63 
64 
70 };
72 void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger);
73 
74 #endif /* NEWGRF_INDUSTRYTILES_H */
Owner
Enum for all companies/owners.
Definition: company_type.h:18
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope)...
Tile information, used while rendering the tile.
Definition: tile_cmd.h:42
IndustryAnimationTrigger
Animation triggers of the industries.
Resolver for the industry tiles scope.
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.
ResolverObject & ro
Surrounding resolver object.
VarSpriteGroupScope
Cargo has been delivered.
Functions for NewGRF industries.
Interface for SpriteGroup-s to access the gamestate.
Definitions related to NewGRF animation.
Defines the internal data of a functional industry.
Definition: industry.h:40
Set when using the callback resolve system, but not to resolve a callback.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Common return value for all commands.
Definition: command_type.h:23
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0) override
Get a resolver for the scope.
Pseudo random number generator.
uint32 GetRandomBits() const override
Get a few random bits.
Resolver for industry scopes.
Resolver for industry tiles.
uint32 GetTriggers() const override
Get the triggers.
IndustryTileTrigger
Available industry tile triggers.
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override
Get a variable value.
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
Trigger a random trigger for all industry tiles.
IndustryTileScopeResolver indtile_scope
Scope resolver for the industry tile.
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
Industry * industry
Industry owning the tiles.
Resolved object itself.
IndustriesScopeResolver ind_scope
Scope resolver for the industry owning the tile.
TileIndex tile
Tile being resolved.
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
Related object of the resolved one.
IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
Constructor of the scope resolver for the industry tile.
CallbackID
List of implemented NewGRF callbacks.
Defines the data structure of each individual tile of an industry.
Definition: industrytype.h:155
The tile of the industry has been triggered during the tileloop.
void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger)
Trigger a random trigger for a single industry tile.
The industry has been triggered via its tick.