Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Item.h

00001 /*
00002  * Item.h -- class interface for items
00003  * Copyright (C) 2002  Eric Lemings <elemings@users.sourceforge.net>
00004  *
00005  * This software is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This software is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this software; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00018  * 02111-1307, USA
00019  *
00020  * RCS: $Id: Item.h,v 1.3 2003/03/29 02:10:29 elemings Exp $
00021  */
00022 
00023 #ifdef __cplusplus
00024 
00025 #  ifndef OGS_CORE_ITEM_H
00026 #    define OGS_CORE_ITEM_H
00027 
00028 #    include <string>
00029 
00030 #    include <ogs/support/Attachable.h>
00031 #    include <ogs/core/Entity.h>
00032 #    include <ogs/core/Namespace.h>
00033 
00034 OGS_BEGIN_CORE_NAMESPACE
00035 
00041 class Item: public Entity, public ogs::support::Attachable {
00042   public:
00047     typedef double Worth;
00048 
00052     typedef std::string Material;
00053 
00058     typedef unsigned Hardness;
00059 
00064     typedef double Thickness;
00065 
00070     typedef Entity::Health Density;
00071 
00072     virtual bool attachObject (Object& object);
00073     virtual bool detachObject ();
00074     Object* getObject () const;
00075 
00076     Worth getWorth () const;
00077     void setWorth (Worth worth);
00078 
00079     virtual ~Item () = 0;
00080 
00081   protected:
00082     Item (Entity::Weight weight = 0.0,
00083           Size::Type size = Size::MEDIUM,
00084           Worth worth = 0.0);
00085 
00086     virtual bool canEquip (const Object& object) const;
00087 
00088   private:
00089     Worth _worth;
00090     Material _material;
00091     Hardness _hardness;
00092     Thickness _thickness;
00093     Density _density;
00094     Object* _object;
00095 };
00096 
00104 inline bool
00105 Item::detachObject () {
00106   this->_object = NULL;
00107   return (true);
00108 }
00109 
00118 inline bool
00119 Item::canEquip (const Object& object) const {
00120   return (false);
00121 }
00122 
00130 inline ogs::support::Object*
00131 Item::getObject () const {
00132   return (this->_object);
00133 }
00134 
00140 inline Item::Worth
00141 Item::getWorth () const {
00142   return (this->_worth);
00143 }
00144 
00145 inline Item::~Item () { }
00146 
00147 OGS_END_CORE_NAMESPACE
00148 
00149 #  endif /* !defined OGS_CORE_ITEM_H */
00150 
00151 #endif /* defined __cplusplus */
00152 

Generated on Sun Apr 20 03:36:21 2003 for Open Gaming System (OGS) by doxygen1.3