feat(ai): BrainGraph AiGraph + BrainBuilder(fluent, 显式标签, 目标校验)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user