ORTS

Object.H

Go to the documentation of this file.
00001 #ifndef Object_H
00002 #define Object_H
00003 
00004 // $Id: Object.H 6636 2008-01-20 20:01:58Z furtak $
00005  
00006 // This is an ORTS file (c) Michael Buro, licensed under the GPL
00007 
00008 // Game object base class (interface to terrain code)
00009 
00010 #include "Global.H"
00011 #include "LinAlg.H"
00012 
00013 class Object {
00014 
00015 public:
00016 
00017   // CIRCLE:    center, radius
00018   // LINE:      (x1,y1)---(x2,y2)
00019   // RECTANGLE: (x1,y1) \ (x2,y2)  (axis aligned)
00020   enum Shape { SHAPE_UNDEF=0, CIRCLE, LINE, RECTANGLE };
00021 
00022   // Z categories
00023   enum ZCat { ZCAT_UNDEF=0, UNDER_WATER, ON_WATER, ON_LAND, IN_AIR };
00024 
00025   virtual Shape get_shape() const = 0;
00026   virtual sint4 get_max_speed() const = 0;
00027 
00028   // only valid if circle:
00029   virtual sint4 get_radius() const = 0;
00030 
00031   // attributes that can change
00032   // if pointer != 0 store previous value there
00033   
00034   virtual ZCat  get_zcat(ZCat *prev = 0) const = 0;  
00035   virtual sint4 get_speed(sint4 *prev=0) const = 0;
00036   virtual bool  get_moving(bool *prev=0) const = 0 ; 
00037   virtual void  get_center(sint4 &x, sint4 &y, sint4 *px=0, sint4 *py=0) const = 0;
00038 
00039   // only valid if rectangle or line:
00040   virtual void get_p1(sint4 &x, sint4 &y, sint4 *px=0, sint4 *py=0) const = 0; // rectangle: upper left corner
00041   virtual void get_p2(sint4 &x, sint4 &y, sint4 *px=0, sint4 *py=0) const = 0; // rectangle: lower right corner
00042 
00043   virtual bool is_pending_action(void) const = 0;
00044 
00045   virtual real8 distance_to(const Object &other) const = 0;
00046 
00047   static void circle_footprint(sint4 x, sint4 y, sint4 r, Vector< Vec2<sint4> > &tiles, sint4 resolution);
00048   static void rect_footprint(sint4 x1, sint4 y1, sint4 x2, sint4 y2,
00049                              Vector< Vec2<sint4> > &tiles, sint4 resolution);
00050   static void line_footprint(sint4 x1, sint4 y1, sint4 x2, sint4 y2,
00051                              Vector< Vec2<sint4> > &tiles, sint4 resolution);
00052 
00053   inline virtual ~Object() { }
00054 };
00055 
00056 REGISTER_TYPEOF(110, Vector<Object*>::iterator);
00057 REGISTER_TYPEOF(111, Vector<Object*>::const_iterator);
00058 
00059 REGISTER_TYPEOF(112, Vector<const Object*>::iterator);
00060 REGISTER_TYPEOF(113, Vector<const Object*>::const_iterator);
00061 
00062 REGISTER_TYPEOF(114, std::set<Object*>::iterator);
00063 REGISTER_TYPEOF(115, std::set<Object*>::const_iterator);
00064 
00065 REGISTER_TYPEOF(116, std::set<const Object*>::iterator);
00066 REGISTER_TYPEOF(117, std::set<const Object*>::const_iterator);
00067 
00068 #endif


Generated on Fri May 18 2012 03:02:43 for ORTS by Doxygen1.7.3