00001 #include "TeamBuildings.h" 00002 #include "Game.h" 00003 00004 #include "Building.h" 00005 00006 #include "OgreSceneManager.h" 00007 #include "OgreStringConverter.h" 00008 #include "OgreException.h" 00009 #include "OgreEntity.h" 00010 #include "OgreRay.h" 00011 00012 using Ogre::SceneManager; 00013 using Ogre::RaySceneQueryResult; 00014 using Ogre::StringConverter; 00015 using Ogre::Exception; 00016 using Ogre::Ray; 00017 00018 00019 namespace ASR 00020 { 00021 int TeamBuildings::mNumTeams = 0; 00022 00023 // ---------------------------------------------------------------------------- 00024 TeamBuildings::TeamBuildings ( unsigned int initialBuildings ) 00025 { 00026 mNumTeams++; 00027 mTeamName = "team_buildings_" + StringConverter::toString ( mNumTeams ); 00028 00029 SceneManager* sceneMgr = Game::getSingletonPtr ()->getSceneManager (); 00030 mTeamNode = sceneMgr->getRootSceneNode()->createChildSceneNode( mTeamName ); 00031 00032 mBuildings.reserve ( initialBuildings ); 00033 } 00034 00035 00036 // ---------------------------------------------------------------------------- 00037 TeamBuildings::~TeamBuildings () 00038 { 00039 BuildingList::iterator iter = mBuildings.begin (); 00040 while ( iter != mBuildings.end() ) 00041 { 00042 delete (*iter); 00043 iter++; 00044 } 00045 } 00046 00047 00048 // ---------------------------------------------------------------------------- 00049 Building* TeamBuildings::createBuilding ( String meshName, Vector3 position ) 00050 { 00051 Building* newBuilding = new Building ( mTeamNode, meshName, position ); 00052 00053 mBuildings.push_back ( newBuilding ); 00054 00055 return newBuilding; 00056 } 00057 00058 00059 // ---------------------------------------------------------------------------- 00060 Building* TeamBuildings::getBuilding ( size_t index ) 00061 { 00062 if ( index >= mBuildings.size() ) 00063 throw Exception ( Exception::ERR_ITEM_NOT_FOUND, "Building index to high", "TeamBuildings::getBuilding" ); 00064 00065 return mBuildings[index]; 00066 } 00067 00068 00069 // ---------------------------------------------------------------------------- 00070 size_t TeamBuildings::getNumBuildings () 00071 { 00072 return mBuildings.size(); 00073 } 00074 }