Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

GameState.cpp

Go to the documentation of this file.
00001 /*
00002 CS Senior Project 2003
00003 Team : Leftfield
00004 Project : ModernWarfare
00005 Members :
00006 - Russ Christensen              <rchriste@cs.utah.edu>
00007 - Todd Smith                    <tcsmith@cs.utah.edu>
00008 - Usit Duongsaa                 <duongsaa@cs.utah.edu>
00009 Copyright 2003 Russ Christensen, Usit Duongsaa, and Todd Smith. All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00012 
00013 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
00014 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
00015 THIS SOFTWARE IS PROVIDED BY RUSS CHRISTENSEN, USIT DUONGSAA, AND TODD SMITH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RUSS, USIT, TODD OR OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00016 */
00017 
00022 #include "GameState.h"
00023 
00024 vector<Player*>& GameState::players()
00025 {
00026         static vector<Player*> m_players;
00027         return m_players;
00028 }
00029 
00030 vector<MilitaryUnit*>& GameState::units()
00031 {
00032         static vector<MilitaryUnit*> m_units;
00033         return m_units;
00034 }
00035 
00036 vector<MilitaryUnit*>& GameState::selectedUnits()
00037 {
00038   static vector<MilitaryUnit*> m_selectedUnits;
00039   return m_selectedUnits;
00040 }
00041 
00042 vector<City*>& GameState::cities()
00043 {
00044         static vector<City*> m_cities;
00045         return m_cities;
00046 }
00047 
00048 vector<DrawableObject*>& GameState::drawables()
00049 {
00050         static vector<DrawableObject*> m_drawables;
00051         return m_drawables;
00052 }
00053 
00054 void GameState::addMilitaryUnit(MilitaryUnit* unit)
00055 {
00056         units().push_back(unit);
00057         drawables().push_back(unit);
00058 }
00059 
00060 MilitaryUnit* GameState::getMilitaryUnit(uint uniqueID)
00061 {
00063         for(vector<MilitaryUnit*>::iterator iter = units().begin(); iter != units().end(); ++iter)
00064         {
00065                 if((*iter)->uniqueID() == uniqueID) return *iter;
00066         }
00067         return 0;
00068 }
00069 
00070 void GameState::addCity(City* city)
00071 {
00072         cities().push_back(city);
00073         drawables().push_back(city);
00074 }
00075 
00076 City* GameState::getCity(uint uniqueID)
00077 {
00078         for(vector<City*>::iterator iter = cities().begin(); iter != cities().end(); ++iter)
00079         {
00080                 if ((*iter)->uniqueID() == uniqueID) return *iter;
00081         }
00082         return 0;
00083 }
00084 
00085 Player* GameState::findPlayer(const Vec3D& teamColor)
00086 {
00087         for(size_t i=0; i < players().size(); ++i)
00088                 if( players()[i]->color() == teamColor) return players()[i];
00089         return 0;
00090 }
00091 
00092 vector<BattleEntry*>& GameState::battles()
00093 {
00094         static vector<BattleEntry*> theBattles;
00095         return theBattles;
00096 }
00097 
00098 BattleEntry* GameState::getBattle(uint uniqueID)
00099 {
00100         for(vector<BattleEntry*>::iterator iter = battles().begin(); iter != battles().end(); ++iter)
00101         {
00102                 BattleEntry* battle = *iter;
00103                 if((*iter)->uniqueID() == uniqueID) return *iter;
00104         }
00105         return 0;
00106 }
00107 
00108 MessagesReceived& GameState::messagesReceived(void)
00109 {
00110         static MessagesReceived theMessagesReceived;
00111         return theMessagesReceived;
00112 }
00113 
00114 Vec3D& GameState::camTarget()
00115 {
00116   static Vec3D m_camTarget(0.0f, 0.0f, 0.0f);
00117   return m_camTarget;
00118 }
00119 
00120 
00121 BattleEntry* GameState::m_activeBattle;
00122 
00123 BattleEntry* GameState::activeBattle()
00124 {
00125   return m_activeBattle;
00126 }
00127 
00128 void GameState::setActiveBattle(BattleEntry* battle)
00129 {
00130   m_activeBattle = battle;
00131 }
00132 
00133 
00134 Map::WorldMap GameState::m_worldMap;
00135 
00136 void GameState::setWorldMap(const Map::WorldMap& map)
00137 {
00138   m_worldMap = map;
00139 }
00140 
00141 const Map::WorldMap& GameState::worldMap()
00142 {
00143   return m_worldMap;
00144 }
00145 
00146 
00147 Player* GameState::m_consolePlayer;
00148 
00149 Player* GameState::consolePlayer()
00150 {
00151   return m_consolePlayer;
00152 }
00153 
00154 void GameState::setConsolePlayer(Player* cp)
00155 {
00156   m_consolePlayer = cp;
00157 }
00158 
00159 ControlMode GameState::m_controlMode(NORMAL);
00160 
00161 ControlMode GameState::controlMode()
00162 { 
00163   return m_controlMode;
00164 }
00165 
00166 void GameState::setControlMode(ControlMode mode)
00167 {
00168   m_controlMode = mode;
00169 }
00170 
00171 vector<int>& GameState::availableRFM()
00172 {
00173         static vector<int> availableRFMVec;
00174         return availableRFMVec;
00175 }

Generated on Wed Apr 23 05:50:15 2003 for Modern Warfare by doxygen1.3-rc2