예제 #1
0
 public void AddPort(BasePort port)
 {
     if (ports.ContainsKey(port.name))
     {
         throw new ArgumentException($"Already contains port:{port.name}");
     }
     ports[port.name] = port;
     port.Enable(this);
     onPortAdded?.Invoke(port);
 }
예제 #2
0
 //断开连接
 public void Disconnect(BasePort port)
 {
     if (port.Owner == null || !nodes.ContainsKey(port.Owner.GUID))
     {
         return;
     }
     foreach (var connection in port.Connections.ToArray())
     {
         Disconnect(connection);
     }
 }
예제 #3
0
 public void RemovePort(BasePort port)
 {
     if (port.Owner != this)
     {
         return;
     }
     if (!ports.ContainsKey(port.name))
     {
         throw new ArgumentException($"Not contains port:{port.name}");
     }
     Owner.Disconnect(port);
     ports.Remove(port.name);
     onPortRemoved?.Invoke(port);
 }
예제 #4
0
 private void InitPort()
 {
     //属性端口
     foreach (FieldInfo item in ReflectionHelper.GetFieldInfos(GetType()))
     {
         if (AttributeHelper.TryGetFieldAttribute(item, out NodeValueAttribute nodeValueAttribute))
         {
             continue;
         }
         BasePort port = null;
         if (AttributeHelper.TryGetFieldAttribute(item, out InputPortAttribute inputAttr))
         {
             port = new BasePort(inputAttr.name, inputAttr.orientation, inputAttr.direction, inputAttr.capacity, item.FieldType);
         }
         if (AttributeHelper.TryGetFieldAttribute(item, out OutputPortAttribute outputAttr))
         {
             port = new BasePort(outputAttr.name, outputAttr.orientation, outputAttr.direction, outputAttr.capacity, item.FieldType);
         }
         if (port != null)
         {
             AddPort(port);
         }
     }
 }
예제 #5
0
 public AddPortCommand(BaseNode node, string name, BasePort.Orientation orientation, BasePort.Direction direction, BasePort.Capacity capacity, Type type = null)
 {
     this.node = node;
     port      = new BasePort(name, orientation, direction, capacity, type);
 }
예제 #6
0
 public RemovePortCommand(BaseNode node, BasePort port)
 {
     this.node = node;
     this.port = port;
 }