newgrf_object.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef NEWGRF_OBJECT_H
00013 #define NEWGRF_OBJECT_H
00014
00015 #include "newgrf_callbacks.h"
00016 #include "economy_func.h"
00017 #include "tile_cmd.h"
00018 #include "object_type.h"
00019 #include "newgrf_animation_type.h"
00020 #include "newgrf_class.h"
00021 #include "newgrf_commons.h"
00022
00024 enum ObjectFlags {
00025 OBJECT_FLAG_NONE = 0,
00026 OBJECT_FLAG_ONLY_IN_SCENEDIT = 1 << 0,
00027 OBJECT_FLAG_CANNOT_REMOVE = 1 << 1,
00028 OBJECT_FLAG_AUTOREMOVE = 1 << 2,
00029 OBJECT_FLAG_BUILT_ON_WATER = 1 << 3,
00030 OBJECT_FLAG_CLEAR_INCOME = 1 << 4,
00031 OBJECT_FLAG_HAS_NO_FOUNDATION = 1 << 5,
00032 OBJECT_FLAG_ANIMATION = 1 << 6,
00033 OBJECT_FLAG_ONLY_IN_GAME = 1 << 7,
00034 OBJECT_FLAG_2CC_COLOUR = 1 << 8,
00035 OBJECT_FLAG_NOT_ON_LAND = 1 << 9,
00036 OBJECT_FLAG_DRAW_WATER = 1 << 10,
00037 OBJECT_FLAG_ALLOW_UNDER_BRIDGE = 1 << 11,
00038 OBJECT_FLAG_ANIM_RANDOM_BITS = 1 << 12,
00039 };
00040 DECLARE_ENUM_AS_BIT_SET(ObjectFlags)
00041
00042 void ResetObjects();
00043
00045 enum ObjectClassID {
00046 OBJECT_CLASS_BEGIN = 0,
00047 OBJECT_CLASS_MAX = 32,
00048 INVALID_OBJECT_CLASS = 0xFF,
00049 };
00051 DECLARE_POSTFIX_INCREMENT(ObjectClassID)
00052
00053
00054 struct ObjectSpec {
00055
00056 GRFFilePropsBase<2> grf_prop;
00057 ObjectClassID cls_id;
00058 StringID name;
00059
00060 uint8 climate;
00061 uint8 size;
00062 uint8 build_cost_multiplier;
00063 uint8 clear_cost_multiplier;
00064 Date introduction_date;
00065 Date end_of_life_date;
00066 ObjectFlags flags;
00067 AnimationInfo animation;
00068 uint16 callback_mask;
00069 uint8 height;
00070 uint8 views;
00071 bool enabled;
00072
00077 Money GetBuildCost() const { return GetPrice(PR_BUILD_OBJECT, this->build_cost_multiplier, this->grf_prop.grffile, 0); }
00078
00083 Money GetClearCost() const { return GetPrice(PR_CLEAR_OBJECT, this->clear_cost_multiplier, this->grf_prop.grffile, 0); }
00084
00085 bool IsAvailable() const;
00086 uint Index() const;
00087
00088 static const ObjectSpec *Get(ObjectType index);
00089 static const ObjectSpec *GetByTile(TileIndex tile);
00090 };
00091
00093 typedef NewGRFClass<ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX> ObjectClass;
00094
00096 static const CargoID CT_PURCHASE_OBJECT = 1;
00097
00098 uint16 GetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, const Object *o, TileIndex tile, uint8 view = 0);
00099
00100 void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec);
00101 void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view);
00102 void AnimateNewObjectTile(TileIndex tile);
00103 void TriggerObjectTileAnimation(const Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
00104 void TriggerObjectAnimation(const Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
00105
00106 #endif