#if GRAPH_DESIGNER
using UnityEngine;
using Opsive.BehaviorDesigner.Runtime.Tasks;
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
using BaseGames.Enemies.Boss.Patterns;
namespace BaseGames.Enemies.AI
{
///
/// BD Action:触发攻击预警(TelegraphSystem),等待 Duration 秒后返回 Success。
/// 对应架构 07_EnemyModule §8 BD_TelegraphAttack;与 TelegraphSystem 协作。
///
[TaskName("Telegraph Attack")]
[TaskCategory("BaseGames/Enemy/Combat")]
[TaskDescription("播放攻击前摇动画并等待结束后返回 Success")]
public class BD_TelegraphAttack : Action
{
[SerializeField] private float m_Duration = 1f;
[SerializeField] private string m_VfxKey = "";
private TelegraphSystem _telegraph;
private float _elapsed;
private Coroutine _telegraphCoroutine;
public override void OnAwake() => _telegraph = GetComponent();
public override void OnStart()
{
_elapsed = 0f;
_telegraphCoroutine = null;
if (_telegraph != null && !string.IsNullOrEmpty(m_VfxKey))
{
_telegraphCoroutine = _telegraph.StartCoroutine(
_telegraph.ShowTelegraph(m_VfxKey, m_Duration, transform.position));
}
}
public override TaskStatus OnUpdate()
{
_elapsed += Time.deltaTime;
return _elapsed >= m_Duration ? TaskStatus.Success : TaskStatus.Running;
}
public override void OnEnd()
{
// BD 任务被 Abort 时停止仍在播放的预警协程,避免孤立 VFX
if (_telegraphCoroutine != null)
{
_telegraph?.StopCoroutine(_telegraphCoroutine);
_telegraphCoroutine = null;
}
}
}
}
#endif