feat(enemy): ICombatant 增加 HasEligibleAttack/UseBestAttack + EnemyBase 构建选择器
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user