示例#1
0
        public override void OnInputLiteralChanged(CNodeChangeContext context, CInputPin pin)
        {
            if (pin == InputPins[0])
            {
                CKlaxScriptTypeInfo targetType = ((CKlaxScriptTypeInfo)pin.Literal);
                ChangePinType(context, OutputPins[0], targetType == null ? typeof(object) : targetType.Type);

                if (targetType != null)
                {
                    ChangeNodeName(context, "Cast to " + targetType.Name);
                }
            }
        }
示例#2
0
 public override void OnAddOutputPinButtonClicked(CNodeChangeContext context)
 {
     if (InputPins[0].Literal is CKlaxScriptTypeInfo currentType)
     {
         CSwitchExecutionPin pin = new CSwitchExecutionPin
         {
             Name  = "",
             Type  = currentType.Type,
             Value = currentType.Type.GetDefaultValue()
         };
         AddExecutionPin(context, pin, OutExecutionPins.Count, false);
     }
 }
示例#3
0
        public override void OnInputLiteralChanged(CNodeChangeContext context, CInputPin pin)
        {
            if (pin == InputPins[0])
            {
                CKlaxScriptTypeInfo newType = pin.Literal as CKlaxScriptTypeInfo;
                if (newType != null)
                {
                    OutExecutionPins.RemoveRange(1, OutExecutionPins.Count - 1);
                    context.Actions.Add(new CSwitchNodeTypeChangeAction(newType.Type));

                    ChangePinType(context, InputPins[1], newType.Type);
                    ChangeNodeName(context, $"Switch ({newType.Name})");
                    InputPins[1].Literal = newType.Type.GetDefaultValue();
                }
            }
        }
示例#4
0
        public override void RemoveConnection(CNodeConnectionViewModel removedConnection, CPinViewModel otherPin)
        {
            m_pin.SourceNode           = null;
            m_pin.SourceParameterIndex = -1;

            if (otherPin is COutputPinViewModel outputVm)
            {
                CNodeChangeContext context = new CNodeChangeContext();
                m_nodeViewmodel.ScriptNode.OnInputConnectionChanged(context, m_pin, null);
                foreach (var action in context.Actions)
                {
                    m_nodeViewmodel.ExecuteNodeAction(action);
                }
            }

            base.RemoveConnection(removedConnection, otherPin);
        }
 public override void OnInputConnectionChanged(CNodeChangeContext context, CInputPin pin, COutputPin otherpin)
 {
     if (otherpin == null)
     {
         ChangePinType(context, OutputPins[1], typeof(object));
     }
     else
     {
         Type type = otherpin.Type;
         if (type.IsGenericType)
         {
             if (type.GetGenericTypeDefinition() == typeof(List <>))
             {
                 Type outputType = type.GenericTypeArguments[0];
                 if (outputType != OutputPins[1].Type)
                 {
                     ChangePinType(context, OutputPins[1], outputType);
                 }
             }
         }
     }
 }
示例#6
0
        public override void AddConnection(CNodeConnectionViewModel newConnection, CPinViewModel otherPin)
        {
            if (otherPin is COutputPinViewModel outputPin)
            {
                // Input pin can only be connected to a single node
                if (Connections.Count > 0)
                {
                    if (Connections.Count > 1)
                    {
                        List <CNodeConnectionViewModel> oldConnections = new List <CNodeConnectionViewModel>();
                        foreach (CNodeConnectionViewModel connection in Connections)
                        {
                            oldConnections.Add(connection);
                        }

                        foreach (CNodeConnectionViewModel connection in oldConnections)
                        {
                            connection.Disconnect();
                        }
                    }

                    Connections[0].Disconnect();
                }

                m_pin.SourceNode           = outputPin.NodeViewModel.ScriptNode;
                m_pin.SourceParameterIndex = outputPin.PinIndex;

                CNodeChangeContext context = new CNodeChangeContext();
                m_nodeViewmodel.ScriptNode.OnInputConnectionChanged(context, m_pin, outputPin.Pin);
                foreach (var action in context.Actions)
                {
                    m_nodeViewmodel.ExecuteNodeAction(action);
                }

                base.AddConnection(newConnection, otherPin);
            }
        }