feat(ai): BrainGraph AiGraph + BrainBuilder(fluent, 显式标签, 目标校验)

This commit is contained in:
2026-07-03 14:04:51 +08:00
parent 3d6cef1f41
commit 6f9fa8c4b8
8 changed files with 301 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
using System.Collections.Generic;
namespace BaseGames.AI
{
/// <summary>
/// 不可变状态图,每敌人类型构建一次、所有实例共享(flyweight)。
/// 既被 AiRuntime 执行,又被导出器/调试器只读投影。
/// </summary>
public sealed class AiGraph
{
readonly Dictionary<string, AiState> _states;
public string EntryState { get; }
public IReadOnlyList<Transition> GlobalTransitions { get; }
public AiGraph(string entry, Dictionary<string, AiState> states, IReadOnlyList<Transition> globals)
{
EntryState = entry;
_states = states;
GlobalTransitions = globals;
}
public AiState GetState(string name) => _states[name];
public bool HasState(string name) => _states.ContainsKey(name);
public IEnumerable<string> StateNames => _states.Keys;
public IEnumerable<AiState> States => _states.Values;
}
}