2025-12-23 19:47:06 -05:00
|
|
|
|
using System;
|
2026-01-12 03:22:16 -05:00
|
|
|
|
using Sirenix.OdinInspector;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
using SLSUtilities.FunctionalAnimation;
|
|
|
|
|
|
using UnityEngine;
|
2026-02-13 09:22:11 -05:00
|
|
|
|
using UnityEngine.Serialization;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Cielonos.MainGame.FunctionalAnimation
|
|
|
|
|
|
{
|
2025-12-23 19:47:06 -05:00
|
|
|
|
[Serializable]
|
2025-11-25 08:19:33 -05:00
|
|
|
|
public class SwitchFuncAnim : FuncAnimPayloadBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public string animationName;
|
|
|
|
|
|
|
2026-01-12 03:22:16 -05:00
|
|
|
|
[Tooltip("是否启用高级设置")]
|
|
|
|
|
|
public bool advancedSettings;
|
|
|
|
|
|
[ShowIf("advancedSettings")]
|
|
|
|
|
|
[Tooltip("用于Update Event,是否在落地时切换动画")]
|
|
|
|
|
|
public bool switchWhenLanding;
|
|
|
|
|
|
[ShowIf("advancedSettings")]
|
|
|
|
|
|
[Tooltip("如果switchWhenLanding为true,是否覆盖地面检测的长度")]
|
|
|
|
|
|
public bool overrideGroundDetection;
|
2026-02-13 09:22:11 -05:00
|
|
|
|
[FormerlySerializedAs("overrideGroundDetectionLength")]
|
2026-01-12 03:22:16 -05:00
|
|
|
|
[ShowIf("advancedSettings"), ShowIf("overrideGroundDetection")]
|
2026-02-13 09:22:11 -05:00
|
|
|
|
[Tooltip("覆盖地面检测的长度乘数")]
|
|
|
|
|
|
public float groundDetectionLengthMultiplier = 1f;
|
|
|
|
|
|
[ShowIf("advancedSettings"), ShowIf("overrideGroundDetection")]
|
|
|
|
|
|
[Tooltip("覆盖地面检测的偏移")]
|
|
|
|
|
|
public float groundDetectionOffset = 0f;
|
2026-01-12 03:22:16 -05:00
|
|
|
|
|
2025-11-25 08:19:33 -05:00
|
|
|
|
public override void Invoke()
|
|
|
|
|
|
{
|
2026-05-23 08:27:50 -04:00
|
|
|
|
var data = character.animationSc.fullBodyFuncAnimSm.collection[animationName];
|
|
|
|
|
|
float animationSpeedMultiplier = 1f;
|
|
|
|
|
|
if (data.animInfo.tags.Contains("Attack") && data.animInfo.isAffectedBySpeedMultiplier)
|
|
|
|
|
|
{
|
|
|
|
|
|
animationSpeedMultiplier = character.attributeSm[CharacterAttribute.AttackSpeed];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-12 03:22:16 -05:00
|
|
|
|
if (!advancedSettings)
|
|
|
|
|
|
{
|
2026-05-23 08:27:50 -04:00
|
|
|
|
character.animationSc.fullBodyFuncAnimSm.Play(animationName, animationSpeedMultiplier);
|
2026-01-12 03:22:16 -05:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (switchWhenLanding)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (overrideGroundDetection)
|
|
|
|
|
|
{
|
2026-02-13 09:22:11 -05:00
|
|
|
|
if (character.movementSc.groundDetector.DetectGround(groundDetectionLengthMultiplier, groundDetectionOffset))
|
2026-01-12 03:22:16 -05:00
|
|
|
|
{
|
2026-05-23 08:27:50 -04:00
|
|
|
|
character.animationSc.fullBodyFuncAnimSm.Play(animationName, animationSpeedMultiplier);
|
2026-01-12 03:22:16 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2026-02-13 09:22:11 -05:00
|
|
|
|
if (character.movementSc.groundDetector.DetectGround())
|
2026-01-12 03:22:16 -05:00
|
|
|
|
{
|
2026-05-23 08:27:50 -04:00
|
|
|
|
character.animationSc.fullBodyFuncAnimSm.Play(animationName, animationSpeedMultiplier);
|
2026-01-12 03:22:16 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-25 08:19:33 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|