更新
This commit is contained in:
@@ -70,19 +70,21 @@ namespace Cielonos.MainGame
|
||||
|
||||
public bool CheckPlayability(DisruptionType disruptionType = DisruptionType.NormalAction)
|
||||
{
|
||||
if (currentRuntimeFuncAnim == null || disruptionType == DisruptionType.Death)
|
||||
if (character.statusSm.isDead)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentRuntimeFuncAnim == null || disruptionType == DisruptionType.Death || disruptionType == DisruptionType.Must)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (disruptionType == DisruptionType.ForcedAction || disruptionType == DisruptionType.ForcedExternal)
|
||||
|
||||
if (disruptionType == DisruptionType.ForcedAction)
|
||||
{
|
||||
if (character.statusSm.isDead || character.statusSm.HasStatus(StatusType.Incapacitation))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return animationSc.disruptionStatus[DisruptionType.ForcedAction] ||
|
||||
animationSc.disruptionStatus[DisruptionType.NormalAction] ||
|
||||
animationSc.disruptionStatus[DisruptionType.Movement];
|
||||
}
|
||||
|
||||
if (disruptionType == DisruptionType.NormalAction)
|
||||
@@ -103,7 +105,7 @@ namespace Cielonos.MainGame
|
||||
return disruptionType switch
|
||||
{
|
||||
DisruptionType.None => false,
|
||||
DisruptionType.Must or DisruptionType.Death or DisruptionType.ForcedAction or DisruptionType.ForcedExternal => true,
|
||||
DisruptionType.Must or DisruptionType.Death => true,
|
||||
_ => animationSc.disruptionStatus[disruptionType]
|
||||
};
|
||||
}
|
||||
@@ -130,10 +132,6 @@ namespace Cielonos.MainGame
|
||||
|
||||
if (!CheckPlayability(newRtFuncAnim.funcAnimData.animInfo.disruptionType))
|
||||
{
|
||||
Debug.LogWarning($"[FunctionalAnimationSubmodule] Cannot play animation '{animationName}' due to playability check failure." +
|
||||
$"CurrentAnimation={currentRuntimeFuncAnim?.funcAnimData.animInfo.animationName ?? "None"} " +
|
||||
$"NewRtFuncAnim: disruptionType={newRtFuncAnim.funcAnimData.animInfo.disruptionType}" +
|
||||
$"IsDuringDisruption={animationSc.disruptionStatus[newRtFuncAnim.funcAnimData.animInfo.disruptionType]}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -144,7 +142,8 @@ namespace Cielonos.MainGame
|
||||
currentRuntimeFuncAnim.InvokeEndEvents();
|
||||
ResetPlayerPreinput();
|
||||
}
|
||||
|
||||
|
||||
float oldClipLength = currentRuntimeFuncAnim != null ? currentClip.length : 1f;
|
||||
currentRuntimeFuncAnim = newRtFuncAnim;
|
||||
currentRuntimeFuncAnim.ClearRuntimeEvents();
|
||||
runtimeStartEvents?.ForEach(payload => currentRuntimeFuncAnim.AddStartEvent(payload));
|
||||
@@ -157,7 +156,7 @@ namespace Cielonos.MainGame
|
||||
|
||||
currentRuntimeFuncAnim.currentPlayTime = animInfo.overrideStartFrame / currentClip.frameRate;
|
||||
float normalizedTimeOffset = currentPlayTime / currentClip.length;
|
||||
float normalizedTransitionDuration = isNormalizedTransition ? transitionDuration : transitionDuration / currentClip.length;
|
||||
float normalizedTransitionDuration = isNormalizedTransition ? transitionDuration : transitionDuration / oldClipLength;
|
||||
animator.CrossFade(animInfo.stateName, normalizedTransitionDuration, animator.GetLayerIndex(animatorLayerName), normalizedTimeOffset);
|
||||
float actionSpeed = animInfo.overridePlaySpeed * currentPlaySpeedMultiplier;
|
||||
animator.SetFloat(ActionSpeed, actionSpeed);
|
||||
@@ -170,6 +169,16 @@ namespace Cielonos.MainGame
|
||||
currentRuntimeFuncAnim.SetUpdateUntilEventsStatus();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止指定名称的动画,默认为强制停止
|
||||
/// </summary>
|
||||
public bool Stop(string animationName, DisruptionType disruptionType = DisruptionType.Must, float transitionDuration = 0.1f)
|
||||
{
|
||||
if (currentRuntimeFuncAnim == null) return true;
|
||||
if (currentRuntimeFuncAnim.funcAnimData.animInfo.animationName != animationName) return false;
|
||||
return Stop(disruptionType, transitionDuration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止当前动画
|
||||
@@ -185,7 +194,7 @@ namespace Cielonos.MainGame
|
||||
|
||||
if(currentRuntimeFuncAnim == null) return true;
|
||||
|
||||
if (disruptionType != DisruptionType.Death)
|
||||
if (disruptionType != DisruptionType.Death && disruptionType != DisruptionType.Must)
|
||||
{
|
||||
if (!CheckDisruption(disruptionType))
|
||||
{
|
||||
@@ -201,15 +210,13 @@ namespace Cielonos.MainGame
|
||||
ResetPlayerPreinput();
|
||||
}
|
||||
|
||||
float normalizedTransitionDuration = transitionDuration / currentClip.length;
|
||||
float oldClipLength = currentRuntimeFuncAnim != null ? currentClip.length : 1f;
|
||||
float normalizedTransitionDuration = transitionDuration / oldClipLength;
|
||||
animator.CrossFade("Empty", normalizedTransitionDuration, animator.GetLayerIndex(animatorLayerName));
|
||||
animationSc.disruptionStatus[DisruptionType.NormalExternal] = false;
|
||||
animationSc.disruptionStatus[DisruptionType.NormalAction] = false;
|
||||
animationSc.disruptionStatus[DisruptionType.Movement] = false;
|
||||
currentRuntimeFuncAnim = null;
|
||||
|
||||
Debug.Log("[FunctionalAnimationSubmodule] Animation stopped successfully.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -224,6 +231,8 @@ namespace Cielonos.MainGame
|
||||
|
||||
if (currentPlayTime >= currentClip.length)
|
||||
{
|
||||
UpdateEvents();
|
||||
|
||||
if (currentClip.isLooping)
|
||||
{
|
||||
currentRuntimeFuncAnim.currentPlayTime %= currentClip.length;
|
||||
|
||||
Reference in New Issue
Block a user