2017-04-08 05:59:21 +00:00
|
|
|
#include <components/openmw-mp/Log.hpp>
|
|
|
|
|
2017-04-06 12:11:51 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwmechanics/movement.hpp"
|
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
|
|
|
#include "../mwrender/animation.hpp"
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
#include "../mwworld/worldimp.hpp"
|
2017-04-06 01:00:50 +00:00
|
|
|
|
2017-04-05 09:52:27 +00:00
|
|
|
#include "LocalActor.hpp"
|
2017-04-10 14:10:18 +00:00
|
|
|
#include "Main.hpp"
|
|
|
|
#include "Networking.hpp"
|
|
|
|
#include "ActorList.hpp"
|
2017-04-05 09:52:27 +00:00
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
LocalActor::LocalActor()
|
|
|
|
{
|
2017-04-10 14:10:18 +00:00
|
|
|
posWasChanged = false;
|
2017-04-05 09:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LocalActor::~LocalActor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-04-10 14:10:18 +00:00
|
|
|
void LocalActor::update(bool forceUpdate)
|
2017-04-05 09:52:27 +00:00
|
|
|
{
|
2017-04-10 14:10:18 +00:00
|
|
|
updatePosition(forceUpdate);
|
2017-04-06 12:11:51 +00:00
|
|
|
updateDrawState();
|
|
|
|
}
|
|
|
|
|
2017-04-10 14:10:18 +00:00
|
|
|
void LocalActor::updatePosition(bool forceUpdate)
|
2017-04-06 12:11:51 +00:00
|
|
|
{
|
2017-04-10 14:10:18 +00:00
|
|
|
bool posIsChanging = (direction.pos[0] != 0 || direction.pos[1] != 0 || direction.pos[2] != 0 ||
|
|
|
|
direction.rot[0] != 0 || direction.rot[1] != 0 || direction.rot[2] != 0);
|
|
|
|
|
2017-04-10 15:24:30 +00:00
|
|
|
if (posIsChanging || posWasChanged || forceUpdate)
|
2017-04-10 14:10:18 +00:00
|
|
|
{
|
|
|
|
posWasChanged = posIsChanging;
|
|
|
|
|
|
|
|
position = ptr.getRefData().getPosition();
|
|
|
|
|
|
|
|
ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList();
|
|
|
|
actorList->addPositionActor(*this);
|
|
|
|
}
|
2017-04-06 12:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LocalActor::updateDrawState()
|
|
|
|
{
|
|
|
|
drawState = ptr.getClass().getNpcStats(ptr).getDrawState();
|
|
|
|
}
|
|
|
|
|
2017-04-06 01:00:50 +00:00
|
|
|
MWWorld::Ptr LocalActor::getPtr()
|
|
|
|
{
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LocalActor::setPtr(const MWWorld::Ptr& newPtr)
|
|
|
|
{
|
|
|
|
ptr = newPtr;
|
2017-04-10 04:22:03 +00:00
|
|
|
|
|
|
|
refId = newPtr.getCellRef().getRefId();
|
|
|
|
refNumIndex = newPtr.getCellRef().getRefNum().mIndex;
|
|
|
|
mpNum = newPtr.getCellRef().getMpNum();
|
2017-04-06 01:00:50 +00:00
|
|
|
}
|