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:
parent
e33f59e0fe
commit
aecfc0829a
3 changed files with 32 additions and 0 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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));
|
||||||
|
|
|
@ -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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue