fix(enemy): 禁用的能力组件不再报告可用

CanUse 纳入 enabled。此前禁用组件仍返回 true,选招器会选中一个
StartCoroutine 必然失败的招。这也是阶段门(按阶段启停能力)的前提。
This commit is contained in:
2026-07-30 13:28:23 +08:00
parent d8d99dd1ce
commit 64d2087adc
3 changed files with 77 additions and 3 deletions
@@ -37,11 +37,16 @@ namespace BaseGames.Enemies.Abilities
public float CooldownRemaining => Mathf.Max(0f, _cooldownEndTime - Time.time);
public bool IsOnCooldown => CooldownRemaining > 0f;
/// <summary>能力被外部中断时触发(BD Task / 状态机订阅用)。</summary>
/// <summary>能力被外部中断时触发(AI 决策层 / 状态机订阅用)。</summary>
public event System.Action<InterruptReason> Interrupted;
/// <summary>BD 任务统一查询入口:当前是否可用(冷却完毕且未执行中)。</summary>
public virtual bool CanUse => !_isRunning && !IsOnCooldown && _enemy != null && _enemy.IsAlive;
/// <summary>
/// 统一可用性查询:组件启用 + 冷却完毕 + 未执行中 + 宿主存活。
/// enabled 这一维供阶段门使用——被阶段禁用的能力不得进入选招候选,
/// 否则选招器会选中它然后 StartCoroutine 在禁用组件上必然失败。
/// </summary>
public virtual bool CanUse => enabled && !_isRunning && !IsOnCooldown
&& _enemy != null && _enemy.IsAlive;
// ── IAttackCandidate(供 EnemyAttackSelector 选招)──────────────────
public bool RequiresLineOfSight => _config != null && _config.requiresLineOfSight;