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

134 lines
3.1 KiB
C++
Raw Normal View History

#include "player.hpp"
#include "../mwbase/environment.hpp"
2013-04-04 09:23:17 +00:00
#include "../mwworld/ptr.hpp"
#include "../mwmechanics/movement.hpp"
#include "../mwmechanics/npcstats.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;
}
2013-04-04 09:23:17 +00:00
void Player::setCell (MWWorld::CellStore *cellStore)
{
mCellStore = cellStore;
}
MWWorld::Ptr Player::getPlayer()
{
MWWorld::Ptr ptr (&mPlayer, mCellStore);
return ptr;
}
void Player::setBirthSign (const std::string &sign)
{
mSign = sign;
}
const std::string& Player::getBirthSign() const
{
return mSign;
}
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
2013-04-04 09:23:17 +00:00
bool Player::getAutoMove() const
{
return mAutoMove;
}
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).mPosition[1] = value;
2011-02-03 11:16:59 +00:00
}
void Player::setLeftRight (int value)
{
MWWorld::Ptr ptr = getPlayer();
MWWorld::Class::get (ptr).getMovementSettings (ptr).mPosition[0] = value;
2011-02-03 11:16:59 +00:00
}
void Player::setForwardBackward (int value)
{
MWWorld::Ptr ptr = getPlayer();
mForwardBackward = value;
if (mAutoMove)
value = 1;
MWWorld::Class::get (ptr).getMovementSettings (ptr).mPosition[1] = value;
2011-02-03 11:16:59 +00:00
}
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).mPosition[2] = value;
}
2011-02-03 11:16:59 +00:00
2013-02-07 01:51:47 +00:00
void Player::setRunState(bool run)
{
MWWorld::Ptr ptr = getPlayer();
MWWorld::Class::get(ptr).setStance(ptr, MWWorld::Class::Run, run);
}
2013-03-06 15:58:56 +00:00
void Player::setSneak(bool sneak)
{
MWWorld::Ptr ptr = getPlayer();
MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Sneak, sneak);
}
void Player::setYaw(float yaw)
{
MWWorld::Ptr ptr = getPlayer();
MWWorld::Class::get(ptr).getMovementSettings(ptr).mRotation[2] = yaw;
}
void Player::setPitch(float pitch)
{
MWWorld::Ptr ptr = getPlayer();
MWWorld::Class::get(ptr).getMovementSettings(ptr).mRotation[0] = pitch;
}
void Player::setRoll(float roll)
{
MWWorld::Ptr ptr = getPlayer();
MWWorld::Class::get(ptr).getMovementSettings(ptr).mRotation[1] = roll;
}
2012-07-07 18:53:19 +00:00
MWMechanics::DrawState_ Player::getDrawState()
{
MWWorld::Ptr ptr = getPlayer();
return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState();
}
}