OpenTTD Source 20250205-master-gfd85ab1e2c
|
Functions related to NewGRF objects. More...
#include "newgrf_callbacks.h"
#include "newgrf_spritegroup.h"
#include "newgrf_town.h"
#include "economy_func.h"
#include "timer/timer_game_calendar.h"
#include "object_type.h"
#include "newgrf_animation_type.h"
#include "newgrf_class.h"
#include "newgrf_commons.h"
Go to the source code of this file.
Data Structures | |
struct | ObjectSpec |
Allow incrementing of ObjectClassID variables. More... | |
struct | ObjectScopeResolver |
Object scope resolver. More... | |
struct | ObjectResolverObject |
A resolver object to be used with feature 0F spritegroups. More... | |
Typedefs | |
using | ObjectFlags = EnumBitSet< ObjectFlag, uint16_t > |
using | ObjectClass = NewGRFClass< ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX > |
Class containing information relating to object classes. | |
Enumerations | |
enum class | ObjectFlag : uint8_t { OnlyInScenedit = 0 , CannotRemove = 1 , Autoremove = 2 , BuiltOnWater = 3 , ClearIncome = 4 , HasNoFoundation = 5 , Animation = 6 , OnlyInGame = 7 , Uses2CC = 8 , NotOnLand = 9 , DrawWater = 10 , AllowUnderBridge = 11 , AnimRandomBits = 12 , ScaleByWater = 13 } |
Various object behaviours. More... | |
enum | ObjectClassID : uint16_t { OBJECT_CLASS_BEGIN = 0 , OBJECT_CLASS_MAX = UINT16_MAX , INVALID_OBJECT_CLASS = UINT16_MAX } |
Class IDs for objects. More... | |
Functions | |
void | ResetObjects () |
This function initialize the spec arrays of objects. | |
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 | DrawNewObjectTile (TileInfo *ti, const ObjectSpec *spec) |
Draw an object on the map. | |
void | DrawNewObjectTileInGUI (int x, int y, const ObjectSpec *spec, uint8_t view) |
Draw representation of an object (tile) for GUI purposes. | |
void | AnimateNewObjectTile (TileIndex tile) |
Handle the animation of the object tile. | |
void | TriggerObjectTileAnimation (Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec) |
Trigger the update of animation on a single tile. | |
void | TriggerObjectAnimation (Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec) |
Trigger the update of animation on a whole object. | |
Variables | |
static const uint8_t | OBJECT_SIZE_1X1 = 0x11 |
The value of a NewGRF's size property when the object is 1x1 tiles: low nibble for X, high nibble for Y. | |
static const size_t | OBJECT_SPRITE_GROUP_DEFAULT = 0 |
static const size_t | OBJECT_SPRITE_GROUP_PURCHASE = 1 |
Functions related to NewGRF objects.
Definition in file newgrf_object.h.
Class containing information relating to object classes.
Definition at line 164 of file newgrf_object.h.
using ObjectFlags = EnumBitSet<ObjectFlag, uint16_t> |
Definition at line 40 of file newgrf_object.h.
enum ObjectClassID : uint16_t |
Class IDs for objects.
Enumerator | |
---|---|
OBJECT_CLASS_BEGIN | The lowest valid value. |
OBJECT_CLASS_MAX | Maximum number of classes. |
INVALID_OBJECT_CLASS | Class for the less fortunate. |
Definition at line 47 of file newgrf_object.h.
|
strong |
Various object behaviours.
Enumerator | |
---|---|
OnlyInScenedit | Object can only be constructed in the scenario editor. |
CannotRemove | Object can not be removed. |
Autoremove | Object get automatically removed (like "owned land"). |
BuiltOnWater | Object can be built on water (not required). |
ClearIncome | When object is cleared a positive income is generated instead of a cost. |
HasNoFoundation | Do not display foundations when on a slope. |
Animation | Object has animated tiles. |
OnlyInGame | Object can only be built in game. |
Uses2CC | Object wants 2CC colour mapping. |
NotOnLand | Object can not be on land, implicitly sets ObjectFlag::BuiltOnWater. |
DrawWater | Object wants to be drawn on water. |
AllowUnderBridge | Object can built under a bridge. |
AnimRandomBits | Object wants random bits in "next animation frame" callback. |
ScaleByWater | Object count is roughly scaled by water amount at edges. |
Definition at line 24 of file newgrf_object.h.
void AnimateNewObjectTile | ( | TileIndex | tile | ) |
Handle the animation of the object tile.
tile | The tile to animate. |
Definition at line 542 of file newgrf_object.cpp.
References AnimationBase< ObjectAnimationBase, ObjectSpec, Object, int, StubGetObjectCallback, TileAnimationFrameAnimationHelper< Object > >::AnimateTile(), Animation, AnimRandomBits, ObjectSpec::flags, ObjectSpec::GetByTile(), Object::GetByTile(), and EnumBitSet< Tenum, Tstorage >::Test().
void DrawNewObjectTile | ( | TileInfo * | ti, |
const ObjectSpec * | spec | ||
) |
Draw an object on the map.
ti | Information about the tile to draw on. |
spec | Object spec to draw. |
Definition at line 464 of file newgrf_object.cpp.
References DrawTileLayout, Object::GetByTile(), SpriteGroup::Resolve(), and TileInfo::tile.
void DrawNewObjectTileInGUI | ( | int | x, |
int | y, | ||
const ObjectSpec * | spec, | ||
uint8_t | view | ||
) |
Draw representation of an object (tile) for GUI purposes.
x | Position x of image. |
y | Position y of image. |
spec | Object spec to draw. |
view | The object's view. |
Definition at line 482 of file newgrf_object.cpp.
References _local_company, Livery::colour1, Livery::colour2, DrawNewGRFTileSeqInGUI(), DrawSprite(), ObjectSpec::flags, GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), DrawTileSprites::ground, GroundSpritePaletteTransform(), INVALID_TILE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), PalSpriteID::pal, PALETTE_RECOLOUR_START, SpriteGroup::Resolve(), PalSpriteID::sprite, SPRITE_WIDTH, EnumBitSet< Tenum, Tstorage >::Test(), and Uses2CC.
Referenced by ObjectPickerCallbacks::DrawType(), and BuildObjectWindow::DrawWidget().
uint16_t GetObjectCallback | ( | CallbackID | callback, |
uint32_t | param1, | ||
uint32_t | param2, | ||
const ObjectSpec * | spec, | ||
Object * | o, | ||
TileIndex | tile, | ||
uint8_t | view | ||
) |
Perform a callback for an object.
callback | The callback to perform. |
param1 | The first parameter to pass to the NewGRF. |
param2 | The second parameter to pass to the NewGRF. |
spec | The specification of the object / the entry point. |
o | The object to call the callback for. |
tile | The tile the callback is called for. |
view | The view of the object (only used when o == nullptr). |
Definition at line 426 of file newgrf_object.cpp.
Referenced by BuildObject(), CmdBuildObject(), BuildObjectWindow::DrawWidget(), and StubGetObjectCallback().
void ResetObjects | ( | ) |
This function initialize the spec arrays of objects.
Definition at line 121 of file newgrf_object.cpp.
References _object_specs, NewGRFClass< Tspec, Tindex, Tmax >::Allocate(), ObjectSpec::grf_prop, lengthof, GRFFilePropsBase< Tcnt >::local_id, OBJECT_LIGHTHOUSE, and OBJECT_TRANSMITTER.
Referenced by ResetNewGRFData().
void TriggerObjectAnimation | ( | Object * | o, |
ObjectAnimationTrigger | trigger, | ||
const ObjectSpec * | spec | ||
) |
Trigger the update of animation on a whole object.
o | The object that got triggered. |
trigger | The trigger that is triggered. |
spec | The spec associated with the object. |
Definition at line 570 of file newgrf_object.cpp.
References ObjectSpec::animation, HasBit(), Object::location, TriggerObjectTileAnimation(), and AnimationInfo::triggers.
Referenced by BuildObject().
void TriggerObjectTileAnimation | ( | Object * | o, |
TileIndex | tile, | ||
ObjectAnimationTrigger | trigger, | ||
const ObjectSpec * | spec | ||
) |
Trigger the update of animation on a single tile.
o | The object that got triggered. |
tile | The location of the triggered tile. |
trigger | The trigger that is triggered. |
spec | The spec associated with the object. |
Definition at line 557 of file newgrf_object.cpp.
References ObjectSpec::animation, CBID_OBJECT_ANIMATION_START_STOP, AnimationBase< ObjectAnimationBase, ObjectSpec, Object, int, StubGetObjectCallback, TileAnimationFrameAnimationHelper< Object > >::ChangeAnimationFrame(), HasBit(), Random, and AnimationInfo::triggers.
Referenced by TriggerObjectAnimation().
|
static |
The value of a NewGRF's size property when the object is 1x1 tiles: low nibble for X, high nibble for Y.
Definition at line 42 of file newgrf_object.h.
Referenced by CmdBuildObjectArea(), ObjectChangeInfo(), and BuildObjectWindow::OnPlaceObject().
|
static |
Definition at line 166 of file newgrf_object.h.
|
static |
Definition at line 167 of file newgrf_object.h.