2011-01-04 14:58:22 +00:00
|
|
|
#ifndef GAME_MWWORLD_PLAYER_H
|
|
|
|
#define GAME_MWWORLD_PLAYER_H
|
2010-06-21 21:39:59 +00:00
|
|
|
|
|
|
|
#include "OgreCamera.h"
|
|
|
|
|
2010-07-05 10:09:04 +00:00
|
|
|
#include <components/esm_store/cell_store.hpp>
|
|
|
|
|
|
|
|
#include "../mwworld/refdata.hpp"
|
2010-07-26 10:59:50 +00:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2010-07-05 10:09:04 +00:00
|
|
|
|
2011-01-08 14:11:37 +00:00
|
|
|
namespace MWRender
|
2010-08-21 10:31:04 +00:00
|
|
|
{
|
2011-01-08 14:11:37 +00:00
|
|
|
class Player;
|
2010-08-21 10:31:04 +00:00
|
|
|
}
|
|
|
|
|
2011-01-04 14:58:22 +00:00
|
|
|
namespace MWWorld
|
2010-06-21 21:39:59 +00:00
|
|
|
{
|
2011-01-08 14:11:37 +00:00
|
|
|
class World;
|
|
|
|
|
|
|
|
/// \brief NPC object representing the player and additional player data
|
2011-01-06 09:07:01 +00:00
|
|
|
class Player
|
2010-07-26 10:59:50 +00:00
|
|
|
{
|
2011-01-06 09:07:01 +00:00
|
|
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> mPlayer;
|
|
|
|
MWWorld::Ptr::CellStore *mCellStore;
|
2011-01-08 14:11:37 +00:00
|
|
|
MWRender::Player *mRenderer;
|
2011-01-06 09:07:01 +00:00
|
|
|
MWWorld::World& mWorld;
|
|
|
|
std::string mName;
|
|
|
|
bool mMale;
|
|
|
|
std::string mRace;
|
|
|
|
std::string mBirthsign;
|
|
|
|
ESM::Class *mClass;
|
2011-01-09 19:38:58 +00:00
|
|
|
bool mCollisionMode;
|
2010-06-21 21:39:59 +00:00
|
|
|
|
2011-01-14 14:52:28 +00:00
|
|
|
bool mAutoMove;
|
2011-01-16 15:47:03 +00:00
|
|
|
bool misWalking; //Testing...
|
2011-01-14 14:52:28 +00:00
|
|
|
|
2011-01-06 09:07:01 +00:00
|
|
|
public:
|
2010-06-22 08:15:22 +00:00
|
|
|
|
2011-01-08 14:11:37 +00:00
|
|
|
Player(MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world);
|
2010-06-21 21:39:59 +00:00
|
|
|
|
2011-01-06 09:07:01 +00:00
|
|
|
~Player();
|
2010-06-21 21:39:59 +00:00
|
|
|
|
2011-01-06 09:07:01 +00:00
|
|
|
/// Set the player position. Uses Morrowind coordinates.
|
|
|
|
void setPos(float _x, float _y, float _z, bool updateCamera = false);
|
2010-06-21 21:39:59 +00:00
|
|
|
|
2011-01-06 09:07:01 +00:00
|
|
|
void setCell (MWWorld::Ptr::CellStore *cellStore)
|
|
|
|
{
|
|
|
|
mCellStore = cellStore;
|
|
|
|
}
|
2010-06-21 21:39:59 +00:00
|
|
|
|
2011-01-06 09:07:01 +00:00
|
|
|
/// Move the player relative to her own position and
|
|
|
|
/// orientation. After the call, the new position is returned.
|
|
|
|
void moveRel (float &relX, float &relY, float &relZ);
|
2010-08-20 15:14:07 +00:00
|
|
|
|
2010-07-26 11:09:44 +00:00
|
|
|
MWWorld::Ptr getPlayer()
|
2010-07-05 10:09:04 +00:00
|
|
|
{
|
2010-07-26 11:09:44 +00:00
|
|
|
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
|
|
|
return ptr;
|
2010-07-05 10:09:04 +00:00
|
|
|
}
|
2010-09-15 10:22:06 +00:00
|
|
|
|
2011-01-08 14:11:37 +00:00
|
|
|
MWRender::Player *getRenderer() { return mRenderer; }
|
|
|
|
|
2010-09-15 10:22:06 +00:00
|
|
|
void setName (const std::string& name)
|
|
|
|
{
|
|
|
|
mName = name;
|
|
|
|
}
|
|
|
|
|
2010-09-15 12:33:02 +00:00
|
|
|
void setGender (bool male)
|
|
|
|
{
|
|
|
|
mMale = male;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setRace (const std::string& race)
|
|
|
|
{
|
|
|
|
mRace = race;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setBirthsign (const std::string& birthsign)
|
|
|
|
{
|
|
|
|
mBirthsign = birthsign;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setClass (const ESM::Class& class_);
|
|
|
|
|
2010-09-15 10:22:06 +00:00
|
|
|
std::string getName() const
|
|
|
|
{
|
|
|
|
return mName;
|
|
|
|
}
|
2010-09-15 12:33:02 +00:00
|
|
|
|
|
|
|
bool isMale() const
|
|
|
|
{
|
|
|
|
return mMale;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getRace() const
|
|
|
|
{
|
|
|
|
return mRace;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getBirthsign() const
|
|
|
|
{
|
|
|
|
return mBirthsign;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ESM::Class& getClass() const
|
|
|
|
{
|
|
|
|
return *mClass;
|
|
|
|
}
|
2011-01-09 19:38:58 +00:00
|
|
|
|
2011-01-09 20:07:27 +00:00
|
|
|
void toggleCollisionMode()
|
2011-01-09 19:38:58 +00:00
|
|
|
{
|
2011-01-09 20:07:27 +00:00
|
|
|
mCollisionMode = !mCollisionMode;
|
2011-01-09 19:38:58 +00:00
|
|
|
}
|
2011-01-14 14:52:28 +00:00
|
|
|
|
2011-01-18 05:16:01 +00:00
|
|
|
bool getAutoMove()
|
2011-01-14 14:52:28 +00:00
|
|
|
{
|
|
|
|
return mAutoMove;
|
2011-01-17 20:48:12 +00:00
|
|
|
}
|
2011-01-14 14:52:28 +00:00
|
|
|
|
2011-01-18 05:16:01 +00:00
|
|
|
void setAutoMove(bool setMe)
|
2011-01-17 20:48:12 +00:00
|
|
|
{
|
|
|
|
mAutoMove = setMe;
|
|
|
|
}
|
|
|
|
|
|
|
|
//NOTE: we don't have speed being calculated yet, so for now this function only requires a frame duration.
|
2011-01-14 14:52:28 +00:00
|
|
|
/// <param name="duration">float value representing time since last call</param>
|
2011-01-17 20:48:12 +00:00
|
|
|
void executeAutoMove(float duration)
|
2011-01-14 14:52:28 +00:00
|
|
|
{
|
2011-01-17 21:36:44 +00:00
|
|
|
float X_Val = 0.0f;
|
|
|
|
float Y_Val = 0.0f;
|
|
|
|
float Z_Val = 300.0f * duration * -1.0f;
|
2011-01-17 20:48:12 +00:00
|
|
|
if (mAutoMove == true)
|
2011-01-16 16:05:03 +00:00
|
|
|
{
|
2011-01-17 20:48:12 +00:00
|
|
|
//if player is running
|
|
|
|
//Make player go at full speed
|
2011-01-17 21:36:44 +00:00
|
|
|
moveRel(X_Val, Y_Val, Z_Val);
|
2011-01-17 20:48:12 +00:00
|
|
|
//else go forward at walk speed.
|
|
|
|
}
|
2011-01-14 14:52:28 +00:00
|
|
|
}
|
|
|
|
|
2011-01-18 05:16:01 +00:00
|
|
|
bool getisWalking()
|
2011-01-16 15:47:03 +00:00
|
|
|
{
|
2011-01-16 18:45:54 +00:00
|
|
|
return misWalking;
|
2011-01-16 15:47:03 +00:00
|
|
|
}
|
|
|
|
|
2011-01-18 05:16:01 +00:00
|
|
|
void setisWalking(bool setMe)
|
2011-01-16 15:47:03 +00:00
|
|
|
{
|
2011-01-16 18:45:54 +00:00
|
|
|
misWalking = setMe;
|
2011-01-16 15:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 14:52:28 +00:00
|
|
|
|
2010-06-21 21:39:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|