|
|
|
@ -2,7 +2,6 @@
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
#include "../mwmechanics/movement.hpp"
|
|
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
|
|
|
|
#include "../mwrender/animation.hpp"
|
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
|
#include "../mwworld/worldimp.hpp"
|
|
|
|
@ -18,6 +17,14 @@ using namespace std;
|
|
|
|
|
LocalActor::LocalActor()
|
|
|
|
|
{
|
|
|
|
|
posWasChanged = false;
|
|
|
|
|
|
|
|
|
|
wasRunning = false;
|
|
|
|
|
wasSneaking = false;
|
|
|
|
|
wasForceJumping = false;
|
|
|
|
|
wasForceMoveJumping = false;
|
|
|
|
|
|
|
|
|
|
wasJumping = false;
|
|
|
|
|
wasFlying = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocalActor::~LocalActor()
|
|
|
|
@ -28,7 +35,7 @@ LocalActor::~LocalActor()
|
|
|
|
|
void LocalActor::update(bool forceUpdate)
|
|
|
|
|
{
|
|
|
|
|
updatePosition(forceUpdate);
|
|
|
|
|
updateDrawState();
|
|
|
|
|
updateDrawStateAndFlags(forceUpdate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocalActor::updatePosition(bool forceUpdate)
|
|
|
|
@ -42,14 +49,66 @@ void LocalActor::updatePosition(bool forceUpdate)
|
|
|
|
|
|
|
|
|
|
position = ptr.getRefData().getPosition();
|
|
|
|
|
|
|
|
|
|
ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList();
|
|
|
|
|
actorList->addPositionActor(*this);
|
|
|
|
|
mwmp::Main::get().getNetworking()->getActorList()->addPositionActor(*this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocalActor::updateDrawState()
|
|
|
|
|
void LocalActor::updateDrawStateAndFlags(bool forceUpdate)
|
|
|
|
|
{
|
|
|
|
|
drawState = ptr.getClass().getNpcStats(ptr).getDrawState();
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
MWMechanics::NpcStats ptrNpcStats = ptr.getClass().getNpcStats(ptr);
|
|
|
|
|
|
|
|
|
|
using namespace MWMechanics;
|
|
|
|
|
|
|
|
|
|
bool isRunning = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Run);
|
|
|
|
|
bool isSneaking = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Sneak);
|
|
|
|
|
bool isForceJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceJump);
|
|
|
|
|
bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
|
|
|
|
|
|
|
|
|
|
isFlying = world->isFlying(ptr);
|
|
|
|
|
bool isJumping = ptr.getRefData().isEnabled() && !world->isOnGround(ptr) && !isFlying;
|
|
|
|
|
|
|
|
|
|
MWMechanics::DrawState_ currentDrawState = ptr.getClass().getNpcStats(ptr).getDrawState();
|
|
|
|
|
|
|
|
|
|
if (wasRunning != isRunning
|
|
|
|
|
|| wasSneaking != isSneaking || wasForceJumping != isForceJumping
|
|
|
|
|
|| wasForceMoveJumping != isForceMoveJumping || lastDrawState != currentDrawState
|
|
|
|
|
|| wasJumping || isJumping || wasFlying || isFlying
|
|
|
|
|
|| forceUpdate)
|
|
|
|
|
{
|
|
|
|
|
wasRunning = isRunning;
|
|
|
|
|
wasSneaking = isSneaking;
|
|
|
|
|
wasForceJumping = isForceJumping;
|
|
|
|
|
wasForceMoveJumping = isForceMoveJumping;
|
|
|
|
|
lastDrawState = currentDrawState;
|
|
|
|
|
|
|
|
|
|
wasFlying = isFlying;
|
|
|
|
|
wasJumping = isJumping;
|
|
|
|
|
|
|
|
|
|
movementFlags = 0;
|
|
|
|
|
|
|
|
|
|
#define __SETFLAG(flag, value) (value) ? (movementFlags | flag) : (movementFlags & ~flag)
|
|
|
|
|
|
|
|
|
|
movementFlags = __SETFLAG(CreatureStats::Flag_Sneak, isSneaking);
|
|
|
|
|
movementFlags = __SETFLAG(CreatureStats::Flag_Run, isRunning);
|
|
|
|
|
movementFlags = __SETFLAG(CreatureStats::Flag_ForceJump, isForceJumping);
|
|
|
|
|
movementFlags = __SETFLAG(CreatureStats::Flag_ForceJump, isJumping);
|
|
|
|
|
movementFlags = __SETFLAG(CreatureStats::Flag_ForceMoveJump, isForceMoveJumping);
|
|
|
|
|
|
|
|
|
|
#undef __SETFLAG
|
|
|
|
|
|
|
|
|
|
if (currentDrawState == MWMechanics::DrawState_Nothing)
|
|
|
|
|
drawState = 0;
|
|
|
|
|
else if (currentDrawState == MWMechanics::DrawState_Weapon)
|
|
|
|
|
drawState = 1;
|
|
|
|
|
else if (currentDrawState == MWMechanics::DrawState_Spell)
|
|
|
|
|
drawState = 2;
|
|
|
|
|
|
|
|
|
|
if (isJumping)
|
|
|
|
|
updatePosition(true); // fix position after jump;
|
|
|
|
|
|
|
|
|
|
mwmp::Main::get().getNetworking()->getActorList()->addDrawStateActor(*this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr LocalActor::getPtr()
|
|
|
|
@ -61,7 +120,9 @@ void LocalActor::setPtr(const MWWorld::Ptr& newPtr)
|
|
|
|
|
{
|
|
|
|
|
ptr = newPtr;
|
|
|
|
|
|
|
|
|
|
refId = newPtr.getCellRef().getRefId();
|
|
|
|
|
refNumIndex = newPtr.getCellRef().getRefNum().mIndex;
|
|
|
|
|
mpNum = newPtr.getCellRef().getMpNum();
|
|
|
|
|
refId = ptr.getCellRef().getRefId();
|
|
|
|
|
refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
|
|
|
|
mpNum = ptr.getCellRef().getMpNum();
|
|
|
|
|
|
|
|
|
|
lastDrawState = ptr.getClass().getNpcStats(ptr).getDrawState();
|
|
|
|
|
}
|
|
|
|
|