refactor(ai): 终审收尾——删死字段/事件转换刷新IsSuspended + 局部事件与双实例独立性测试

This commit is contained in:
2026-07-03 14:33:23 +08:00
parent 747d39072e
commit 11e4c9f1ea
3 changed files with 43 additions and 4 deletions
+4 -1
View File
@@ -54,7 +54,10 @@ namespace BaseGames.AI
{
var sig = _pending.Dequeue();
if (TryEventTransition(sig))
return; // 事件触发转换后本帧结束
{
IsSuspended = false; // 已推进转换,非挂起
return;
}
}
// 2) IsControllable 让位门:受击/硬直/击飞时挂起,不推进决策也不跑 Tick。
+2 -3
View File
@@ -23,7 +23,7 @@ namespace BaseGames.AI
s = new AiState(name);
_states[name] = s;
}
return new StateBuilder(this, s);
return new StateBuilder(s);
}
public GlobalBuilder Global() => new GlobalBuilder(this);
@@ -52,9 +52,8 @@ namespace BaseGames.AI
public sealed class StateBuilder
{
readonly BrainBuilder _owner;
readonly AiState _state;
internal StateBuilder(BrainBuilder owner, AiState state) { _owner = owner; _state = state; }
internal StateBuilder(AiState state) { _state = state; }
public StateBuilder OnEnter(Action<IAiContext> fn) { _state.OnEnter = fn; return this; }
public StateBuilder Tick(Action<IAiContext> fn) { _state.OnTick = (c, _) => fn(c); return this; }