Example #1
0
        public T AddLink <T>(T link, PortModel source, PortModel?target = null) where T : LinkModel
        {
            link.Type = Options.Links.DefaultLinkType;
            source.AddLink(link);

            if (target == null)
            {
                link.OnGoingPosition = new Point(source.Position.X + source.Size.Width / 2,
                                                 source.Position.Y + source.Size.Height / 2);
            }
            else
            {
                target.AddLink(link);
            }

            source.Refresh();
            target?.Refresh();

            source.Parent.Group?.Refresh();
            target?.Parent.Group?.Refresh();

            LinkAdded?.Invoke(link);
            Changed?.Invoke();
            return(link);
        }
        public NodeEditorPanel(IGUI _gui,
                               EditorWindow _editorWindow,
                               ConstellationScript _script,
                               IUndoable _undoable,
                               ClipBoard _editorClipBoard,
                               float positionX,
                               float positionY,
                               LinkAdded linkAdded,
                               NodeAdded nodeAdded,
                               NodeRemoved nodeRemoved)
        {
            nodesFactory        = new NodesFactory();
            constellationScript = _script;
            undoable            = _undoable;
            Nodes            = new List <NodeView> ();
            GUI              = _gui;
            EditorWindow     = _editorWindow;
            editorScrollSize = new Vector2(500, 500);
            Background       = AssetDatabase.LoadAssetAtPath(editorPath + "background.png", typeof(Texture2D)) as Texture2D;
            var allNodes = NodesFactory.GetAllNodes();

            nodes           = new string[allNodes.Length];
            editorScrollPos = new Vector2(positionX, positionY);
            for (var i = 0; i < allNodes.Length; i++)
            {
                nodes[i] = allNodes[i];
            }
            OnLinkAdded        += linkAdded;
            OnNodeAdded        += nodeAdded;
            OnNodeRemoved      += nodeRemoved;
            nodeEditorSelection = new NodeEditorSelection(GUI, _editorClipBoard);
        }
        public SensorBoneLink CreateLink(Bone bone, Sensor sensor)
        {
            if (links.ContainsKey(bone))
            {
                var removedLink = links[bone];
                links.Remove(bone);
                LinkRemoved?.Invoke(removedLink);
            }

            var link = new SensorBoneLink(bone, sensor);

            links.Add(bone, link);
            LinkAdded?.Invoke(link);

            return(link);
        }
 public NodeEditorLinks(ConstellationScript _constellationScript,
                        bool _isInstance,
                        IGUI _gui,
                        NodeConfig _nodeConfig,
                        LinkAdded _onLinkAdded, LinkRemoved _onLinkRemoved,
                        NodeEditorPanel _nodeEditorPannel,
                        IUndoable _undoable)
 {
     OnLinkAdded        += _onLinkAdded;
     OnLinkRemoved      += _onLinkRemoved;
     undoable            = _undoable;
     constellationScript = _constellationScript;
     isInstance          = _isInstance;
     GUI       = _gui;
     LinksView = new LinkView(GUI, _nodeEditorPannel, constellationScript, _nodeConfig, linkRemoved);
 }
Example #5
0
        public T AddLink <T>(PortModel source, PortModel?target = null) where T : LinkModel
        {
            var link = (T)Activator.CreateInstance(typeof(T), source, target);

            link.Type = Options.DefaultLinkType;
            source.AddLink(link);

            if (target == null)
            {
                link.OnGoingPosition = new Point(source.Position.X + source.Size.Width / 2,
                                                 source.Position.Y + source.Size.Height / 2);
            }
            else
            {
                target.AddLink(link);
            }

            LinkAdded?.Invoke(link);
            Changed?.Invoke();
            return(link);
        }
Example #6
0
        public static bool CreateLink(InputData _input, OutputData _output, ConstellationScriptData constellationScript, LinkValid linkIsValid, LinkAdded linkCreated)
        {
            if (_output != null && _output.Type == UNDEFINED && _input != null && _input.Type != UNDEFINED)
            {
                return(false);
            }

            //if ()
            if (IsTypeValid(_input, _output))
            {
                var newLink = new LinkData(_input, _output);
                if (TypeConst.IsLinkValid(newLink, constellationScript))
                {
                    linkIsValid();
                    constellationScript.AddLink(newLink);
                    linkCreated(newLink.GUID);
                    return(true);
                }
            }
            return(false);
        }