10 #ifndef NEWGRF_OBJECT_H
11 #define NEWGRF_OBJECT_H
73 uint16_t callback_mask;
96 bool IsEverAvailable()
const;
97 bool WasEverAvailable()
const;
98 bool IsAvailable()
const;
101 static const std::vector<ObjectSpec> &Specs();
102 static size_t Count();
106 static void BindToClasses();
129 uint32_t
GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter,
bool &available)
const override;
148 if (tsr !=
nullptr)
return tsr;
167 static const size_t OBJECT_SPRITE_GROUP_DEFAULT = 0;
168 static const size_t OBJECT_SPRITE_GROUP_PURCHASE = 1;
Struct containing information relating to NewGRF classes for stations and airports.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift)
Determine a certain price.
Functions related to the economy.
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definitions related to NewGRF animation.
ObjectAnimationTrigger
Animation triggers for objects.
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 e.g.
This file simplyfies 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.
void TriggerObjectAnimation(Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec)
Trigger the update of animation on a whole object.
void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec)
Draw an object on the map.
ObjectFlags
Various object behaviours.
@ OBJECT_FLAG_CLEAR_INCOME
When object is cleared a positive income is generated instead of a cost.
@ OBJECT_FLAG_ALLOW_UNDER_BRIDGE
Object can built under a bridge.
@ OBJECT_FLAG_HAS_NO_FOUNDATION
Do not display foundations when on a slope.
@ OBJECT_FLAG_NONE
Just nothing.
@ OBJECT_FLAG_AUTOREMOVE
Object get automatically removed (like "owned land").
@ OBJECT_FLAG_SCALE_BY_WATER
Object count is roughly scaled by water amount at edges.
@ OBJECT_FLAG_2CC_COLOUR
Object wants 2CC colour mapping.
@ OBJECT_FLAG_ANIMATION
Object has animated tiles.
@ OBJECT_FLAG_BUILT_ON_WATER
Object can be built on water (not required).
@ OBJECT_FLAG_CANNOT_REMOVE
Object can not be removed.
@ OBJECT_FLAG_NOT_ON_LAND
Object can not be on land, implicitly sets OBJECT_FLAG_BUILT_ON_WATER.
@ OBJECT_FLAG_ANIM_RANDOM_BITS
Object wants random bits in "next animation frame" callback.
@ OBJECT_FLAG_ONLY_IN_GAME
Object can only be built in game.
@ OBJECT_FLAG_DRAW_WATER
Object wants to be drawn on water.
@ OBJECT_FLAG_ONLY_IN_SCENEDIT
Object can only be constructed in the scenario editor.
uint16_t GetObjectCallback(CallbackID callback, uint32_t param1, uint32_t param2, const ObjectSpec *spec, Object *o, TileIndex tile, uint8_t view=0)
Perform a callback for an object.
void TriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec)
Trigger the update of animation on a single tile.
ObjectClassID
Class IDs for objects.
@ INVALID_OBJECT_CLASS
Class for the less fortunate.
@ OBJECT_CLASS_BEGIN
The lowest valid value.
@ OBJECT_CLASS_MAX
Maximum number of classes.
void AnimateNewObjectTile(TileIndex tile)
Handle the animation of the object tile.
@ 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.
@ Count
by amount of cargo
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
A resolver object to be used with feature 0F spritegroups.
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.
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.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0) override
Get a resolver for the scope.
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override
Used by the resolver to get values for feature 0F deterministic spritegroups.
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.
Allow incrementing of ObjectClassID variables.
AnimationInfo animation
Information about the animation.
bool IsEnabled() const
Test if this object is enabled.
TimerGameCalendar::Date introduction_date
From when can this object be built.
StringID name
The name for this object.
GRFFilePropsBase< 2 > grf_prop
Properties related the the grf file.
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.
uint8_t climate
In which climates is this object available?
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.
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.
Interface for SpriteGroup-s to access the gamestate.
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.
Templated helper to make a type-safe 'typedef' representing a single POD value.
Tile information, used while rendering the tile.
Scope resolver for a town.
Definition of the game-calendar-timer.