public bool AddConnection(Node newCon) { // check if we already have this connection, we don't want to double up foreach (NavConnectionData data in connections) { if (data.node == newCon) { return(false); } } // copy connection array NavConnectionData newData = new NavConnectionData(newCon); newData.UpdateDistanceFromNode(this); connections.AddLast(newData); return(true); }
public void RemoveConnection(Node oldCon) { if (connections.Count == 0) { return; } bool didFindNode = false; NavConnectionData foundData = new NavConnectionData(); // find the connection foreach (NavConnectionData con in connections) { if (con.node == oldCon) { foundData = con; didFindNode = true; } } // remove the connection if (didFindNode == true) { connections.Remove(foundData); } }