Fix annimation not loop
This commit is contained in:
@@ -46,20 +46,27 @@ namespace BrewMonster
|
||||
}
|
||||
if (_animationQueue.Count > 0)
|
||||
{
|
||||
_animationQueue.Enqueue(new AnimationQueue
|
||||
if(@event.IsForceStopPrevious)
|
||||
{
|
||||
AnimationName = @event.AnimationName,
|
||||
IsForceStopPrevious = @event.IsForceStopPrevious,
|
||||
AttackEvent = @event.AttackEvent,
|
||||
ChannelAct = @event.ChannelAct,
|
||||
Rank = @event.Rank
|
||||
});
|
||||
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
|
||||
return;
|
||||
_animationQueue.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
_animationQueue.Enqueue(new AnimationQueue
|
||||
{
|
||||
AnimationName = @event.AnimationName,
|
||||
IsForceStopPrevious = @event.IsForceStopPrevious,
|
||||
AttackEvent = @event.AttackEvent,
|
||||
ChannelAct = @event.ChannelAct,
|
||||
Rank = @event.Rank
|
||||
});
|
||||
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
|
||||
return;
|
||||
}
|
||||
}
|
||||
previousAnimationName = @event.AnimationName;
|
||||
InternalPlayAnimation(@event.AnimationName, @event.ITransTime, FadeMode, @event.IsLoop);
|
||||
ApplyAnimationEndCallbacks(@event.AttackEvent, @event.ChannelAct, @event.Rank, @event.AnimationName);
|
||||
InternalPlayAnimation(@event.AnimationName, @event.ITransTime, FadeMode);
|
||||
ApplyAnimationEndCallbacks(@event.AttackEvent, @event.ChannelAct, @event.Rank, @event.AnimationName, @event.IsLoop);
|
||||
}
|
||||
public void InitPlayerEventDoneHandler()
|
||||
{
|
||||
@@ -195,6 +202,7 @@ namespace BrewMonster
|
||||
AttackEvent = null,
|
||||
IsLoop = true
|
||||
});
|
||||
Debug.Log($"EnqueueAnimationForLooping: {animationName}, _animationQueue: {string.Join(", ", _animationList)}");
|
||||
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
|
||||
return true;
|
||||
}
|
||||
@@ -205,14 +213,6 @@ namespace BrewMonster
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
string animationQueueString = "";
|
||||
foreach(var animation in _animationQueue)
|
||||
{
|
||||
animationQueueString += animation.AnimationName + ", ";
|
||||
}
|
||||
}
|
||||
|
||||
if (_animationQueue.Peek().IsForceStopPrevious)
|
||||
{
|
||||
@@ -227,21 +227,26 @@ namespace BrewMonster
|
||||
var animationQueue = _animationQueue.Dequeue();
|
||||
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
|
||||
previousAnimationName = animationQueue.AnimationName;
|
||||
InternalPlayAnimation(animationQueue.AnimationName, animationQueue.ITransTime, FadeMode, animationQueue.IsLoop);
|
||||
ApplyAnimationEndCallbacks(animationQueue.AttackEvent, animationQueue.ChannelAct, animationQueue.Rank, animationQueue.AnimationName);
|
||||
InternalPlayAnimation(animationQueue.AnimationName, animationQueue.ITransTime, FadeMode);
|
||||
ApplyAnimationEndCallbacks(animationQueue.AttackEvent, animationQueue.ChannelAct, animationQueue.Rank, animationQueue.AnimationName,animationQueue.IsLoop);
|
||||
}
|
||||
|
||||
private void ApplyAnimationEndCallbacks(CECAttackEvent attackEvent, ChannelAct channelAct, int rank, string animationName)
|
||||
private void ApplyAnimationEndCallbacks(CECAttackEvent attackEvent, ChannelAct channelAct, int rank, string animationName, bool isLoop)
|
||||
{
|
||||
if (_currentState == null) return;
|
||||
_currentState.Events.OnEnd = () =>
|
||||
{
|
||||
if (attackEvent != null)
|
||||
attackEvent.m_bSignaled = true;
|
||||
if(isLoop)
|
||||
{
|
||||
EnqueueAnimationForLooping(animationName);
|
||||
}
|
||||
if (channelAct == null || string.IsNullOrEmpty(animationName))
|
||||
return;
|
||||
var node = channelAct.GetNodeByRank((byte)rank);
|
||||
node?.m_pActive?.m_ActionNames?.Remove(animationName);
|
||||
|
||||
};
|
||||
}
|
||||
void ApplyDamage()
|
||||
@@ -271,7 +276,7 @@ namespace BrewMonster
|
||||
/// <param name="animationName"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="fadeMode"></param>
|
||||
private void InternalPlayAnimation(string animationName, float duration = FadeTime, FadeMode fadeMode = FadeMode, bool isLoop = false)
|
||||
private void InternalPlayAnimation(string animationName, float duration = FadeTime, FadeMode fadeMode = FadeMode)
|
||||
{
|
||||
if (namedAnimancer == null)
|
||||
{
|
||||
@@ -281,13 +286,8 @@ namespace BrewMonster
|
||||
if (isState)
|
||||
{
|
||||
_currentState = namedAnimancer.TryPlay(animationName, duration / 1000, fadeMode);
|
||||
_currentState.Time = 0;
|
||||
_currentAnimationName = animationName;
|
||||
//if the animation is looping and the current state is not looping, play the animation again
|
||||
if(isLoop == true && _currentState.IsLooping == false)
|
||||
{
|
||||
_currentState.Time = 0;
|
||||
_currentState.Events.OnEnd = () => EnqueueAnimationForLooping(animationName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//BMLogger.LogError($"Null name animation: {animationName}");
|
||||
|
||||
Reference in New Issue
Block a user