fix(ai): 应用 Task 1+2 代码审查意见
ResourceFull 未挂 BossResource 时改为显式抛——原先静默返回 false, 是 CLAUDE.md 第 6 条禁止的下游兜底,且与紧邻的 Boss facet 行为不一致。 FakeBossControl.DistanceToAnchor 不再忽略 index。测试改用 TearDown 清理 (本项目关闭了 Domain/Scene Reload,失败断言会把物体永久留在打开的场景里)。 BeginPhaseTransition 去掉死的默认参数;接口补充重入契约说明。 顺带去重:FakeAiContext 实现 IEnemyActor,删除两个测试内的本地 Ctx 副本 ——一个接口成员改动要同步三份是复发性成本。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,23 +7,6 @@ namespace BaseGames.Tests.EditMode.AI
|
||||
{
|
||||
public class PerceptionRecipeSoTests
|
||||
{
|
||||
sealed class Ctx : IAiContext, IEnemyActor
|
||||
{
|
||||
public FakeSensor S = new FakeSensor();
|
||||
public FakeLocomotion L = new FakeLocomotion();
|
||||
public FakeCombat C = new FakeCombat();
|
||||
public FakeVitals V = new FakeVitals();
|
||||
public Blackboard BB = new Blackboard();
|
||||
public FakeBossControl B = new FakeBossControl();
|
||||
public ISensor Sensor => S;
|
||||
public IEnemyLocomotion Locomotion => L;
|
||||
public ICombatant Combat => C;
|
||||
public IActorVitals Vitals => V;
|
||||
public Blackboard Blackboard => BB;
|
||||
public IBossControl Boss => B;
|
||||
public bool HasAlertState => true;
|
||||
}
|
||||
|
||||
static PerceptionRecipeSO MakeE001Recipe()
|
||||
{
|
||||
var so = ScriptableObject.CreateInstance<PerceptionRecipeSO>();
|
||||
@@ -61,7 +44,7 @@ namespace BaseGames.Tests.EditMode.AI
|
||||
public void Graph_BehavesLikeE001()
|
||||
{
|
||||
var so = MakeE001Recipe();
|
||||
var ctx = new Ctx();
|
||||
var ctx = new FakeAiContext();
|
||||
var rt = new AiRuntime(so.GetOrBuildGraph(), ctx);
|
||||
Assert.AreEqual(DisguiseThenPatrol.Disguise, rt.CurrentStateName);
|
||||
ctx.S.Chase = true;
|
||||
|
||||
Reference in New Issue
Block a user