mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Work out the state in the character controller update method
This commit is contained in:
parent
23acf4b130
commit
51d5efeeb2
@ -246,7 +246,6 @@ namespace MWMechanics
|
||||
if(iter->second.getState() >= CharState_Death1)
|
||||
continue;
|
||||
|
||||
iter->second.setMovementVector(Ogre::Vector3::ZERO);
|
||||
iter->second.setState(CharState_Death1, false);
|
||||
|
||||
++mDeathCount[MWWorld::Class::get(iter->first).getId(iter->first)];
|
||||
@ -259,15 +258,6 @@ namespace MWMechanics
|
||||
|
||||
if(!paused)
|
||||
{
|
||||
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||
{
|
||||
if(iter->second.getState() >= CharState_Death1)
|
||||
continue;
|
||||
|
||||
Ogre::Vector3 movement = MWWorld::Class::get(iter->first).getMovementVector(iter->first);
|
||||
iter->second.setMovementVector(movement);
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, Ogre::Vector3> > movement;
|
||||
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||
{
|
||||
|
@ -139,36 +139,35 @@ void CharacterController::markerEvent(float time, const std::string &evt)
|
||||
}
|
||||
|
||||
|
||||
void CharacterController::setMovementVector(const Ogre::Vector3 &vec)
|
||||
Ogre::Vector3 CharacterController::update(float duration)
|
||||
{
|
||||
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
||||
const Ogre::Vector3 &vec = cls.getMovementVector(mPtr);
|
||||
|
||||
// HACK: The length we get is too large.
|
||||
float speed = std::max(1.0f, vec.length() / 32.0f);
|
||||
|
||||
if(vec.length() >= 0.1f)
|
||||
if(std::abs(vec.x/2.0f) > std::abs(vec.y))
|
||||
{
|
||||
if(std::abs(vec.x/2.0f) > std::abs(vec.y))
|
||||
{
|
||||
if(vec.x > 0.0f)
|
||||
setState(CharState_WalkRight, true);
|
||||
else if(vec.x < 0.0f)
|
||||
setState(CharState_WalkLeft, true);
|
||||
}
|
||||
else if(vec.y < 0.0f)
|
||||
setState(CharState_WalkBack, true);
|
||||
else
|
||||
setState(CharState_WalkForward, true);
|
||||
if(vec.x > 0.0f)
|
||||
setState(CharState_WalkRight, true);
|
||||
else if(vec.x < 0.0f)
|
||||
setState(CharState_WalkLeft, true);
|
||||
}
|
||||
else if(vec.y > 0.0f)
|
||||
setState(CharState_WalkForward, true);
|
||||
else if(vec.y < 0.0f)
|
||||
setState(CharState_WalkBack, true);
|
||||
else
|
||||
setState(CharState_Idle, true);
|
||||
{
|
||||
if(!(getState() >= CharState_Death1))
|
||||
setState(CharState_Idle, true);
|
||||
}
|
||||
|
||||
if(mAnimation)
|
||||
mAnimation->setSpeedMult(speed);
|
||||
mDirection = vec.normalisedCopy();
|
||||
}
|
||||
|
||||
|
||||
Ogre::Vector3 CharacterController::update(float duration)
|
||||
{
|
||||
Ogre::Vector3 movement = Ogre::Vector3::ZERO;
|
||||
if(mAnimation && !mSkipAnim)
|
||||
movement += mAnimation->runAnimation(duration);
|
||||
|
@ -66,8 +66,6 @@ public:
|
||||
void playGroup(const std::string &groupname, int mode, int count);
|
||||
void skipAnim();
|
||||
|
||||
void setMovementVector(const Ogre::Vector3 &vec);
|
||||
|
||||
void setState(CharacterState state, bool loop);
|
||||
CharacterState getState() const
|
||||
{ return mState; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user