Example #1
0
        protected override void OnTargetFieldChanged()
        {
            if (TargetField == null)
            {
                throw new NullReferenceException("Target Field cannot be null as this would make the node invalid");
            }
            InputPins.Clear();
            OutputPins.Clear();

            CInputPin targetObjectInput = new CInputPin("Target", TargetField.DeclaringType);

            InputPins.Add(targetObjectInput);

            Name = "Get " + TargetField.Name;

            COutputPin outputPin = new COutputPin(TargetField.Name, TargetField.FieldType);

            OutputPins.Add(outputPin);
        }
Example #2
0
        protected override void OnTargetPropertyChanged()
        {
            if (TargetProperty == null)
            {
                throw new NullReferenceException("Target Property cannot be null as this would make the node invalid");
            }
            InputPins.Clear();
            OutputPins.Clear();

            Name = "Set " + TargetProperty.Name;

            CInputPin targetObjectInput = new CInputPin("Target", TargetProperty.DeclaringType);

            InputPins.Add(targetObjectInput);

            CInputPin setValueInput = new CInputPin("Value", TargetProperty.PropertyType);

            InputPins.Add(setValueInput);

            COutputPin newValueOutput = new COutputPin("NewValue", TargetProperty.PropertyType);

            OutputPins.Add(newValueOutput);
        }
Example #3
0
 /// <summary>
 /// Notifies the node that the output of another pin has been connected to one of its input pins
 /// </summary>
 /// <param name="context">Context which contains all editor node actions that need to be executed after this call</param>
 /// <param name="pin">The pin on this node that got a new connection</param>
 /// <param name="otherpin">The pin this node has been connected to</param>
 /// <returns></returns>
 public virtual void OnInputConnectionChanged(CNodeChangeContext context, CInputPin pin, COutputPin otherpin)
 {
 }
Example #4
0
 /// <summary>
 /// Adds a new value output pin. This should only be called upon editor callback.
 /// </summary>
 /// <param name="context">Context which contains all editor node actions that need to be executed after this call</param>
 /// <param name="newPin">The new output pin that should be added</param>
 /// <param name="index">The index at which the output pin should be inserted</param>
 protected void AddOutputPin(CNodeChangeContext context, COutputPin newPin, int index)
 {
     OutputPins.Add(newPin);
     context.Actions.Add(new CAddPinChangeAction(newPin, index, false));
 }
        private void OnTargetMethodChanged()
        {
            OutputPins.Clear();
            InputPins.Clear();

            CKlaxScriptRegistry registry = CKlaxScriptRegistry.Instance;

            registry.TryGetFunctionInfo(TargetMethod, out CKlaxScriptFunctionInfo outFunctionInfo);

            Name = outFunctionInfo.displayName;

            if (TargetMethod.ReturnType != typeof(void))
            {
                COutputPin returnOutput = new COutputPin()
                {
                    Name = "Return",
                    Type = TargetMethod.ReturnType,
                };
                OutputPins.Add(returnOutput);
            }

            if (!TargetMethod.IsStatic)
            {
                CInputPin targetObjectInput = new CInputPin()
                {
                    Name                 = "Target",
                    Type                 = TargetMethod.DeclaringType,
                    Literal              = null,
                    SourceNode           = null,
                    SourceParameterIndex = -1,
                    StackIndex           = -1,
                };
                InputPins.Add(targetObjectInput);
            }

            ParameterInfo[] methodParameters = TargetMethod.GetParameters();
            for (var index = 0; index < methodParameters.Length; index++)
            {
                ParameterInfo parameter   = methodParameters[index];
                Type          elementType = parameter.ParameterType;
                if (parameter.ParameterType.IsByRef)
                {
                    elementType = parameter.ParameterType.GetElementType();
                    if (!parameter.IsIn)
                    {
                        m_additionalReturns.Add(index);
                        COutputPin output = new COutputPin()
                        {
                            Name = parameter.Name,
                            Type = elementType,
                        };
                        OutputPins.Add(output);
                    }
                }

                if (parameter.IsOut)
                {
                    continue;
                }

                CInputPin input = new CInputPin()
                {
                    Name                 = outFunctionInfo.inputParameterNames[index],
                    Type                 = elementType,
                    SourceNode           = null,
                    SourceParameterIndex = -1,
                    StackIndex           = -1,
                };

                input.Literal = input.Type.IsValueType ? Activator.CreateInstance(input.Type) : null;
                InputPins.Add(input);

                m_functionProxy = new SKlaxScriptFunctionProxy(outFunctionInfo);
            }
        }