using System; using Sirenix.OdinInspector; using SLSUtilities.FunctionalAnimation; using UnityEngine; using UnityEngine.Serialization; namespace Cielonos.MainGame.FunctionalAnimation { [Serializable] public class SwitchFuncAnim : FuncAnimPayloadBase { public string animationName; [Tooltip("是否启用高级设置")] public bool advancedSettings; [ShowIf("advancedSettings")] [Tooltip("用于Update Event,是否在落地时切换动画")] public bool switchWhenLanding; [ShowIf("advancedSettings")] [Tooltip("如果switchWhenLanding为true,是否覆盖地面检测的长度")] public bool overrideGroundDetection; [FormerlySerializedAs("overrideGroundDetectionLength")] [ShowIf("advancedSettings"), ShowIf("overrideGroundDetection")] [Tooltip("覆盖地面检测的长度乘数")] public float groundDetectionLengthMultiplier = 1f; [ShowIf("advancedSettings"), ShowIf("overrideGroundDetection")] [Tooltip("覆盖地面检测的偏移")] public float groundDetectionOffset = 0f; public override void Invoke() { if (!advancedSettings) { character.animationSc.fullBodyFuncAnimSm.Play(animationName); } else { if (switchWhenLanding) { if (overrideGroundDetection) { if (character.movementSc.groundDetector.DetectGround(groundDetectionLengthMultiplier, groundDetectionOffset)) { character.animationSc.fullBodyFuncAnimSm.Play(animationName); } } else { if (character.movementSc.groundDetector.DetectGround()) { character.animationSc.fullBodyFuncAnimSm.Play(animationName); } } } } } } }