添加了节点树视图。

This commit is contained in:
fengjiayi
2024-09-26 21:00:17 +08:00
parent e81c527086
commit 42bf85b970
24 changed files with 877 additions and 357 deletions

View File

@@ -7,17 +7,14 @@ namespace Serein.NodeFlow.Base
/// <summary>
/// 节点基类(数据):条件控件,动作控件,条件区域,动作区域
/// </summary>
public abstract partial class NodeModelBase :IDynamicFlowNode
public abstract partial class NodeModelBase : IDynamicFlowNode
{
private static readonly ConnectionType[] ct = [ConnectionType.IsSucceed,
ConnectionType.IsFail,
ConnectionType.IsError,
ConnectionType.Upstream];
public NodeModelBase()
{
PreviousNodes = [];
SuccessorNodes = [];
foreach (ConnectionType ctType in ct)
foreach (ConnectionType ctType in NodeStaticConfig.ConnectionTypes)
{
PreviousNodes[ctType] = [];
SuccessorNodes[ctType] = [];
@@ -71,6 +68,9 @@ namespace Serein.NodeFlow.Base
/// </summary>
public Dictionary<ConnectionType,List<NodeModelBase>> SuccessorNodes { get; }
/// <summary>
/// 当前节点执行完毕后需要执行的下一个分支的类别
/// </summary>
public ConnectionType NextOrientation { get; set; } = ConnectionType.None;
/// <summary>

View File

@@ -426,10 +426,10 @@ namespace Serein.NodeFlow.Base
private static async Task MonitorObjExpInterrupt(IDynamicContext context, NodeModelBase nodeModel, object data, int type)
{
MonitorObjectEventArgs.ObjSourceType sourceType;
object key;
string key;
if(type == 0)
{
key = data;
key = data.GetType().FullName;
sourceType = MonitorObjectEventArgs.ObjSourceType.IOCObj;
}
else
@@ -450,6 +450,7 @@ namespace Serein.NodeFlow.Base
for (int i = 0; i < exps.Count && !isExpInterrupt; i++)
{
exp = exps[i];
if (string.IsNullOrEmpty(exp)) continue;
isExpInterrupt = SereinConditionParser.To(data, exp);
}
@@ -458,7 +459,7 @@ namespace Serein.NodeFlow.Base
InterruptClass interruptClass = InterruptClass.Branch; // 分支中断
if (context.Env.SetNodeInterrupt(nodeModel.Guid, interruptClass))
{
context.Env.TriggerInterrupt(nodeModel.Guid, exp, InterruptTriggerEventArgs.InterruptTriggerType.Obj);
context.Env.TriggerInterrupt(nodeModel.Guid, exp, InterruptTriggerEventArgs.InterruptTriggerType.Exp);
var cancelType = await nodeModel.DebugSetting.GetInterruptTask();
await Console.Out.WriteLineAsync($"[{data}]中断已{cancelType},开始执行后继分支");
}