feat(ai): BrainGraph Transition/AiState/TransitionRecord 数据结构
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace BaseGames.AI
|
||||
{
|
||||
/// <summary>一条转换:条件型(Condition 非空)或事件型(Event 非空)。二者互斥。</summary>
|
||||
public sealed class Transition
|
||||
{
|
||||
public string Target { get; }
|
||||
public Func<IAiContext, bool> Condition { get; } // 条件型:pull,按 LOD 频率评估
|
||||
public AiSignal? Event { get; } // 事件型:push,收到信号即触发
|
||||
public string Label { get; } // 可读标签(显式字符串 / 事件名)
|
||||
|
||||
Transition(string target, Func<IAiContext, bool> condition, AiSignal? evt, string label)
|
||||
{
|
||||
Target = target;
|
||||
Condition = condition;
|
||||
Event = evt;
|
||||
Label = label;
|
||||
}
|
||||
|
||||
public static Transition OnCondition(string target, Func<IAiContext, bool> condition, string label)
|
||||
=> new Transition(target, condition, null, label);
|
||||
|
||||
public static Transition OnEvent(string target, AiSignal evt)
|
||||
=> new Transition(target, null, evt, "on " + evt);
|
||||
|
||||
public bool IsEvent => Event.HasValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user