C:/Users/Mike/Documents/Visual Studio Projects/GameEngine/include/GameObject.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 Copyright (C) 2006 Michael Harnetty
00004 
00005 This program 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 program 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 program; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 -----------------------------------------------------------------------------
00019 */
00020 
00021 #ifndef GAMEOBJECT_H
00022 #define GAMEOBJECT_H
00023 
00024 #include "GameEnginePrerequisites.h"
00025 #include "GameObjectType.h"
00026 #include "GameObjectComponent.h"
00027 #include "Process.h"
00028 #include "Vector3.h"
00029 #include "BaseGame.h"
00030 #include "GameState.h"
00031 #include "Quaternion.h"
00032 #include "GameUtils.h"
00033 
00034 namespace GameEngine {
00035 
00036         class BaseGame;
00037         
00038         typedef std::list< boost::shared_ptr<GameObjectComponent> > GameObjectComponentList;
00039 
00046         class ENGINE_DECL GameObject : public Process, public IEventListener, public boost::enable_shared_from_this<GameObject> {
00047 
00048         public:
00049                 
00057                 GameObject(     char const * const objectType, 
00058                                         const std::string& objectID,
00059                                         GameState* gameState,
00060                                         int timeToLive = -1
00061                                 );
00062 
00067                 GameObject(const GameObject& o); // Note to self: Haven't implemented yet, but what are we going to do about unique ID's etc ?
00068 
00071                 virtual ~GameObject();
00072 
00073                 
00074 
00079                 void addComponent( boost::shared_ptr<GameObjectComponent> component);
00080                 
00085                 void removeComponent( boost::shared_ptr<GameObjectComponent> component);
00086                 
00087                 
00088                 
00093                 bool init();
00094                 
00097                 void destroy();
00098 
00099                 
00100                 
00105                 void update(const double& dt);
00106 
00112                 virtual bool handleEvent(const Event& event) { return false; }
00113                 
00114                 
00115                 
00120                 boost::shared_ptr<GameObject> getSharedToThis() { return this->shared_from_this(); }
00121                 
00126                 const std::string& getID() const { return mID; }
00127                 
00132                 const GameObjectType& getType() const { return mType; }
00133                 
00138                 GameState* const getGameState() const { return mGameState; }
00139 
00140 
00141         protected:
00142                 GameObjectType mType; // Objects type
00143                 std::string mID; // Objects ID, must be unique
00144                 GameState* mGameState;
00145 
00146                 GameObjectComponentList mComponents; // Note to self: Should use a ProcessManager instead ? Component are already Process's so why not...
00147 
00148                 double mLifeTime;
00149                 double mTimeLived;
00150         };
00151 }
00152 
00153 #endif

Generated on Thu Apr 19 09:47:02 2007 for GameEngine by  doxygen 1.5.2