Esempio n. 1
0
    private void OnTriggerEnter(Collider other)
    {
        Pipe connectedPipe = other.GetComponent <Pipe>();

        if (connectedPipe != null)
        {
            pipeNodeData.AddNeighbor(connectedPipe.pipeNodeData);
            Mouledoux.Components.Mediator.NotifySubscribers("PipeModify");
        }
    }
Esempio n. 2
0
        // ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        public int TradeNeighbors(Node a_neighbor)
        {
            if (a_neighbor == null)
            {
                return(-1);
            }
            else if (!m_neighbors.Contains(a_neighbor))
            {
                return(-2);
            }

            Node[] myNeighbors;


            // // Remove eachother as neighbors, so they aren't neighbors to themselves
            // RemoveNeighbor(a_neighbor);
            // a_neighbor.RemoveNeighbor(this);

            // Save this node neighbors to a temp array
            myNeighbors = m_neighbors.ToArray();


            ClearNeighbors();                               // Clear this node's neighbors
            foreach (Node n in a_neighbor.GetNeighbors())   // For each neighbor of my neighbor
            {
                AddNeighbor(n);                             // Copy it to this node's neighbors
            }
            AddNeighbor(a_neighbor);                        // Add the neighbor back to this node's neighbors


            a_neighbor.ClearNeighbors();                    // Clear the neighbor's neighbors
            foreach (Node n in myNeighbors)                 // For each node in the temp array
            {
                a_neighbor.AddNeighbor(n);                  // Copy it to the neighbor's new neighbors
            }
            a_neighbor.AddNeighbor(this);                   // Add this node back to the neighbor's neighbors

            return(0);
        }
Esempio n. 3
0
        // ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        public int AddNeighbor(Node a_newNeighbor)
        {
            if (a_newNeighbor == null)
            {
                return(-1);
            }
            else if (a_newNeighbor == this)
            {
                return(-2);
            }

            if (!m_neighbors.Contains(a_newNeighbor))
            {
                m_neighbors.Add(a_newNeighbor);
            }

            if (!a_newNeighbor.m_neighbors.Contains(this))
            {
                a_newNeighbor.AddNeighbor(this);
            }

            return(0);
        }