newgrf_object.h

Go to the documentation of this file.
00001 /* $Id: newgrf_object.h 21454 2010-12-10 21:32:52Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #ifndef NEWGRF_OBJECT_H
00013 #define NEWGRF_OBJECT_H
00014 
00015 #include "newgrf_callbacks.h"
00016 #include "date_type.h"
00017 #include "economy_func.h"
00018 #include "strings_type.h"
00019 #include "tile_cmd.h"
00020 #include "object_type.h"
00021 #include "newgrf_animation_type.h"
00022 #include "newgrf_class.h"
00023 #include "newgrf_commons.h"
00024 
00026 enum ObjectFlags {
00027   OBJECT_FLAG_NONE               =       0, 
00028   OBJECT_FLAG_ONLY_IN_SCENEDIT   = 1 <<  0, 
00029   OBJECT_FLAG_CANNOT_REMOVE      = 1 <<  1, 
00030   OBJECT_FLAG_AUTOREMOVE         = 1 <<  2, 
00031   OBJECT_FLAG_BUILT_ON_WATER     = 1 <<  3, 
00032   OBJECT_FLAG_CLEAR_INCOME       = 1 <<  4, 
00033   OBJECT_FLAG_HAS_NO_FOUNDATION  = 1 <<  5, 
00034   OBJECT_FLAG_ANIMATION          = 1 <<  6, 
00035   OBJECT_FLAG_ONLY_IN_GAME       = 1 <<  7, 
00036   OBJECT_FLAG_2CC_COLOUR         = 1 <<  8, 
00037   OBJECT_FLAG_NOT_ON_LAND        = 1 <<  9, 
00038   OBJECT_FLAG_DRAW_WATER         = 1 << 10, 
00039   OBJECT_FLAG_ALLOW_UNDER_BRIDGE = 1 << 11, 
00040   OBJECT_FLAG_ANIM_RANDOM_BITS   = 1 << 12, 
00041 };
00042 DECLARE_ENUM_AS_BIT_SET(ObjectFlags)
00043 
00044 void ResetObjects();
00045 
00047 enum ObjectClassID {
00048   OBJECT_CLASS_BEGIN   =    0, 
00049   OBJECT_CLASS_MAX     =   32, 
00050   INVALID_OBJECT_CLASS = 0xFF, 
00051 };
00053 DECLARE_POSTFIX_INCREMENT(ObjectClassID)
00054 
00055 
00056 struct ObjectSpec {
00057   /* 2 because of the "normal" and "buy" sprite stacks. */
00058   GRFFilePropsBase<2> grf_prop; 
00059   ObjectClassID cls_id;         
00060   StringID name;                
00061 
00062   uint8 climate;                
00063   uint8 size;                   
00064   uint8 build_cost_multiplier;  
00065   uint8 clear_cost_multiplier;  
00066   Date introduction_date;       
00067   Date end_of_life_date;        
00068   ObjectFlags flags;            
00069   AnimationInfo animation;      
00070   uint16 callback_mask;         
00071   uint8 height;                 
00072   uint8 views;                  
00073   bool enabled;                 
00074 
00079   bool IsAvailable() const;
00080 
00085   Money GetBuildCost() const { return (_price[PR_BUILD_OBJECT] * this->build_cost_multiplier); }
00086 
00091   Money GetClearCost() const { return (_price[PR_CLEAR_OBJECT] * this->clear_cost_multiplier); }
00092 
00097   uint Index() const;
00098 
00104   static const ObjectSpec *Get(ObjectType index);
00105 
00111   static const ObjectSpec *GetByTile(TileIndex tile);
00112 };
00113 
00115 typedef NewGRFClass<ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX> ObjectClass;
00116 
00118 static const CargoID CT_PURCHASE_OBJECT = 1;
00119 
00120 uint16 GetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, const Object *o, TileIndex tile, uint8 view = 0);
00121 
00122 void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec);
00123 void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view);
00124 void AnimateNewObjectTile(TileIndex tile);
00125 void TriggerObjectTileAnimation(const Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
00126 void TriggerObjectAnimation(const Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
00127 
00128 #endif /* NEWGRF_OBJECT_H */

Generated on Thu Jan 20 22:57:37 2011 for OpenTTD by  doxygen 1.6.1