using BaseGames.AI; namespace BaseGames.Enemies { /// /// E001(草蛭)AI —— 纯决策层,复用 PerceptionStateMachine 的"待机/警觉/追击/巡逻"统一规则。 /// 只声明差异:待机=伪装静止、警觉=张口(e001_alert)、追击=委托 e001_chase 能力、R=巡逻。 /// 追击移动/接触伤害由能力实现;退出追击由 AI 中断能力。依据 Docs/Game/Design/小怪设计-程序开发文档-01.md。 /// [AiDefinition("E001")] public sealed class E001CaoZhiAi : AiScript { static IEnemyActor Actor(IAiContext c) => (IEnemyActor)c; protected override void Build(BrainBuilder b) { PerceptionStateMachine.Add(b, new PerceptionStateMachine.Config { Idle = "Idle_Disguise", Patrol = "Move_Patrol", Alert = "Alert", Chase = "Chase", Death = "Death", Entry = "Idle_Disguise", Rest = "Move_Patrol", ChaseAbilityId = "e001_chase", OnIdleEnter = c => { c.Mover.Stop(); Actor(c).SetPhase(AiPhase.Idle); }, OnPatrolEnter = c => { c.Mover.UsePatrolSpeed(); Actor(c).SetPhase(AiPhase.Patrol); }, OnPatrolTick = c => c.Mover.WalkRandom(), // 警觉:停下、朝向玩家、切 Alert 阶段(播警觉动画+feedback)、张口占位 OnAlertEnter = c => { c.Mover.Stop(); c.Mover.FacePlayer(); Actor(c).SetPhase(AiPhase.Alert); c.Combat.UseAbility("e001_alert"); }, // 追击进入:切追击速度、朝向、Chase 阶段(追击能力由 PerceptionStateMachine 触发) OnChaseEnter = c => { c.Mover.UseChaseSpeed(); c.Mover.FacePlayer(); Actor(c).SetPhase(AiPhase.Chase); }, // 追击退出:中断追击能力(停移动、关接触伤害) OnChaseExit = c => c.Combat.InterruptAbilities(), OnDeathEnter = c => c.Mover.Stop(), }); } } }