forked from teamnwah/openmw-tes3coop
Play an animation when changing states
This commit is contained in:
parent
b378bc92a0
commit
3c487e6019
3 changed files with 35 additions and 10 deletions
|
@ -169,10 +169,7 @@ namespace MWMechanics
|
||||||
if(!MWWorld::Class::get(ptr).getCreatureStats(ptr).isDead())
|
if(!MWWorld::Class::get(ptr).getCreatureStats(ptr).isDead())
|
||||||
mActors.insert(std::make_pair(ptr, CharacterController(ptr, anim, CharState_Idle)));
|
mActors.insert(std::make_pair(ptr, CharacterController(ptr, anim, CharState_Idle)));
|
||||||
else
|
else
|
||||||
{
|
|
||||||
mActors.insert(std::make_pair(ptr, CharacterController(ptr, anim, CharState_Dead)));
|
mActors.insert(std::make_pair(ptr, CharacterController(ptr, anim, CharState_Dead)));
|
||||||
MWBase::Environment::get().getWorld()->playAnimationGroup (ptr, "death1", 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
||||||
|
@ -247,7 +244,6 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
iter->second.setState(CharState_Dead);
|
iter->second.setState(CharState_Dead);
|
||||||
MWBase::Environment::get().getWorld()->playAnimationGroup(iter->first, "death1", 0);
|
|
||||||
|
|
||||||
++mDeathCount[MWWorld::Class::get(iter->first).getId(iter->first)];
|
++mDeathCount[MWWorld::Class::get(iter->first).getId(iter->first)];
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,41 @@
|
||||||
|
|
||||||
#include "character.hpp"
|
#include "character.hpp"
|
||||||
|
|
||||||
|
#include "../mwrender/animation.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
|
|
||||||
|
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state)
|
||||||
|
: mPtr(ptr), mAnimation(anim), mState(state)
|
||||||
|
{
|
||||||
|
if(!mAnimation)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch(mState)
|
||||||
|
{
|
||||||
|
case CharState_Idle:
|
||||||
|
mAnimation->playGroup("idle", 1, 1);
|
||||||
|
break;
|
||||||
|
case CharState_Dead:
|
||||||
|
mAnimation->playGroup("death1", 1, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CharacterController::setState(CharacterState state)
|
||||||
|
{
|
||||||
|
mState = state;
|
||||||
|
switch(mState)
|
||||||
|
{
|
||||||
|
case CharState_Idle:
|
||||||
|
mAnimation->playGroup("idle", 1, 1);
|
||||||
|
break;
|
||||||
|
case CharState_Dead:
|
||||||
|
mAnimation->playGroup("death1", 1, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,15 +24,11 @@ class CharacterController
|
||||||
CharacterState mState;
|
CharacterState mState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state)
|
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state);
|
||||||
: mPtr(ptr), mAnimation(anim), mState(state)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
void setState(CharacterState state);
|
||||||
CharacterState getState() const
|
CharacterState getState() const
|
||||||
{ return mState; }
|
{ return mState; }
|
||||||
|
|
||||||
void setState(CharacterState state)
|
|
||||||
{ mState = state; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue