mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 18:32:36 +00:00
Wrap up World::canRest() implementation by moving enemiesNearby() from InputManager::rest() to World::canRest().
This commit is contained in:
parent
7be9f2ca45
commit
c50ee22772
@ -438,12 +438,16 @@ namespace MWBase
|
||||
|
||||
virtual void enableActorCollision(const MWWorld::Ptr& actor, bool enable) = 0;
|
||||
|
||||
virtual int canRest() = 0;
|
||||
///< check if the player is allowed to rest \n
|
||||
/// 0 - yes \n
|
||||
/// 1 - only waiting \n
|
||||
/// 2 - player is underwater \n
|
||||
/// 3 - enemies are nearby (not implemented)
|
||||
enum RestPermitted
|
||||
{
|
||||
Rest_Allowed = 0,
|
||||
Rest_OnlyWaiting = 1,
|
||||
Rest_PlayerIsUnderwater = 2,
|
||||
Rest_EnemiesAreNearby = 3
|
||||
};
|
||||
|
||||
virtual RestPermitted canRest() = 0;
|
||||
///< check if the player is allowed to rest
|
||||
|
||||
/// \todo Probably shouldn't be here
|
||||
virtual MWRender::Animation* getAnimation(const MWWorld::Ptr &ptr) = 0;
|
||||
|
@ -83,7 +83,7 @@ namespace MWGui
|
||||
|
||||
void WaitDialog::setPtr(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
setCanRest(!ptr.isEmpty() || MWBase::Environment::get().getWorld ()->canRest () == 0);
|
||||
setCanRest(!ptr.isEmpty() || MWBase::Environment::get().getWorld ()->canRest () == MWBase::World::Rest_Allowed);
|
||||
|
||||
if (mUntilHealedButton->getVisible())
|
||||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mUntilHealedButton);
|
||||
@ -120,9 +120,14 @@ namespace MWGui
|
||||
MWBase::Environment::get().getWindowManager()->popGuiMode ();
|
||||
}
|
||||
|
||||
int canRest = MWBase::Environment::get().getWorld ()->canRest ();
|
||||
MWBase::World::RestPermitted canRest = MWBase::Environment::get().getWorld ()->canRest ();
|
||||
|
||||
if (canRest == 2)
|
||||
if (canRest == MWBase::World::Rest_EnemiesAreNearby)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage2}");
|
||||
MWBase::Environment::get().getWindowManager()->popGuiMode ();
|
||||
}
|
||||
else if (canRest == MWBase::World::Rest_PlayerIsUnderwater)
|
||||
{
|
||||
// resting underwater or mid-air not allowed
|
||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage1}");
|
||||
|
@ -1029,10 +1029,6 @@ namespace MWInput
|
||||
if (!MWBase::Environment::get().getWindowManager()->getRestEnabled () || MWBase::Environment::get().getWindowManager()->isGuiMode ())
|
||||
return;
|
||||
|
||||
if(mPlayer->enemiesNearby()) {//Check if in combat
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage2}"); //Nope,
|
||||
return;
|
||||
}
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_Rest); //Open rest GUI
|
||||
|
||||
}
|
||||
|
@ -2297,7 +2297,7 @@ namespace MWWorld
|
||||
applyLoopingParticles(player);
|
||||
}
|
||||
|
||||
int World::canRest ()
|
||||
World::RestPermitted World::canRest ()
|
||||
{
|
||||
CellStore *currentCell = mWorldScene->getCurrentCell();
|
||||
|
||||
@ -2309,13 +2309,16 @@ namespace MWWorld
|
||||
if (!actor)
|
||||
throw std::runtime_error("can't find player");
|
||||
|
||||
if(mPlayer->enemiesNearby())
|
||||
return Rest_EnemiesAreNearby;
|
||||
|
||||
if ((actor->getCollisionMode() && !mPhysics->isOnSolidGround(player)) || isUnderwater(currentCell, playerPos) || isWalkingOnWater(player))
|
||||
return 2;
|
||||
return Rest_PlayerIsUnderwater;
|
||||
|
||||
if((currentCell->getCell()->mData.mFlags&ESM::Cell::NoSleep) || player.getClass().getNpcStats(player).isWerewolf())
|
||||
return 1;
|
||||
return Rest_OnlyWaiting;
|
||||
|
||||
return 0;
|
||||
return Rest_Allowed;
|
||||
}
|
||||
|
||||
MWRender::Animation* World::getAnimation(const MWWorld::Ptr &ptr)
|
||||
|
@ -551,7 +551,7 @@ namespace MWWorld
|
||||
|
||||
void enableActorCollision(const MWWorld::Ptr& actor, bool enable) override;
|
||||
|
||||
int canRest() override;
|
||||
World::RestPermitted canRest() override;
|
||||
///< check if the player is allowed to rest \n
|
||||
/// 0 - yes \n
|
||||
/// 1 - only waiting \n
|
||||
|
Loading…
x
Reference in New Issue
Block a user