|
@@ -71,97 +71,97 @@ struct ObjectSpec {
|
|
|
Date end_of_life_date; ///< When can't this object be built anymore.
|
|
|
ObjectFlags flags; ///< Flags/settings related to the object.
|
|
|
AnimationInfo animation; ///< Information about the animation.
|
|
|
uint16 callback_mask; ///< Bitmask of requested/allowed callbacks.
|
|
|
uint8 height; ///< The height of this structure, in heightlevels; max MAX_TILE_HEIGHT.
|
|
|
uint8 views; ///< The number of views.
|
|
|
uint8 generate_amount; ///< Number of objects which are attempted to be generated per 256^2 map during world generation.
|
|
|
bool enabled; ///< Is this spec enabled?
|
|
|
|
|
|
/**
|
|
|
* Get the cost for building a structure of this type.
|
|
|
* @return The cost for building.
|
|
|
*/
|
|
|
Money GetBuildCost() const { return GetPrice(PR_BUILD_OBJECT, this->build_cost_multiplier, this->grf_prop.grffile, 0); }
|
|
|
|
|
|
/**
|
|
|
* Get the cost for clearing a structure of this type.
|
|
|
* @return The cost for clearing.
|
|
|
*/
|
|
|
Money GetClearCost() const { return GetPrice(PR_CLEAR_OBJECT, this->clear_cost_multiplier, this->grf_prop.grffile, 0); }
|
|
|
|
|
|
bool IsEverAvailable() const;
|
|
|
bool WasEverAvailable() const;
|
|
|
bool IsAvailable() const;
|
|
|
uint Index() const;
|
|
|
|
|
|
static const ObjectSpec *Get(ObjectType index);
|
|
|
static const ObjectSpec *GetByTile(TileIndex tile);
|
|
|
};
|
|
|
|
|
|
/** Object scope resolver. */
|
|
|
struct ObjectScopeResolver : public ScopeResolver {
|
|
|
struct Object *obj; ///< The object the callback is ran for.
|
|
|
TileIndex tile; ///< The tile related to the object.
|
|
|
uint8 view; ///< The view of the object.
|
|
|
|
|
|
/**
|
|
|
* Constructor of an object scope resolver.
|
|
|
* @param ro Surrounding resolver.
|
|
|
* @param obj Object being resolved.
|
|
|
* @param tile %Tile of the object.
|
|
|
* @param view View of the object.
|
|
|
*/
|
|
|
ObjectScopeResolver(ResolverObject &ro, Object *obj, TileIndex tile, uint8 view = 0)
|
|
|
: ScopeResolver(ro), obj(obj), tile(tile), view(view)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
/* virtual */ uint32 GetRandomBits() const;
|
|
|
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
|
|
|
uint32 GetRandomBits() const override;
|
|
|
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
|
|
|
};
|
|
|
|
|
|
/** A resolver object to be used with feature 0F spritegroups. */
|
|
|
struct ObjectResolverObject : public ResolverObject {
|
|
|
ObjectScopeResolver object_scope; ///< The object scope resolver.
|
|
|
TownScopeResolver *town_scope; ///< The town scope resolver (created on the first call).
|
|
|
|
|
|
ObjectResolverObject(const ObjectSpec *spec, Object *o, TileIndex tile, uint8 view = 0,
|
|
|
CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0);
|
|
|
~ObjectResolverObject();
|
|
|
|
|
|
/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
|
|
|
ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
|
|
|
{
|
|
|
switch (scope) {
|
|
|
case VSG_SCOPE_SELF:
|
|
|
return &this->object_scope;
|
|
|
|
|
|
case VSG_SCOPE_PARENT: {
|
|
|
TownScopeResolver *tsr = this->GetTown();
|
|
|
if (tsr != NULL) return tsr;
|
|
|
FALLTHROUGH;
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
return ResolverObject::GetScope(scope, relative);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
TownScopeResolver *GetTown();
|
|
|
};
|
|
|
|
|
|
/** Struct containing information relating to object classes. */
|
|
|
typedef NewGRFClass<ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX> ObjectClass;
|
|
|
|
|
|
/** Mapping of purchase for objects. */
|
|
|
static const CargoID CT_PURCHASE_OBJECT = 1;
|
|
|
|
|
|
uint16 GetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, Object *o, TileIndex tile, uint8 view = 0);
|
|
|
|
|
|
void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec);
|
|
|
void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view);
|
|
|
void AnimateNewObjectTile(TileIndex tile);
|
|
|
void TriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
|
|
|
void TriggerObjectAnimation(Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
|
|
|
|
|
|
#endif /* NEWGRF_OBJECT_H */
|