1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 06:39:42 +00:00

Derive sneaking state from character data

This commit is contained in:
Evil Eye 2022-09-03 16:29:24 +02:00
parent de83a41de6
commit 60491cc896
2 changed files with 8 additions and 5 deletions

View file

@ -37,7 +37,6 @@ namespace MWInput
, mScreenCaptureHandler(screenCaptureHandler)
, mScreenCaptureOperation(screenCaptureOperation)
, mAlwaysRunActive(Settings::Manager::getBool("always run", "Input"))
, mSneaking(false)
, mAttemptJump(false)
, mTimeIdle(0.f)
{
@ -535,15 +534,20 @@ namespace MWInput
Settings::Manager::setBool("always run", "Input", mAlwaysRunActive);
}
bool ActionManager::isSneaking() const
{
const MWBase::Environment& env = MWBase::Environment::get();
return env.getMechanicsManager()->isSneaking(env.getWorld()->getPlayer().getPlayer());
}
void ActionManager::toggleSneaking()
{
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
return;
if (!MWBase::Environment::get().getInputManager()->getControlSwitch("playercontrols"))
return;
mSneaking = !mSneaking;
MWWorld::Player& player = MWBase::Environment::get().getWorld()->getPlayer();
player.setSneak(mSneaking);
player.setSneak(!isSneaking());
}
void ActionManager::handleGuiArrowKey(int action)

View file

@ -49,7 +49,7 @@ namespace MWInput
float getIdleTime() const { return mTimeIdle; }
bool isAlwaysRunActive() const { return mAlwaysRunActive; }
bool isSneaking() const { return mSneaking; }
bool isSneaking() const;
void setAttemptJump(bool enabled) { mAttemptJump = enabled; }
@ -62,7 +62,6 @@ namespace MWInput
osgViewer::ScreenCaptureHandler::CaptureOperation* mScreenCaptureOperation;
bool mAlwaysRunActive;
bool mSneaking;
bool mAttemptJump;
float mTimeIdle;