iregobjs.h

Go to the documentation of this file.
00001 /*
00002  *  iregobjs.h - Ireg (moveable) game objects.
00003  *
00004  *  Copyright (C) 1998-1999  Jeffrey S. Freedman
00005  *  Copyright (C) 2000-2001  The Exult Team
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020  */
00021 
00022 #ifndef IREGOBJS_H
00023 #define IREGOBJS_H  1
00024 
00025 #include "exult_types.h"
00026 #include "objs.h"
00027 
00028 /*
00029  *  A moveable game object (from 'ireg' files):
00030  */
00031 class Ireg_game_object : public Game_object
00032   {
00033   Container_game_object *owner; // Container this is in, or 0.
00034 protected:
00035   unsigned flags:32;    // 32 flags used in 'usecode'.
00036   unsigned flags2:32;   // Another 32 flags used in 'usecode'.
00037 public:
00038   Ireg_game_object(int shapenum, int framenum, unsigned int tilex, 
00039         unsigned int tiley, unsigned int lft = 0)
00040     : Game_object(shapenum, framenum, tilex, tiley, lft),
00041         owner(0), flags(0), flags2(0), lowlift(-1), 
00042         highshape (-1)
00043     {  }
00044           // Copy constructor.
00045   Ireg_game_object(const Ireg_game_object& obj2)
00046     : Game_object(obj2), owner(0), flags(0), flags2(0),
00047           lowlift(-1), highshape (-1)
00048     {  }
00049           // Create fake entry.
00050   Ireg_game_object() : owner(0), flags(0), flags2(0), lowlift(-1), highshape (-1)
00051     {  }
00052   virtual ~Ireg_game_object()
00053     {  }
00054   void set_flags(uint32 f)  // For initialization.
00055     { flags = f; }
00056           // Render.
00057   virtual void paint();
00058   virtual void paint_terrain() {  }
00059           // Move to new abs. location.
00060   virtual void move(int newtx, int newty, int newlift);
00061   void move(Tile_coord t)
00062     { move(t.tx, t.ty, t.tz); }
00063           // Remove/delete this object.
00064   virtual void remove_this(int nodel = 0);
00065   virtual Container_game_object *get_owner()
00066     { return owner; }
00067   virtual void set_owner(Container_game_object *o)
00068     { owner = o; }
00069   virtual int is_dragable() const;// Can this be dragged?
00070   virtual void set_flag(int flag)
00071     {
00072     if (flag >= 0 && flag < 32)
00073       flags |= ((uint32) 1 << flag);
00074     else if (flag >= 32 && flag < 64)
00075       flags2 |= ((uint32) 1 << (flag-32));
00076     }
00077   virtual void clear_flag(int flag)
00078     {
00079     if (flag >= 0 && flag < 32)
00080       flags &= ~((uint32) 1 << flag);
00081     else if (flag >= 32 && flag < 64)
00082       flags2 &= ~((uint32) 1 << (flag-32));
00083     }
00084   virtual int get_flag(int flag) const
00085     {
00086     if (flag >= 0 && flag < 32)
00087       return flags & ((uint32) 1 << flag);
00088     else if (flag >= 32 && flag < 64)
00089       return flags2 & ((uint32) 1 << (flag-32));
00090     return 0;
00091     }
00092   virtual void set_flag_recursively(int flag)
00093     { set_flag(flag); }
00094   uint32 get_flags() const { return flags; }
00095   uint32 get_flags2() const { return flags2; }
00096 
00097           // Write out to IREG file.
00098   virtual void write_ireg(DataSource* out);
00099         // Get size of IREG. Returns -1 if can't write to buffer
00100   virtual int get_ireg_size();
00101   int lowlift;
00102   int highshape;
00103   virtual int get_high_shape() const { return highshape; };
00104   virtual void set_high_shape(int s) { highshape = s;};
00105   virtual int get_low_lift() const { return lowlift; };
00106   virtual void set_low_lift(int l) { lowlift = l;};
00107   };
00108 
00109 #endif

Generated on Mon Jul 9 14:42:49 2007 for ExultEngine by  doxygen 1.5.1