//-------------------------------- Update ------------------------------------- // // calls the update function of each entity //----------------------------------------------------------------------------- void Raven_Game::Update() { //don't update if the user has paused the game if (m_bPaused) return; m_pGraveMarkers->Update(); //get any player keyboard input GetPlayerInput(); //update all the queued searches in the path manager m_pPathManager->UpdateSearches(); //update any doors std::vector<Raven_Door*>::iterator curDoor =m_pMap->GetDoors().begin(); for (curDoor; curDoor != m_pMap->GetDoors().end(); ++curDoor) { (*curDoor)->Update(); } //update any current projectiles std::list<Raven_Projectile*>::iterator curW = m_Projectiles.begin(); while (curW != m_Projectiles.end()) { //test for any dead projectiles and remove them if necessary if (!(*curW)->isDead()) { (*curW)->Update(); ++curW; } else { delete *curW; curW = m_Projectiles.erase(curW); } } //update the bots bool bSpawnPossible = true; std::list<Raven_Bot*>::iterator curBot = m_Bots.begin(); for (curBot; curBot != m_Bots.end(); ++curBot) { //if this bot's status is 'respawning' attempt to resurrect it from //an unoccupied spawn point if ((*curBot)->isSpawning() && bSpawnPossible) { bSpawnPossible = AttemptToAddBot(*curBot); } //if this bot's status is 'dead' add a grave at its current location //then change its status to 'respawning' else if ((*curBot)->isDead()) { //create a grave GraveMarkers::GraveRecord grave = m_pGraveMarkers->AddGrave((*curBot)->Pos(), (*curBot)->GetTeamId(), (*curBot)->GetWeaponSys()->GetCurrentWeaponId()); GraveMarkers::GraveRecord* gravePtr = ` if ((*curBot)->GetWeaponSys()->GetCurrentWeaponId() != 0) { GetMap()->AddTeam_Giver((*curBot)->GetTeamId(), (*curBot)->GetWeaponSys()->GetCurrentWeaponId(), (*curBot)->Pos(), (*curBot)->GetPathPlanner()->GetClosestNodeToPosition((*curBot)->Pos()), grave); } std::list<Raven_Bot*>::iterator curBot2 = m_Bots.begin(); for (curBot2; curBot2 != m_Bots.end(); ++curBot2) { //send a message to all my team if ((*curBot2)->GetTeamId() == (*curBot)->GetTeamId()) { Dispatcher->DispatchMsg(SEND_MSG_IMMEDIATELY, (*curBot)->ID(), (*curBot2)->ID(), Msg_IWasKilledAndIHadWeapons, (void*)gravePtr); //debug_con << "Bot " << ttos((*curBot)->ID()) << " : I'm dead : team (" << ttos(gravePtr->teamId) << ") "; } } //change its status to spawning (*curBot)->SetSpawning(); } //if this bot is alive update it. else if ( (*curBot)->isAlive()) { (*curBot)->Update(); } } //update the triggers m_pMap->UpdateTriggerSystem(m_Bots); //if the user has requested that the number of bots be decreased, remove //one if (m_bRemoveABot) { if (!m_Bots.empty()) { Raven_Bot* pBot = m_Bots.back(); if (pBot == m_pSelectedBot)m_pSelectedBot=0; NotifyAllBotsOfRemoval(pBot); delete m_Bots.back(); m_Bots.remove(pBot); pBot = 0; } m_bRemoveABot = false; } }
//-------------------------------- Update ------------------------------------- // // calls the update function of each entity //----------------------------------------------------------------------------- void Raven_Game::Update() { //don't update if the user has paused the game if (m_bPaused) return; m_pGraveMarkers->Update(); //get any player keyboard input GetPlayerInput(); //update all the queued searches in the path manager m_pPathManager->UpdateSearches(); //update any doors std::vector<Raven_Door*>::iterator curDoor =m_pMap->GetDoors().begin(); for (curDoor; curDoor != m_pMap->GetDoors().end(); ++curDoor) { (*curDoor)->Update(); } //update any current projectiles std::list<Raven_Projectile*>::iterator curW = m_Projectiles.begin(); while (curW != m_Projectiles.end()) { //test for any dead projectiles and remove them if necessary if (!(*curW)->isDead()) { (*curW)->Update(); ++curW; } else { delete *curW; curW = m_Projectiles.erase(curW); } } //update the bots bool bSpawnPossible = true; std::list<Raven_Bot*>::iterator curBot = m_Bots.begin(); for (curBot; curBot != m_Bots.end(); ++curBot) { //if this bot's status is 'respawning' attempt to resurrect it from //an unoccupied spawn point if ((*curBot)->isSpawning() && bSpawnPossible) { bSpawnPossible = AttemptToAddBot(*curBot); } //if this bot's status is 'dead' add a grave at its current location //then change its status to 'respawning' else if ((*curBot)->isDead()) { //create a grave m_pGraveMarkers->AddGrave((*curBot)->Pos()); //change its status to spawning (*curBot)->SetSpawning(); } //if this bot is alive update it. else if ( (*curBot)->isAlive()) { (*curBot)->Update(); } } //update the triggers m_pMap->UpdateTriggerSystem(m_Bots); //if the user has requested that the number of bots be decreased, remove //one if (m_bRemoveABot) { if (!m_Bots.empty()) { Raven_Bot* pBot = m_Bots.back(); if (pBot == m_pSelectedBot)m_pSelectedBot=0; NotifyAllBotsOfRemoval(pBot); delete m_Bots.back(); m_Bots.remove(pBot); pBot = 0; } m_bRemoveABot = false; } }