1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-28 23:36:42 +00:00

Implement WalkForward and WalkBack character states

This commit is contained in:
Chris Robinson 2013-01-18 18:04:00 -08:00
parent e33f59e0fe
commit aecfc0829a
3 changed files with 32 additions and 0 deletions

View file

@ -251,6 +251,7 @@ namespace MWMechanics
} }
iter->second.setState(CharState_Dead); iter->second.setState(CharState_Dead);
iter->second.setDirection(Ogre::Vector3::ZERO);
++mDeathCount[MWWorld::Class::get(iter->first).getId(iter->first)]; ++mDeathCount[MWWorld::Class::get(iter->first).getId(iter->first)];
@ -264,7 +265,22 @@ namespace MWMechanics
{ {
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
{ {
if(iter->second.getState() == CharState_Dead)
continue;
Ogre::Vector3 dir = MWWorld::Class::get(iter->first).getMovementVector(iter->first); Ogre::Vector3 dir = MWWorld::Class::get(iter->first).getMovementVector(iter->first);
CharacterState newstate = CharState_Idle;
if(dir.length() >= 0.1f)
{
if(dir.y < 0.0f)
newstate = CharState_WalkBack;
else
newstate = CharState_WalkForward;
}
if(iter->second.getState() != newstate)
iter->second.setState(newstate);
iter->second.setDirection(dir); iter->second.setDirection(dir);
} }

View file

@ -188,6 +188,18 @@ void CharacterController::setState(CharacterState state)
mAnimation->setAccumulation(Ogre::Vector3::ZERO); mAnimation->setAccumulation(Ogre::Vector3::ZERO);
mAnimation->play(mCurrentGroup, "start"); mAnimation->play(mCurrentGroup, "start");
break; break;
case CharState_WalkForward:
mCurrentGroup = "walkforward";
mAnimation->setAccumulation(Ogre::Vector3(0.0f, 1.0f, 0.0f));
mAnimation->play(mCurrentGroup, "start");
break;
case CharState_WalkBack:
mCurrentGroup = "walkback";
mAnimation->setAccumulation(Ogre::Vector3(0.0f, 1.0f, 0.0f));
mAnimation->play(mCurrentGroup, "start");
break;
case CharState_Dead: case CharState_Dead:
mCurrentGroup = "death1"; mCurrentGroup = "death1";
mAnimation->setAccumulation(Ogre::Vector3(1.0f, 1.0f, 0.0f)); mAnimation->setAccumulation(Ogre::Vector3(1.0f, 1.0f, 0.0f));

View file

@ -16,6 +16,10 @@ namespace MWMechanics
enum CharacterState { enum CharacterState {
CharState_SpecialIdle, /* When running a PlayGroup/LoopGroup animation. */ CharState_SpecialIdle, /* When running a PlayGroup/LoopGroup animation. */
CharState_Idle, CharState_Idle,
CharState_WalkForward,
CharState_WalkBack,
CharState_Dead CharState_Dead
}; };