You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Wiki/pages/先入为主的节点设计.md

3.4 KiB

  • 写在开始

    考虑想尽量用配置文件的形式实现这种简易的节点编辑器,所以写了一套配置文件模板,然后写一个解析器将其解析成ClearScript支持的C#格式代码,在事件系统中执行
    public enum PortType {
          Number,
          String,
          Bool
      }
      public class TriggerNode {
          public Guid Id { get; set; }
          public string Name { get; set; }
          public string Description { get; set; }
          public bool HasProcessRoute { get; set; }
          public Dictionary<string, Input> Inputs { get; set; }
          public Dictionary<string, Output> Outputs { get; set; }
          public int XLocation { get; set; }
          public int YLocation { get; set; }
          public string ScriptTemplate { get; set; }
      }
      public class Input {
          public PortType Type { get; set; }
          public Guid ConnectTo { get; set; }
      }
      public class Output {
          public PortType Type { get; set; }
          public Guid ConnectTo { get; set; }
      }
    

考虑几种基本设计

  • 与节点

    用来计算两个布尔值的与运算 按照上面的格式应该写成下面这种yaml
  • Id: xxx-xxx-xxx
    Name: "And"
    Description: "对两个参数进行与运算输出结果"
    HasProcessRoute: false
    Inputs: 
    param1: 
      Type: Bool
      ConnectTo: null
    param2:
      Type: Bool
      ConnectTo: null
    Outputs:
    param3:
      Type: Bool
      ConnectTo: null
    XLocation: null
    YLocation: null
    ScriptTemplate: "( {{param1}} && {{param2}} )"
    

非节点

用来对一个布尔值进行非运算

Id: xxx-xxx-xxx
Name: "Not"
Description: "对一个参数进行非运算输出结果"
HasProcessRoute: false
Inputs: 
param1: 
  Type: Bool
  ConnectTo: null
Outputs:
param2:
  Type: Bool
  ConnectTo: null
XLocation: null
YLocation: null
ScriptTemplate: "( !{{param1}})"

大于节点

判断参数1是否大于参数2的逻辑运算

Id: xxx-xxx-xxx
Name: "BiggerThan"
Description: "对两个参数进行大于运算输出结果"
HasProcessRoute: false
Inputs: 
param1: 
  Type: Number
  ConnectTo: null
param2:
  Type: Number
  ConnectTo: null
Outputs:
param3:
  Type: Bool
  ConnectTo: null
XLocation: null
YLocation: null
ScriptTemplate: "( {{param1}} > {{param2}} )"

大于等于节点

判断参数1是否大于参数2的逻辑运算

Id: xxx-xxx-xxx
Name: "BiggerEqual"
Description: "对两个参数进行大于等于运算输出结果"
HasProcessRoute: false
Inputs: 
param1: 
  Type: Number
  ConnectTo: null
param2:
  Type: Number
  ConnectTo: null
Outputs:
param3:
  Type: Bool
  ConnectTo: null
XLocation: null
YLocation: null
ScriptTemplate: "( {{param1}} >= {{param2}} )"

通过暴露API获取某个数值节点

通过ClearScript暴露进模拟环境的接口在这里调用然后获取一个数值这种接口本身就是Input然后通过节点上的窗口选择获取什么参数这个在原有的格式设定上就做不出来了因为不包含Input而源是自己在节点上配置的所以应该写成下面这样

Id: xxx-xxx-xxx
Name: "GetAnyFromInterface"
Description: "对两个参数进行大于等于运算输出结果"
HasProcessRoute: false
Options:
- ShowName: 获取角色
  ScriptName: GetCharactor
  
Outputs:
param3:
  Type: Bool
  ConnectTo: null
XLocation: null
YLocation: null
ScriptTemplate: "( {{param1}} >= {{param2}} )"