Exemple #1
0
 //this method will be called twice per link removed, one per link's anchor.
 public void                             RemoveLink(PWNodeLink link)
 {
     if (!linkTable.Remove(link.GUID))
     {
         Debug.LogWarning("[LinkTable] Attempt to remove inexistent link at GUID: " + link.GUID);
     }
 }
Exemple #2
0
        public PWNodeLink               GetLinkFromGUID(string linkGUID)
        {
            PWNodeLink ret = null;

            linkTable.TryGetValue(linkGUID, out ret);
            return(ret);
        }
Exemple #3
0
 //retarget link and node events to GraphStructure event
 void            LinkPostAddedCallback(PWNodeLink link)
 {
     if (OnGraphStructureChanged != null)
     {
         OnGraphStructureChanged();
     }
 }
Exemple #4
0
        public void AddLink(PWNodeLink link)
        {
            linkGUIDs.Add(link.GUID);
            links.Add(link);

            //update anchorFieldRef (for multiple anchors)
            anchorFieldRef.UpdateAnchors();
        }
Exemple #5
0
        //Check errors when transferring values from a node to another
        bool CheckProcessErrors(PWNodeLink link, PWNode node, bool realMode)
        {
            if (!realMode)
            {
                if (link.fromAnchor == null || link.toAnchor == null)
                {
                    Debug.LogError("[PW Process] null anchors in link: " + link + ", from node: " + node + ", trying to removing this link");
                    currentGraph.RemoveLink(link, false);
                    return(true);
                }

                var fromType = Type.GetType(link.fromNode.classAQName);
                var toType   = Type.GetType(link.toNode.classAQName);

                if (!nodesDictionary.ContainsKey(link.toNode.id))
                {
                    Debug.LogError("[PW Process] " + "node id (" + link.toNode.id + ") not found in nodes dictionary");
                    return(true);
                }

                if (nodesDictionary[link.toNode.id] == null)
                {
                    Debug.LogError("[PW Process] " + "node id (" + link.toNode.id + ") is null in nodes dictionary");
                    return(true);
                }

                if (!bakedNodeFields.ContainsKey(link.fromNode.classAQName) ||
                    !bakedNodeFields[link.fromNode.classAQName].ContainsKey(link.fromAnchor.fieldName))
                {
                    Debug.LogError("[PW Process] Can't find field: "
                                   + link.fromAnchor.fieldName + " in " + fromType);
                    return(true);
                }

                if (!bakedNodeFields.ContainsKey(link.toNode.classAQName) ||
                    !bakedNodeFields[link.toNode.classAQName].ContainsKey(link.toAnchor.fieldName))
                {
                    Debug.LogError("[PW Process] Can't find field: "
                                   + link.toAnchor.fieldName + " in " + toType);
                    return(true);
                }

                if (bakedNodeFields[link.fromNode.classAQName][link.fromAnchor.fieldName].GetValue(node) == null)
                {
                    Debug.Log("[PW Process] tring to assign null value from "
                              + fromType + "." + link.fromAnchor.fieldName);
                    return(true);
                }
            }

            return(false);
        }
Exemple #6
0
        //to be called, fmorAnchor and toAnchor fields in PWNodeLink must be valid
        public void                             AddLink(PWNodeLink link)
        {
            if (link.fromAnchor == null || link.toAnchor == null)
            {
                Debug.LogWarning("[LinkTable] Failed to add link because these anchors are null");
                return;
            }
            if (linkTable.ContainsKey(link.GUID))
            {
                Debug.LogWarning("[LinkTable] Attempt to add a link already in tha linkTable");
                return;
            }

            linkTable[link.GUID] = link;
        }
Exemple #7
0
        //remove the link reference stored inside this anchor
        public void RemoveLinkReference(PWNodeLink link)
        {
            if (!linkGUIDs.Remove(link.GUID))
            {
                Debug.LogError("[PWAnchor] Tried to remove inexistant link GUID: " + link.GUID);
            }
            if (!links.Remove(link))
            {
                Debug.LogError("[PWAnchor] Tried to remove link: " + link);
            }

            //set to null the object value if we're not anymore linked
            if (anchorType == PWAnchorType.Input && linkCount == 0)
            {
                nodeRef.SetAnchorValue(this, null);
            }

            //update anchor group
            anchorFieldRef.UpdateAnchors();
        }
Exemple #8
0
        public void             RemoveLink(PWNodeLink link, bool raiseEvents = true)
        {
            if (OnLinkRemoved != null && raiseEvents)
            {
                OnLinkRemoved(link);
            }

            if (link.fromAnchor != null)
            {
                link.fromAnchor.RemoveLinkReference(link);
            }
            if (link.toAnchor != null)
            {
                link.toAnchor.RemoveLinkReference(link);
            }
            nodeLinkTable.RemoveLink(link);

            if (OnPostLinkRemoved != null && raiseEvents)
            {
                OnPostLinkRemoved();
            }
        }
Exemple #9
0
        //create a link without checking for duplication
        public PWNodeLink       CreateLink(PWAnchor fromAnchor, PWAnchor toAnchor, bool raiseEvents = true)
        {
            PWNodeLink link    = new PWNodeLink();
            PWAnchor   fAnchor = fromAnchor;
            PWAnchor   tAnchor = toAnchor;

            //swap anchors if input/output are reversed
            if (fromAnchor.anchorType != PWAnchorType.Output)
            {
                tAnchor = fromAnchor;
                fAnchor = toAnchor;
            }

            if (!PWAnchorUtils.AnchorAreAssignable(fAnchor, tAnchor))
            {
                Debug.LogWarning("[PWGraph] attempted to create a link between unlinkable anchors: " + fAnchor.fieldType + " into " + tAnchor.fieldType);
                return(null);
            }

            link.Initialize(fAnchor, tAnchor);
            nodeLinkTable.AddLink(link);

            //raise link creation event
            if (OnLinkCreated != null && raiseEvents)
            {
                OnLinkCreated(link);
            }

            link.fromNode.AddLink(link);
            link.toNode.AddLink(link);

            if (OnPostLinkCreated != null && raiseEvents)
            {
                OnPostLinkCreated(link);
            }

            return(link);
        }