Esempio n. 1
0
        public override ConnectionPort CreateNew(Node body)
        {
            FSMInputNode knob = ScriptableObject.CreateInstance <FSMInputNode>();

            knob.Init(body, Name, Direction, StyleID, NodeSide, NodeSidePos);
            knob.maxConnectionCount = MaxConnectionCount;
            return(knob);
        }
Esempio n. 2
0
        public override bool CanApplyConnection(ConnectionPort port)
        {
            if (port is FSMInputNode)
            {
                FSMInputNode valueKnob = port as FSMInputNode;
                if (valueKnob == null || !valueType.IsAssignableFrom(valueKnob.valueType))
                {
                    return(false);
                }

                if (valueKnob == null || body == valueKnob.body || connections.Contains(valueKnob))
                {
                    return(false);
                }

                if (direction == Direction.None && valueKnob.direction == Direction.None)
                {
                    return(true); // None-Directive connections can always connect
                }
                if (direction == Direction.In && valueKnob.direction != Direction.Out)
                {
                    return(false); // Cannot connect inputs with anything other than outputs
                }
                if (direction == Direction.Out && valueKnob.direction != Direction.In)
                {
                    return(false);              // Cannot connect outputs with anything other than inputs
                }
                if (direction == Direction.Out) // Let inputs handle checks for recursion
                {
                    return(base.CanApplyConnection(this));
                }

                return(true);
            }

            return(false);
        }