10#ifndef NEWGRF_OBJECT_H
11#define NEWGRF_OBJECT_H
72 std::vector<BadgeID> badges;
97 static const std::vector<ObjectSpec> &Specs();
98 static size_t Count();
126 uint32_t
GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter,
bool &available)
const override;
141 return &this->object_scope;
145 if (tsr !=
nullptr)
return tsr;
Struct containing information relating to NewGRF classes for stations and airports.
Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift)
Determine a certain price.
Functions related to the economy.
@ BuildObject
Price for building new objects.
@ ClearObject
Price for destroying objects.
Definitions related to NewGRF animation.
@ NoAnimation
There is no animation.
Types related to NewGRF badges.
Callbacks that NewGRFs could implement.
CallbackID
List of implemented NewGRF callbacks.
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Header file for classes to be used by for example, NewGRF stations and airports.
This file simplifies and embeds a common mechanism of loading/saving and mapping of grf entities.
static const uint8_t OBJECT_SIZE_1X1
The value of a NewGRF's size property when the object is 1x1 tiles: low nibble for X,...
void ResetObjects()
This function initialize the spec arrays of objects.
void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8_t view)
Draw representation of an object (tile) for GUI purposes.
uint16_t GetObjectCallback(CallbackID callback, uint32_t param1, uint32_t param2, const ObjectSpec *spec, Object *o, TileIndex tile, std::span< int32_t > regs100={}, uint8_t view=0)
Perform a callback for an object.
ObjectFlag
Various object behaviours.
@ AnimRandomBits
Object wants random bits in "next animation frame" callback.
@ Autoremove
Object get automatically removed (like "owned land").
@ CannotRemove
Object can not be removed.
@ AllowUnderBridge
Object can built under a bridge.
@ OnlyInScenedit
Object can only be constructed in the scenario editor.
@ BuiltOnWater
Object can be built on water (not required).
@ OnlyInGame
Object can only be built in game.
@ DrawWater
Object wants to be drawn on water.
@ HasNoFoundation
Do not display foundations when on a slope.
@ Uses2CC
Object wants 2CC colour mapping.
@ NotOnLand
Object can not be on land, implicitly sets ObjectFlag::BuiltOnWater.
@ ScaleByWater
Object count is roughly scaled by water amount at edges.
@ Animation
Object has animated tiles.
@ ClearIncome
When object is cleared a positive income is generated instead of a cost.
void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec)
Draw an object on the map.
PoolID< uint16_t, struct ObjectClassIDTag, UINT16_MAX, UINT16_MAX > ObjectClassID
Class IDs for objects.
bool TriggerObjectAnimation(Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec)
Trigger the update of animation on a whole object.
NewGRFClass< ObjectSpec, ObjectClassID > ObjectClass
Class containing information relating to object classes.
bool TriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec)
Trigger the update of animation on a single tile.
void AnimateNewObjectTile(TileIndex tile)
Handle the animation of the object tile.
VarSpriteGroupScope
Shared by deterministic and random groups.
@ VSG_SCOPE_SELF
Resolved object itself.
@ VSG_SCOPE_PARENT
Related object of the resolved one.
Functions to handle the town part of NewGRF towns.
Types related to object tiles.
uint16_t ObjectType
Types of objects.
ObjectAnimationTrigger
Animation triggers for objects.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Information about animation.
const struct GRFFile * grffile
grf file that introduced this entity
Base for each type of NewGRF spec to be used with NewGRFClass.
ObjectScopeResolver object_scope
The object scope resolver.
std::optional< TownScopeResolver > town_scope
The town scope resolver (created on the first call).
TownScopeResolver * GetTown()
Get the town resolver scope that belongs to this object resolver.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0) override
Get a resolver for the scope.
ObjectResolverObject(const ObjectSpec *spec, Object *o, TileIndex tile, uint8_t view=0, CallbackID callback=CBID_NO_CALLBACK, uint32_t param1=0, uint32_t param2=0)
Constructor of the object resolver.
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
TileIndex tile
The tile related to the object.
uint8_t view
The view of the object.
uint32_t GetRandomBits() const override
Get a few random bits.
const ObjectSpec * spec
Specification of the object type.
ObjectScopeResolver(ResolverObject &ro, Object *obj, const ObjectSpec *spec, TileIndex tile, uint8_t view=0)
Constructor of an object scope resolver.
struct Object * obj
The object the callback is ran for.
An object that isn't use for transport, industries or houses.
bool IsEnabled() const
Test if this object is enabled.
TimerGameCalendar::Date introduction_date
From when can this object be built.
StandardGRFFileProps grf_prop
Properties related the the grf file.
LandscapeTypes climate
In which climates is this object available?
StringID name
The name for this object.
bool IsEverAvailable() const
Check whether the object might be available at some point in this game with the current game mode.
static const ObjectSpec * GetByTile(TileIndex tile)
Get the specification associated with a tile.
static const ObjectSpec * Get(ObjectType index)
Get the specification associated with a specific ObjectType.
bool IsAvailable() const
Check whether the object is available at this time.
Money GetClearCost() const
Get the cost for clearing a structure of this type.
uint8_t size
The size of this objects; low nibble for X, high nibble for Y.
uint8_t generate_amount
Number of objects which are attempted to be generated per 256^2 map during world generation.
uint Index() const
Gets the index of this spec.
ObjectCallbackMasks callback_mask
Bitmask of requested/allowed callbacks.
static void BindToClasses()
Tie all ObjectSpecs to their class.
AnimationInfo< ObjectAnimationTriggers > animation
Information about the animation.
ObjectFlags flags
Flags/settings related to the object.
uint8_t height
The height of this structure, in heightlevels; max MAX_TILE_HEIGHT.
uint8_t clear_cost_multiplier
Clear cost multiplier per tile.
bool WasEverAvailable() const
Check whether the object was available at some point in the past or present in this game with the cur...
Money GetBuildCost() const
Get the cost for building a structure of this type.
uint8_t views
The number of views.
TimerGameCalendar::Date end_of_life_date
When can't this object be built anymore.
uint8_t build_cost_multiplier
Build cost multiplier per tile.
An object, such as transmitter, on the map.
Templated helper to make a PoolID a single POD value.
Interface for SpriteGroup-s to access the gamestate.
ResolverObject(const GRFFile *grffile, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Resolver constructor.
CallbackID callback
Callback being resolved.
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0)
Get a resolver for the scope.
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
ResolverObject & ro
Surrounding resolver object.
Container for standard sprite groups.
Tile information, used while rendering the tile.
Scope resolver for a town.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition of the game-calendar-timer.