forked from teamnwah/openmw-tes3coop
Keep track of the character looping state
This commit is contained in:
parent
9da2c9153e
commit
e4eb4b7e30
2 changed files with 12 additions and 9 deletions
|
@ -103,13 +103,13 @@ static void getStateInfo(CharacterState state, std::string *group)
|
||||||
|
|
||||||
|
|
||||||
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state, bool loop)
|
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state, bool loop)
|
||||||
: mPtr(ptr), mAnimation(anim), mState(state), mSkipAnim(false), mMovingAnim(false)
|
: mPtr(ptr), mAnimation(anim), mCharState(state), mSkipAnim(false), mMovingAnim(false)
|
||||||
{
|
{
|
||||||
if(!mAnimation)
|
if(!mAnimation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string group;
|
std::string group;
|
||||||
getStateInfo(mState, &group);
|
getStateInfo(mCharState, &group);
|
||||||
if(MWWorld::Class::get(mPtr).isActor())
|
if(MWWorld::Class::get(mPtr).isActor())
|
||||||
{
|
{
|
||||||
/* Accumulate along X/Y only for now, until we can figure out how we should
|
/* Accumulate along X/Y only for now, until we can figure out how we should
|
||||||
|
@ -249,7 +249,8 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
|
||||||
if(mode != 0 || getState() != CharState_SpecialIdle)
|
if(mode != 0 || getState() != CharState_SpecialIdle)
|
||||||
{
|
{
|
||||||
mAnimQueue.clear();
|
mAnimQueue.clear();
|
||||||
mState = CharState_SpecialIdle;
|
mCharState = CharState_SpecialIdle;
|
||||||
|
mLooping = false;
|
||||||
mMovingAnim = mAnimation->play(groupname, ((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1);
|
mMovingAnim = mAnimation->play(groupname, ((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1);
|
||||||
}
|
}
|
||||||
else if(mode == 0)
|
else if(mode == 0)
|
||||||
|
@ -268,18 +269,19 @@ void CharacterController::skipAnim()
|
||||||
|
|
||||||
void CharacterController::setState(CharacterState state, bool loop)
|
void CharacterController::setState(CharacterState state, bool loop)
|
||||||
{
|
{
|
||||||
if(mState == state)
|
if(mCharState == state)
|
||||||
return;
|
return;
|
||||||
mState = state;
|
mCharState = state;
|
||||||
|
mLooping = loop;
|
||||||
|
|
||||||
if(!mAnimation)
|
if(!mAnimation)
|
||||||
return;
|
return;
|
||||||
mAnimQueue.clear();
|
mAnimQueue.clear();
|
||||||
|
|
||||||
std::string anim;
|
std::string anim;
|
||||||
getStateInfo(mState, &anim);
|
getStateInfo(mCharState, &anim);
|
||||||
if((mMovingAnim=mAnimation->hasAnimation(anim)) != false)
|
if((mMovingAnim=mAnimation->hasAnimation(anim)) != false)
|
||||||
mMovingAnim = mAnimation->play(anim, "start", "stop", 0.0f, loop ? (~(size_t)0) : 0);
|
mMovingAnim = mAnimation->play(anim, "start", "stop", 0.0f, mLooping ? (~(size_t)0) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,8 @@ class CharacterController
|
||||||
typedef std::deque<std::pair<std::string,size_t> > AnimationQueue;
|
typedef std::deque<std::pair<std::string,size_t> > AnimationQueue;
|
||||||
AnimationQueue mAnimQueue;
|
AnimationQueue mAnimQueue;
|
||||||
|
|
||||||
CharacterState mState;
|
CharacterState mCharState;
|
||||||
|
bool mLooping;
|
||||||
bool mSkipAnim;
|
bool mSkipAnim;
|
||||||
|
|
||||||
bool mMovingAnim;
|
bool mMovingAnim;
|
||||||
|
@ -93,7 +94,7 @@ public:
|
||||||
|
|
||||||
void setState(CharacterState state, bool loop);
|
void setState(CharacterState state, bool loop);
|
||||||
CharacterState getState() const
|
CharacterState getState() const
|
||||||
{ return mState; }
|
{ return mCharState; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue