flag game as ended when player dies

This commit is contained in:
Marc Zinnschlag 2013-11-18 15:38:08 +01:00
parent 82c8495338
commit f45cff8aff
4 changed files with 24 additions and 10 deletions

View file

@ -39,6 +39,8 @@ namespace MWBase
///< Start a new game. ///< Start a new game.
/// ///
/// \param bypass Skip new game mechanics. /// \param bypass Skip new game mechanics.
virtual void endGame() = 0;
}; };
} }

View file

@ -17,6 +17,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/statemanager.hpp"
#include "npcstats.hpp" #include "npcstats.hpp"
#include "creaturestats.hpp" #include "creaturestats.hpp"
@ -344,9 +345,10 @@ namespace MWMechanics
continue; continue;
} }
if (iter->first.getRefData().getHandle()=="player")
{
// If it's the player and God Mode is turned on, keep it alive // If it's the player and God Mode is turned on, keep it alive
if(iter->first.getRefData().getHandle()=="player" && if (MWBase::Environment::get().getWorld()->getGodModeState())
MWBase::Environment::get().getWorld()->getGodModeState())
{ {
MWMechanics::DynamicStat<float> stat (stats.getHealth()); MWMechanics::DynamicStat<float> stat (stats.getHealth());
@ -360,6 +362,9 @@ namespace MWMechanics
continue; continue;
} }
MWBase::Environment::get().getStateManager()->endGame();
}
if(iter->second->isDead()) if(iter->second->isDead())
continue; continue;

View file

@ -46,3 +46,8 @@ void MWState::StateManager::newGame (bool bypass)
mState = State_Running; mState = State_Running;
} }
void MWState::StateManager::endGame()
{
mState = State_Ended;
}

View file

@ -24,6 +24,8 @@ namespace MWState
///< Start a new game. ///< Start a new game.
/// ///
/// \param bypass Skip new game mechanics. /// \param bypass Skip new game mechanics.
virtual void endGame();
}; };
} }