Klak.Wiring.Patcher.Patch.GetNodeOfInstance C# (CSharp) Method

GetNodeOfInstance() public method

public GetNodeOfInstance ( Wiring instance ) : Node
instance Wiring
return Node
        public Node GetNodeOfInstance(Wiring.NodeBase instance)
        {
            return _instanceIDToNodeMap[instance.GetInstanceID()];
        }

Usage Example

Beispiel #1
0
        // Enumerate all links from the outlets and cache them.
        void CacheLinks(Patch patch)
        {
            _cachedLinks = new List <NodeLink>();

            foreach (var outlet in _outlets)
            {
                // Scan all the events from the outlet.
                var boundEvent  = outlet.boundEvent;
                var targetCount = boundEvent.GetPersistentEventCount();
                for (var i = 0; i < targetCount; i++)
                {
                    var target = boundEvent.GetPersistentTarget(i);

                    // Ignore it if it's a null event or the target is not a node.
                    if (target == null || !(target is Wiring.NodeBase))
                    {
                        continue;
                    }

                    // Try to retrieve the linked inlet.
                    var targetNode = patch.GetNodeOfInstance((Wiring.NodeBase)target);
                    var methodName = boundEvent.GetPersistentMethodName(i);
                    var inlet      = targetNode.GetInletWithName(methodName);

                    // Cache it if it's a valid link.
                    if (targetNode != null && inlet != null)
                    {
                        _cachedLinks.Add(new NodeLink(this, outlet, targetNode, inlet));
                    }
                }
            }
        }
All Usage Examples Of Klak.Wiring.Patcher.Patch::GetNodeOfInstance