void GetAvailable() { if (user == null) { return; } currentComputer = user.address.elements[user.address.depth - 1].computer; if (currentComputer == null) { return; } double startPercent = (double)user.address.elements[user.address.depth - 1].startPoint / (currentComputer.pointCount - 1); Spline.Direction dir = Spline.Direction.Forward; if (user.address.elements[user.address.depth - 1].startPoint > user.address.elements[user.address.depth - 1].endPoint) { dir = Spline.Direction.Backward; } int[] available = currentComputer.GetAvailableNodeLinksAtPosition(startPercent, dir); nodes = new List <Node>(); connectionIndices = new List <int>(); pointIndices = new List <int>(); for (int i = 0; i < available.Length; i++) { Node node = currentComputer.nodeLinks[available[i]].node; if (currentComputer.nodeLinks[available[i]].pointIndex == user.address.elements[user.address.depth - 1].startPoint) { continue; } Node.Connection[] connections = node.GetConnections(); for (int n = 0; n < connections.Length; n++) { if (connections[n].computer == currentComputer) { continue; } nodes.Add(node); connectionIndices.Add(n); pointIndices.Add(currentComputer.nodeLinks[available[i]].pointIndex); } } }
/// <summary> /// Used to get the available junctions. Call this to update the junction list on the GUI. /// </summary> public void GetAvailableJunctions() { //Get the last SplineComputer in the junction address currentComputer = follower.address.elements[follower.address.depth - 1].computer; if (currentComputer == null) { return; } //Get the available junctions at the current address double startPercent = (double)follower.address.elements[follower.address.depth - 1].startPoint / (currentComputer.pointCount - 1); Spline.Direction dir = Spline.Direction.Forward; if (follower.address.elements[follower.address.depth - 1].startPoint > follower.address.elements[follower.address.depth - 1].endPoint) { dir = Spline.Direction.Backward; } int[] available = currentComputer.GetAvailableNodeLinksAtPosition(startPercent, dir); nodes.Clear(); connectionIndices.Clear(); pointIndices.Clear(); //Make a list of the available junctions which to use in OnGUI for the buttons for (int i = 0; i < available.Length; i++) { Node node = currentComputer.nodeLinks[available[i]].node; if (currentComputer.nodeLinks[available[i]].pointIndex == follower.address.elements[follower.address.depth - 1].startPoint) { continue; } Node.Connection[] connections = node.GetConnections(); for (int n = 0; n < connections.Length; n++) { if (connections[n].computer == currentComputer) { continue; } nodes.Add(node); connectionIndices.Add(n); pointIndices.Add(currentComputer.nodeLinks[available[i]].pointIndex); } } }