feat(enemy): ICombatant 增加 HasEligibleAttack/UseBestAttack + EnemyBase 构建选择器

This commit is contained in:
2026-07-24 12:20:54 +08:00
parent 04a267b69f
commit 702df35efd
4 changed files with 60 additions and 0 deletions
@@ -82,6 +82,25 @@ namespace BaseGames.Enemies
public void InterruptAbilities()
=> _enemy.Abilities?.InterruptAll(Abilities.InterruptReason.ExternalRequest);
public bool HasEligibleAttack()
{
var sel = _enemy.AttackSelector;
if (sel == null) return false;
return sel.HasEligible(_enemy.IsPlayerVisible(), _enemy.Movement != null && _enemy.Movement.IsGrounded);
}
public bool UseBestAttack()
{
var sel = _enemy.AttackSelector;
if (sel == null) return false;
var mode = _enemy.StatsSO != null
? _enemy.StatsSO.attackSelectionMode
: Abilities.AttackSelectionMode.WeightedRandom;
bool grounded = _enemy.Movement != null && _enemy.Movement.IsGrounded;
var pick = sel.Select(_enemy.IsPlayerVisible(), grounded, mode);
return pick != null && pick.Execute();
}
// ---- IActorVitals ----
public bool IsAlive => _enemy.IsAlive;
public bool IsControllable => _enemy.CurrentState == EnemyStateType.Controlled;