2010-08-21 10:41:59 +00:00
|
|
|
|
2011-01-04 14:58:22 +00:00
|
|
|
#include "player.hpp"
|
2010-08-21 10:41:59 +00:00
|
|
|
|
2012-07-03 10:30:50 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
2013-05-19 16:40:37 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2013-05-19 17:48:51 +00:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
2013-04-04 09:23:17 +00:00
|
|
|
|
|
|
|
#include "../mwworld/ptr.hpp"
|
2013-05-19 16:40:37 +00:00
|
|
|
#include "../mwworld/inventorystore.hpp"
|
2012-07-03 10:30:50 +00:00
|
|
|
|
2012-01-27 12:17:30 +00:00
|
|
|
#include "../mwmechanics/movement.hpp"
|
2012-04-08 17:43:04 +00:00
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
2012-01-27 12:17:30 +00:00
|
|
|
|
2011-02-03 11:16:59 +00:00
|
|
|
#include "class.hpp"
|
2010-08-21 10:41:59 +00:00
|
|
|
|
2011-01-04 14:58:22 +00:00
|
|
|
namespace MWWorld
|
2010-08-21 10:41:59 +00:00
|
|
|
{
|
2012-11-07 21:36:43 +00:00
|
|
|
Player::Player (const ESM::NPC *player, const MWBase::World& world)
|
|
|
|
: mCellStore(0),
|
|
|
|
mAutoMove(false),
|
|
|
|
mForwardBackward (0)
|
2010-09-15 12:33:02 +00:00
|
|
|
{
|
2012-11-05 12:07:59 +00:00
|
|
|
mPlayer.mBase = player;
|
|
|
|
mPlayer.mRef.mRefID = "player";
|
2011-11-08 00:08:00 +00:00
|
|
|
|
|
|
|
float* playerPos = mPlayer.mData.getPosition().pos;
|
|
|
|
playerPos[0] = playerPos[1] = playerPos[2] = 0;
|
2010-09-15 12:33:02 +00:00
|
|
|
}
|
|
|
|
|
2013-05-15 15:54:18 +00:00
|
|
|
void Player::set(const ESM::NPC *player)
|
|
|
|
{
|
|
|
|
mPlayer.mBase = 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)
|
2012-04-08 10:25:33 +00:00
|
|
|
{
|
2012-04-08 17:43:04 +00:00
|
|
|
MWWorld::Ptr ptr = getPlayer();
|
2012-07-06 13:50:26 +00:00
|
|
|
MWWorld::Class::get(ptr).getNpcStats(ptr).setDrawState (state);
|
2012-04-08 10:25:33 +00:00
|
|
|
}
|
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;
|
|
|
|
|
2013-03-31 02:00:46 +00:00
|
|
|
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();
|
|
|
|
|
2013-03-31 02:00:46 +00:00
|
|
|
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;
|
|
|
|
|
2013-03-31 02:00:46 +00:00
|
|
|
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
|
|
|
|
2012-07-03 10:30:50 +00:00
|
|
|
void Player::setUpDown(int value)
|
|
|
|
{
|
|
|
|
MWWorld::Ptr ptr = getPlayer();
|
2012-03-25 02:03:08 +00:00
|
|
|
|
2013-03-31 02:00:46 +00:00
|
|
|
MWWorld::Class::get (ptr).getMovementSettings (ptr).mPosition[2] = value;
|
2012-07-03 10:30:50 +00:00
|
|
|
}
|
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);
|
2013-08-03 00:46:26 +00:00
|
|
|
|
|
|
|
// TODO show sneak indicator only when the player is not detected by any actor
|
|
|
|
MWBase::Environment::get().getWindowManager()->setSneakVisibility(sneak);
|
2013-03-06 15:58:56 +00:00
|
|
|
}
|
|
|
|
|
2013-06-12 14:07:46 +00:00
|
|
|
void Player::yaw(float yaw)
|
2013-03-31 09:57:22 +00:00
|
|
|
{
|
|
|
|
MWWorld::Ptr ptr = getPlayer();
|
2013-06-12 14:07:46 +00:00
|
|
|
MWWorld::Class::get(ptr).getMovementSettings(ptr).mRotation[2] += yaw;
|
2013-03-31 09:57:22 +00:00
|
|
|
}
|
2013-06-12 14:07:46 +00:00
|
|
|
void Player::pitch(float pitch)
|
2013-03-31 09:57:22 +00:00
|
|
|
{
|
|
|
|
MWWorld::Ptr ptr = getPlayer();
|
2013-06-12 14:07:46 +00:00
|
|
|
MWWorld::Class::get(ptr).getMovementSettings(ptr).mRotation[0] += pitch;
|
2013-03-31 09:57:22 +00:00
|
|
|
}
|
2013-06-12 14:07:46 +00:00
|
|
|
void Player::roll(float roll)
|
2013-03-31 09:57:22 +00:00
|
|
|
{
|
|
|
|
MWWorld::Ptr ptr = getPlayer();
|
2013-06-12 14:07:46 +00:00
|
|
|
MWWorld::Class::get(ptr).getMovementSettings(ptr).mRotation[1] += roll;
|
2013-03-31 09:57:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-07 18:53:19 +00:00
|
|
|
MWMechanics::DrawState_ Player::getDrawState()
|
2012-04-08 17:43:04 +00:00
|
|
|
{
|
|
|
|
MWWorld::Ptr ptr = getPlayer();
|
2012-07-06 13:50:26 +00:00
|
|
|
return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState();
|
2012-04-08 17:43:04 +00:00
|
|
|
}
|
2010-08-21 10:41:59 +00:00
|
|
|
}
|