fix(ai): AiRuntime 自转换设为no-op(根治死亡双发Died再入) + EnemyBase.OnSpawn复位brain.enabled + 测试

Switch 对 target==当前态直接 no-op(不重跑Exit/Enter),循环改为 if(Switch(t))return true;
OnSpawn 复用时恢复被 QuotaManager 裁剪禁用的 brain。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-03 16:26:28 +08:00
co-authored by Claude Opus 4.8
parent d38c6e35bb
commit 63e241af92
3 changed files with 23 additions and 4 deletions
+5 -4
View File
@@ -85,7 +85,7 @@ namespace BaseGames.AI
{
var t = globals[i];
if (!t.IsEvent && t.Condition(_ctx))
return Switch(t);
{ if (Switch(t)) return true; }
}
var locals = _current.Transitions;
@@ -93,7 +93,7 @@ namespace BaseGames.AI
{
var t = locals[i];
if (!t.IsEvent && t.Condition(_ctx))
return Switch(t);
{ if (Switch(t)) return true; }
}
return false;
@@ -106,7 +106,7 @@ namespace BaseGames.AI
{
var t = globals[i];
if (t.IsEvent && t.Event.Value == sig)
return Switch(t);
{ if (Switch(t)) return true; }
}
var locals = _current.Transitions;
@@ -114,13 +114,14 @@ namespace BaseGames.AI
{
var t = locals[i];
if (t.IsEvent && t.Event.Value == sig)
return Switch(t);
{ if (Switch(t)) return true; }
}
return false;
}
bool Switch(Transition t)
{
if (t.Target == _current.Name) return false; // 自转换:no-op,不重跑 Exit/Enter
var from = _current.Name;
_current.OnExit?.Invoke(_ctx);
_current = _graph.GetState(t.Target);