Ejemplo n.º 1
0
        public bool CanConnect(Socket target)
        {
            if (target == null)
            {
                return false;
            }
            if (Parent == target.Parent)
            {
                return false;
            }
            // Check if the source is an input socket. If it is, the target cannot be an input socket as well.
            if (Index < Parent.InputCount && target.Index < target.Parent.InputCount)
            {
                return false;
            }
            // Check if the source is an output socket. If it is, the target cannot be an output socket as well.
            if (Index >= Parent.InputCount && target.Index >= target.Parent.InputCount)
            {
                return false;
            }
            if (IsConnectedTo(target))
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 2
0
        public void Connect(Socket other)
        {
            if (m_acceptMultipleConnections)
            {
                m_sockets.Add(other);
                other.m_sockets.Add(this);
            }
            else
            {
                foreach(Socket socket in m_sockets)
                {
                    socket.Disconnect(this);
                }

                m_sockets.Clear();
                m_sockets.Add(other);
                other.m_sockets.Clear();
                other.m_sockets.Add(this);
            }
        }
Ejemplo n.º 3
0
 public void DrawSocket(Socket socket, bool isInput)
 {
     GUI.DrawTexture(m_socketRect, m_socketTexture);
     m_guiStyle.alignment = (isInput) ? TextAnchor.MiddleLeft : TextAnchor.MiddleRight;
     GUI.Label(m_labelRect, socket.Label, m_guiStyle);
 }
Ejemplo n.º 4
0
 public bool IsConnectedTo(Socket other)
 {
     return m_sockets.Contains(other);
 }
Ejemplo n.º 5
0
 public void Disconnect(Socket other)
 {
     other.m_sockets.Remove(this);
     m_sockets.Remove(other);
 }