feat(ai): 敌人感知↔状态模型——待机/警觉/追击/巡逻 + 可复用感知状态机
感知门面 EnemyBase.InChaseZone(追逐/aggro)/InVisionZone(视野/los,缺省回退aggro),纯查询; 转换逻辑归 AI 层: 新增可复用 PerceptionStateMachine(统一规则,HasAlert/视野缺省自动降级); 规则: 未发现进视野→警觉, 进追逐→追击(委托能力), 追击脱离视野→巡逻(永不回警觉,再进视野再警觉). EnemyStatsSO.HasAlertState 勾选项; ContactChaseAbility 改纯执行器(退出由AI中断); E001 用可复用件. PlayMode 验证四态转换全通过. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,8 +7,10 @@ namespace BaseGames.Tests.EditMode.AI
|
||||
public sealed class FakeSensor : ISensor
|
||||
{
|
||||
public bool Sees; public float LostForValue; public Vector2 Last;
|
||||
public bool Chase; public bool Vision;
|
||||
public bool InChaseZone() => Chase;
|
||||
public bool InVisionZone() => Vision;
|
||||
public bool SeesPlayer() => Sees;
|
||||
public bool DetectsPlayer() => Sees; // 测试里等同可见
|
||||
public bool InRange(float range) => Sees; // 简化:可见即在范围
|
||||
public bool LostFor(float seconds) => LostForValue >= seconds;
|
||||
public Vector2 LastKnown => Last;
|
||||
@@ -33,6 +35,7 @@ namespace BaseGames.Tests.EditMode.AI
|
||||
public bool IsAbilityRunning(string id = null) => id == null ? Running != null : Running == id;
|
||||
public bool NoAbilityRunning => Running == null;
|
||||
public bool CanUseAbility(string id) => true;
|
||||
public void InterruptAbilities() => Running = null;
|
||||
}
|
||||
|
||||
public sealed class FakeVitals : IActorVitals
|
||||
|
||||
Reference in New Issue
Block a user