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; }
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); } }
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); }
public bool IsConnectedTo(Socket other) { return m_sockets.Contains(other); }
public void Disconnect(Socket other) { other.m_sockets.Remove(this); m_sockets.Remove(other); }