1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 03:39:14 +00:00
OpenMW/apps/openmw/mwworld/player.cpp

89 lines
2.1 KiB
C++
Raw Normal View History

#include "player.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwmechanics/movement.hpp"
#include "../mwmechanics/npcstats.hpp"
2012-10-01 15:17:04 +00:00
#include "esmstore.hpp"
2011-02-03 11:16:59 +00:00
#include "class.hpp"
namespace MWWorld
{
2012-11-07 21:36:43 +00:00
Player::Player (const ESM::NPC *player, const MWBase::World& world)
: mCellStore(0),
mAutoMove(false),
mForwardBackward (0)
{
2012-11-05 12:07:59 +00:00
mPlayer.mBase = player;
mPlayer.mRef.mRefID = "player";
float* playerPos = mPlayer.mData.getPosition().pos;
playerPos[0] = playerPos[1] = playerPos[2] = 0;
}
2012-07-07 18:53:19 +00:00
void Player::setDrawState (MWMechanics::DrawState_ state)
{
MWWorld::Ptr ptr = getPlayer();
MWWorld::Class::get(ptr).getNpcStats(ptr).setDrawState (state);
}
2012-04-08 11:17:16 +00:00
2011-02-03 11:16:59 +00:00
void Player::setAutoMove (bool enable)
{
MWWorld::Ptr ptr = getPlayer();
mAutoMove = enable;
int value = mForwardBackward;
if (mAutoMove)
value = 1;
MWWorld::Class::get (ptr).getMovementSettings (ptr).mForwardBackward = value;
}
void Player::setLeftRight (int value)
{
MWWorld::Ptr ptr = getPlayer();
MWWorld::Class::get (ptr).getMovementSettings (ptr).mLeftRight = value;
}
void Player::setForwardBackward (int value)
{
MWWorld::Ptr ptr = getPlayer();
mForwardBackward = value;
if (mAutoMove)
value = 1;
MWWorld::Class::get (ptr).getMovementSettings (ptr).mForwardBackward = value;
}
2012-03-25 02:03:08 +00:00
void Player::setUpDown(int value)
{
MWWorld::Ptr ptr = getPlayer();
2012-03-25 02:03:08 +00:00
MWWorld::Class::get (ptr).getMovementSettings (ptr).mUpDown = value;
}
2011-02-03 11:16:59 +00:00
void Player::toggleRunning()
{
MWWorld::Ptr ptr = getPlayer();
bool running = MWWorld::Class::get (ptr).getStance (ptr, MWWorld::Class::Run, true);
MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running);
}
2012-07-07 18:53:19 +00:00
MWMechanics::DrawState_ Player::getDrawState()
{
MWWorld::Ptr ptr = getPlayer();
return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState();
}
}