public bool TryFinalizingConnection(WirePin targetPin)
 {
     if (targetPin.Connect(sourcePin, true))
     {
         sourcePin          = null;
         sourcePinDisplayer = null;
         MakingConnection   = false; // No more making the connection
         return(true);
     }
     MakingConnection = true;
     return(false);
 }
        public virtual void DrawWires()
        {
            foreach (WirePinDisplayer input in InputPinsDisplayer) // The wires are rendered by the node having the end of the connection (inputs)
            {
                WirePin          inputPin        = input.DisplayedWirePin;
                WirePinDisplayer targetDisplayer = (WirePinDisplayer)inputPin.WirePinDisplayer;

                Rect targetRect = new Rect(targetDisplayer.InteractionRect.position + WindowRect.position, targetDisplayer.InteractionRect.size);

                if (inputPin.IsConnected)
                {
                    WirePinDisplayer sourceDisplayer = (WirePinDisplayer)inputPin.GetConnectedPin().WirePinDisplayer;
                    Rect             sourceRect      = new Rect(
                        sourceDisplayer.InteractionRect.position + sourceDisplayer.OwnerDisplayer.WindowRect.position,
                        targetDisplayer.InteractionRect.size
                        );
                    WireGraphEditor.DrawNodeCurve(sourceRect, targetRect, WDEngine.ClassicWireColor);
                }
            }
        }
        private void SaveConnections()
        {
            // TODO : OPTIMIZATION
            List <PinConnection> pinConnections = new List <PinConnection>();

            foreach (WireNode node in equalityNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in greaterNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in inequalityNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in lesserNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in constantNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in sayReplyNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in branchNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in setAnimVarNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in getAnimVarNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in reunionNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in getVarNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            foreach (WireNode node in chooseReplyNodes)
            {
                foreach (WirePin pin in node.Inputs)
                {
                    if (pin.IsConnected)
                    {
                        WirePin       other      = pin.GetConnectedPin();
                        PinConnection connection = new PinConnection()
                        {
                            PinOne = pin.WirePinId,
                            PinTwo = other.WirePinId
                        };
                        pinConnections.Add(connection);
                    }
                }
            }

            connections = pinConnections;
        }
示例#4
0
 public WirePinDisplayer(WireNodeDisplayer owner, WirePin displayedWirePin)
 {
     OwnerDisplayer   = owner;
     DisplayedWirePin = displayedWirePin;
     DisplayedWirePin.WirePinDisplayer = this;
 }
 public void CancelConnection()
 {
     sourcePin          = null;
     sourcePinDisplayer = null;
     MakingConnection   = false;
 }
 public void BeginConnection(WirePin sourcePin)
 {
     this.sourcePin     = sourcePin;
     sourcePinDisplayer = (WirePinDisplayer)sourcePin.WirePinDisplayer;
     MakingConnection   = true;
 }