00001 //----------------------------------------------------------------------------------- 00002 // 00003 // Pro-Vocation Light Engine (PVLE) 00004 // Copyright (C) 2007-2009 Sukender, KinoX & Buzib 00005 // For more information, contact us : sukender@free.fr 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 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // For any use that is not compatible with the terms of the GNU 00013 // General Public License, please contact the authors for alternative 00014 // licensing options. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License along 00022 // with this program; if not, write to the Free Software Foundation, Inc., 00023 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00024 // 00025 //----------------------------------------------------------------------------------- 00026 00027 #ifndef GAME_PVLE_GAME_H 00028 #define GAME_PVLE_GAME_H 00029 00030 #include <PVLE/Export.h> 00031 #include <PVLE/Game/PVLEPlayer.h> 00032 #include <PVLE/Game/PVLETeam.h> 00033 #include <PVLE/Entity/3DPhy.h> 00034 #include <PVLE/Util/Assert.h> 00035 00038 class /*PVLE_EXPORT*/ PVLEGame : public C3DPhyOwner { 00039 public: 00040 PVLEGame(osg::Group * pParentGroup, Physics::Space * pParentSpace) : C3DPhyOwner(pParentGroup, pParentSpace), friendlyFire(1.f) {} 00041 00043 virtual C3DPhy * create3DPhy(const std::string & name) { return new C3DPhy(); } 00044 00048 00049 float getFriendlyFire() const { return friendlyFire; } 00050 void setFriendlyFire(float value) { ASSERT(value >= 0); friendlyFire = value; /*setMaskBits(DATA_CHANGED);*/ } 00051 00052 00055 00056 void addTeam(PVLETeam * pTeam) { pTeam->pGame = this; vTeamsList.push_back(pTeam); } 00057 //void removeTeam(PVLETeam * pTeam) { if deleted, set pTeam->pGame = NULL; } 00058 PVLETeam * getTeam(UINT index) { return vTeamsList[index].get(); } 00059 const PVLETeam * getTeam(UINT index) const { return vTeamsList[index].get(); } 00060 UINT getNbTeams() { return vTeamsList.size(); } 00062 00063 protected: 00064 float friendlyFire; 00065 std::vector<osg::ref_ptr<PVLETeam> > vTeamsList; 00066 }; 00067 00068 00069 00070 #include <boost/cast.hpp> 00071 00073 class /*PVLE_EXPORT*/ PVLEGameHolder : public Util::Singleton<PVLEGameHolder> { 00074 public: 00075 PVLEGame * get() { return pGame; } 00076 00078 template<class T> 00079 T * get() { return boost::polymorphic_downcast<T *>(pGame); } 00080 00084 void setCurrentGame(PVLEGame * pGame) { this->pGame = pGame; } 00085 00086 protected: 00087 PVLEGame * pGame; 00088 }; 00089 00090 00091 #endif // GAME_PVLE_GAME_H