44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using System;
|
||
using Cielonos.MainGame.Buffs.Character;
|
||
using Cielonos.MainGame.Characters;
|
||
using Sirenix.OdinInspector;
|
||
using SLSUtilities.FunctionalAnimation;
|
||
using UnityEngine;
|
||
|
||
namespace Cielonos.MainGame.Base.FunctionalAnimation.Payloads
|
||
{
|
||
/// <summary>
|
||
/// FuncAnim Payload:在动画事件触发时,为当前的动画执行者施加指定的 CharacterBuff。
|
||
/// 完全兼容 ICharacterBuffFactory 的 Odin 多态编辑架构。
|
||
/// </summary>
|
||
[Serializable]
|
||
[EventColor(0.2f, 0.9f, 0.4f)]
|
||
public class ApplyBuff : FuncAnimPayloadBase
|
||
{
|
||
public override string NameForInspector => "Apply Buff";
|
||
|
||
[Tooltip("选择要施加的 Buff 类型并配置其参数。")]
|
||
[SerializeReference]
|
||
public ICharacterBuffFactory buffFactory;
|
||
|
||
public override void Invoke()
|
||
{
|
||
if (buffFactory == null)
|
||
{
|
||
Debug.LogWarning("[ApplyBuffPayload] 未配置 Buff 工厂,无法施加 Buff。");
|
||
return;
|
||
}
|
||
|
||
if (Executor is CharacterBase characterBase)
|
||
{
|
||
// 创建并施加 Buff (发起者和承受者都是自身)
|
||
buffFactory.Create().Apply(characterBase, characterBase);
|
||
}
|
||
else
|
||
{
|
||
Debug.LogWarning("[ApplyBuffPayload] 动画执行者不是 CharacterBase,无法施加 CharacterBuff。");
|
||
}
|
||
}
|
||
}
|
||
}
|