public CInputPinViewModel(CInputPin inputPin, CScriptNodeViewmodel nodeViewModel, int pinIndex) : base(nodeViewModel, pinIndex)
 {
     m_pin            = inputPin;
     Name             = inputPin.Name;
     Tooltip          = EditorKlaxScriptUtility.GetTypeName(inputPin.Type);
     m_pinColor       = PinColorHelpers.GetColorForType(inputPin.Type);
     m_nodeViewmodel  = nodeViewModel;
     m_literal        = inputPin.Literal;
     m_valueType      = inputPin.Type;
     m_bIsLiteralOnly = inputPin.bIsLiteralOnly;
 }
        public override bool CanConnect(CPinViewModel pinToCheck, out string failReason)
        {
            if (pinToCheck == null)
            {
                failReason = "Source not existing";
                return(false);
            }

            if (pinToCheck.NodeViewModel == NodeViewModel)
            {
                failReason = "Cannot connect to a pin on the same node";
                return(false);
            }

            if (pinToCheck is COutputPinViewModel)
            {
                failReason = "Output is not compatible with another output";
                return(false);
            }

            if (pinToCheck is CExecutionPinViewModel)
            {
                failReason = "Output is not compatible with execution";
                return(false);
            }

            if (pinToCheck is CInputPinViewModel inputPin)
            {
                if (inputPin.IsLiteralOnly)
                {
                    failReason = $"Input pin {inputPin.Name} can only be assigned a value by changing its literal value";
                    return(false);
                }

                if (!inputPin.ValueType.IsAssignableFrom(ValueType))
                {
                    failReason = "Output of type " + EditorKlaxScriptUtility.GetTypeName(ValueType) + " is not compatible with input of type " + EditorKlaxScriptUtility.GetTypeName(inputPin.ValueType);
                    return(false);
                }
            }

            failReason = "";
            return(true);
        }