// Token: 0x06001E07 RID: 7687 RVA: 0x000813BC File Offset: 0x0007F5BC public bool PerformStep() { List <NodeGraphSpider.StepInfo> list = this.uncheckedSteps; this.uncheckedSteps = new List <NodeGraphSpider.StepInfo>(); for (int i = 0; i < list.Count; i++) { NodeGraphSpider.StepInfo stepInfo = list[i]; foreach (NodeGraph.LinkIndex linkIndex in this.nodeGraph.GetActiveNodeLinks(stepInfo.node)) { if (this.nodeGraph.IsLinkSuitableForHull(linkIndex, this.hullMask)) { NodeGraph.NodeIndex linkEndNode = this.nodeGraph.GetLinkEndNode(linkIndex); if (!this.visitedNodes[linkEndNode.nodeIndex]) { this.uncheckedSteps.Add(new NodeGraphSpider.StepInfo { node = linkEndNode, previousStep = stepInfo }); this.visitedNodes[linkEndNode.nodeIndex] = true; } } } this.collectedSteps.Add(stepInfo); } return(list.Count > 0); }
// Token: 0x06001DF4 RID: 7668 RVA: 0x00080FE0 File Offset: 0x0007F1E0 private void ReconstructPath(Path path, NodeGraph.LinkIndex[] cameFrom, NodeGraph.LinkIndex current, NodeGraph.PathRequest pathRequest) { int num = 1 << (int)pathRequest.hullClassification; path.Clear(); if (current != NodeGraph.LinkIndex.invalid) { path.PushWaypointToFront(this.links[current.linkIndex].nodeIndexB, 0f); } while (current != NodeGraph.LinkIndex.invalid) { NodeGraph.NodeIndex nodeIndexB = this.links[current.linkIndex].nodeIndexB; float minJumpHeight = 0f; if ((num & this.links[current.linkIndex].jumpHullMask) != 0 && this.links[current.linkIndex].minJumpHeight > 0f) { Vector3 position = this.nodes[this.links[current.linkIndex].nodeIndexA.nodeIndex].position; Vector3 position2 = this.nodes[this.links[current.linkIndex].nodeIndexB.nodeIndex].position; minJumpHeight = Trajectory.CalculateApex(Trajectory.CalculateInitialYSpeed(Trajectory.CalculateGroundTravelTime(pathRequest.maxSpeed, NodeGraph.DistanceXZ(position, position2)), position2.y - position.y)); } path.PushWaypointToFront(nodeIndexB, minJumpHeight); if (cameFrom[this.links[current.linkIndex].nodeIndexA.nodeIndex] == NodeGraph.LinkIndex.invalid) { path.PushWaypointToFront(this.links[current.linkIndex].nodeIndexA, 0f); } current = cameFrom[this.links[current.linkIndex].nodeIndexA.nodeIndex]; } path.status = PathStatus.Valid; }
// Token: 0x06001DE5 RID: 7653 RVA: 0x000805E4 File Offset: 0x0007E7E4 public bool GetNodeFlags(NodeGraph.NodeIndex nodeIndex, out NodeFlags flags) { if (nodeIndex != NodeGraph.NodeIndex.invalid && nodeIndex.nodeIndex < this.nodes.Length) { flags = this.nodes[nodeIndex.nodeIndex].flags; return(true); } flags = NodeFlags.None; return(false); }
// Token: 0x06001DE4 RID: 7652 RVA: 0x00080590 File Offset: 0x0007E790 public bool GetNodePosition(NodeGraph.NodeIndex nodeIndex, out Vector3 position) { if (nodeIndex != NodeGraph.NodeIndex.invalid && nodeIndex.nodeIndex < this.nodes.Length) { position = this.nodes[nodeIndex.nodeIndex].position; return(true); } position = Vector3.zero; return(false); }
// Token: 0x06001DF1 RID: 7665 RVA: 0x00080AC8 File Offset: 0x0007ECC8 private static void ArrayRemoveNodeIndex(NodeGraph.NodeIndex[] array, NodeGraph.NodeIndex value, int count) { for (int i = 0; i < count; i++) { if (array[i] == value) { array[i] = array[count - 1]; return; } } }
// Token: 0x06001E08 RID: 7688 RVA: 0x000814AC File Offset: 0x0007F6AC public void AddNodeForNextStep(NodeGraph.NodeIndex nodeIndex) { if (!this.visitedNodes[nodeIndex.nodeIndex]) { this.uncheckedSteps.Add(new NodeGraphSpider.StepInfo { node = nodeIndex, previousStep = null }); this.visitedNodes[nodeIndex.nodeIndex] = true; } }
// Token: 0x06001DF3 RID: 7667 RVA: 0x00080F68 File Offset: 0x0007F168 private NodeGraph.LinkIndex Resolve(NodeGraph.LinkIndex[] cameFrom, NodeGraph.LinkIndex current) { if (current.linkIndex < 0 || current.linkIndex > this.links.Length) { Debug.LogFormat("Link {0} is out of range [0,{1})", new object[] { current.linkIndex, this.links.Length }); } NodeGraph.NodeIndex nodeIndexA = this.links[current.linkIndex].nodeIndexA; return(cameFrom[nodeIndexA.nodeIndex]); }
// Token: 0x06001DE6 RID: 7654 RVA: 0x00080624 File Offset: 0x0007E824 public NodeGraph.LinkIndex[] GetActiveNodeLinks(NodeGraph.NodeIndex nodeIndex) { if (nodeIndex != NodeGraph.NodeIndex.invalid && nodeIndex.nodeIndex < this.nodes.Length) { NodeGraph.LinkListIndex linkListIndex = this.nodes[nodeIndex.nodeIndex].linkListIndex; NodeGraph.LinkIndex[] array = new NodeGraph.LinkIndex[linkListIndex.size]; int index = linkListIndex.index; int num = 0; while ((long)num < (long)((ulong)linkListIndex.size)) { array[num] = new NodeGraph.LinkIndex { linkIndex = index++ }; num++; } return(array); } return(null); }
// Token: 0x06001DED RID: 7661 RVA: 0x00080930 File Offset: 0x0007EB30 public NodeGraph.NodeIndex FindClosestNode(Vector3 position, HullClassification hullClassification) { float num = float.PositiveInfinity; NodeGraph.NodeIndex invalid = NodeGraph.NodeIndex.invalid; int num2 = 1 << (int)hullClassification; for (int i = 0; i < this.nodes.Length; i++) { NodeGraph.Node node = this.nodes[i]; if ((node.forbiddenHulls & (HullMask)num2) == HullMask.None && (node.gateIndex == 0 || this.openGates[(int)node.gateIndex])) { float sqrMagnitude = (node.position - position).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; invalid = new NodeGraph.NodeIndex(i); } } } return(invalid); }
// Token: 0x06001DEE RID: 7662 RVA: 0x000809C0 File Offset: 0x0007EBC0 public NodeGraph.NodeIndex FindClosestNodeWithFlagConditions(Vector3 position, HullClassification hullClassification, NodeFlags requiredFlags, NodeFlags forbiddenFlags, bool preventOverhead) { float num = float.PositiveInfinity; NodeGraph.NodeIndex invalid = NodeGraph.NodeIndex.invalid; int num2 = 1 << (int)hullClassification; for (int i = 0; i < this.nodes.Length; i++) { NodeFlags flags = this.nodes[i].flags; if ((flags & forbiddenFlags) == NodeFlags.None && (flags & requiredFlags) == requiredFlags && (this.nodes[i].forbiddenHulls & (HullMask)num2) == HullMask.None && (this.nodes[i].gateIndex == 0 || this.openGates[(int)this.nodes[i].gateIndex])) { Vector3 a = this.nodes[i].position - position; float sqrMagnitude = a.sqrMagnitude; if (sqrMagnitude < num && (!preventOverhead || Vector3.Dot(a / Mathf.Sqrt(sqrMagnitude), Vector3.up) <= 0.70710677f)) { num = sqrMagnitude; invalid = new NodeGraph.NodeIndex(i); } } } return(invalid); }
// Token: 0x06001DF2 RID: 7666 RVA: 0x00080B04 File Offset: 0x0007ED04 public PathTask ComputePath(NodeGraph.PathRequest pathRequest) { PathTask pathTask = new PathTask(pathRequest.path); pathTask.status = PathTask.TaskStatus.Running; NodeGraph.NodeIndex nodeIndex = this.FindClosestNode(pathRequest.startPos, pathRequest.hullClassification); NodeGraph.NodeIndex nodeIndex2 = this.FindClosestNode(pathRequest.endPos, pathRequest.hullClassification); if (nodeIndex.nodeIndex == NodeGraph.NodeIndex.invalid.nodeIndex || nodeIndex2.nodeIndex == NodeGraph.NodeIndex.invalid.nodeIndex) { pathRequest.path.Clear(); pathTask.status = PathTask.TaskStatus.Complete; return(pathTask); } int num = 1 << (int)pathRequest.hullClassification; bool[] array = new bool[this.nodes.Length]; bool[] array2 = new bool[this.nodes.Length]; array2[nodeIndex.nodeIndex] = true; int i = 1; NodeGraph.NodeIndex[] array3 = new NodeGraph.NodeIndex[this.nodes.Length]; array3[0] = nodeIndex; NodeGraph.LinkIndex[] array4 = new NodeGraph.LinkIndex[this.nodes.Length]; for (int j = 0; j < array4.Length; j++) { array4[j] = NodeGraph.LinkIndex.invalid; } float[] array5 = new float[this.nodes.Length]; for (int k = 0; k < array5.Length; k++) { array5[k] = float.PositiveInfinity; } array5[nodeIndex.nodeIndex] = 0f; float[] array6 = new float[this.nodes.Length]; for (int l = 0; l < array6.Length; l++) { array6[l] = float.PositiveInfinity; } array6[nodeIndex.nodeIndex] = this.HeuristicCostEstimate(pathRequest.startPos, pathRequest.endPos); while (i > 0) { NodeGraph.NodeIndex invalid = NodeGraph.NodeIndex.invalid; float num2 = float.PositiveInfinity; for (int m = 0; m < i; m++) { int nodeIndex3 = array3[m].nodeIndex; if (array6[nodeIndex3] <= num2) { num2 = array6[nodeIndex3]; invalid = new NodeGraph.NodeIndex(nodeIndex3); } } if (invalid.nodeIndex == nodeIndex2.nodeIndex) { this.ReconstructPath(pathRequest.path, array4, array4[invalid.nodeIndex], pathRequest); pathTask.status = PathTask.TaskStatus.Complete; return(pathTask); } array2[invalid.nodeIndex] = false; NodeGraph.ArrayRemoveNodeIndex(array3, invalid, i); i--; array[invalid.nodeIndex] = true; NodeGraph.LinkListIndex linkListIndex = this.nodes[invalid.nodeIndex].linkListIndex; NodeGraph.LinkIndex linkIndex = new NodeGraph.LinkIndex { linkIndex = linkListIndex.index }; NodeGraph.LinkIndex linkIndex2 = new NodeGraph.LinkIndex { linkIndex = linkListIndex.index + (int)linkListIndex.size }; while (linkIndex.linkIndex < linkIndex2.linkIndex) { NodeGraph.Link link = this.links[linkIndex.linkIndex]; NodeGraph.NodeIndex nodeIndexB = link.nodeIndexB; if (!array[nodeIndexB.nodeIndex]) { if ((num & link.jumpHullMask) != 0 && this.links[linkIndex.linkIndex].minJumpHeight > 0f) { Vector3 position = this.nodes[link.nodeIndexA.nodeIndex].position; Vector3 position2 = this.nodes[link.nodeIndexB.nodeIndex].position; if (Trajectory.CalculateApex(Trajectory.CalculateInitialYSpeed(Trajectory.CalculateGroundTravelTime(pathRequest.maxSpeed, NodeGraph.DistanceXZ(position, position2)), position2.y - position.y)) > pathRequest.maxJumpHeight) { goto IL_41A; } } if ((link.hullMask & num) != 0 && (link.gateIndex == 0 || this.openGates[(int)link.gateIndex])) { float num3 = array5[invalid.nodeIndex] + link.distanceScore; if (!array2[nodeIndexB.nodeIndex]) { array2[nodeIndexB.nodeIndex] = true; array3[i] = nodeIndexB; i++; } else if (num3 >= array5[nodeIndexB.nodeIndex]) { goto IL_41A; } array4[nodeIndexB.nodeIndex] = linkIndex; array5[nodeIndexB.nodeIndex] = num3; array6[nodeIndexB.nodeIndex] = array5[nodeIndexB.nodeIndex] + this.HeuristicCostEstimate(this.nodes[nodeIndexB.nodeIndex].position, this.nodes[nodeIndex2.nodeIndex].position); } } IL_41A: linkIndex.linkIndex++; } } pathRequest.path.Clear(); pathTask.status = PathTask.TaskStatus.Complete; return(pathTask); }
// Token: 0x06001DE7 RID: 7655 RVA: 0x000806AC File Offset: 0x0007E8AC public bool TestNodeLineOfSight(NodeGraph.NodeIndex nodeIndexA, NodeGraph.NodeIndex nodeIndexB) { return(nodeIndexA != NodeGraph.NodeIndex.invalid && nodeIndexA.nodeIndex < this.nodes.Length && nodeIndexB != NodeGraph.NodeIndex.invalid && nodeIndexB.nodeIndex < this.nodes.Length && this.nodes[nodeIndexA.nodeIndex].lineOfSightMask[nodeIndexB.nodeIndex]); }
// Token: 0x06001DD9 RID: 7641 RVA: 0x0007FC08 File Offset: 0x0007DE08 public void SetNodes(ReadOnlyCollection <MapNode> mapNodes, ReadOnlyCollection <SerializableBitArray> lineOfSightMasks) { this.Clear(); Dictionary <MapNode, NodeGraph.NodeIndex> dictionary = new Dictionary <MapNode, NodeGraph.NodeIndex>(); List <NodeGraph.Node> list = new List <NodeGraph.Node>(); List <NodeGraph.Link> list2 = new List <NodeGraph.Link>(); for (int i = 0; i < mapNodes.Count; i++) { MapNode key = mapNodes[i]; dictionary[key] = new NodeGraph.NodeIndex(i); } for (int j = 0; j < mapNodes.Count; j++) { MapNode mapNode = mapNodes[j]; NodeGraph.NodeIndex nodeIndexA = dictionary[mapNode]; int count = list2.Count; for (int k = 0; k < mapNode.links.Count; k++) { MapNode.Link link = mapNode.links[k]; if (!dictionary.ContainsKey(link.nodeB)) { Debug.LogErrorFormat(link.nodeB, "[{0}] Node {1} was not registered.", new object[] { k, link.nodeB }); } list2.Add(new NodeGraph.Link { nodeIndexA = nodeIndexA, nodeIndexB = dictionary[link.nodeB], distanceScore = link.distanceScore, minJumpHeight = link.minJumpHeight, hullMask = link.hullMask, jumpHullMask = link.jumpHullMask, gateIndex = this.RegisterGateName(link.gateName) }); } HullMask hullMask = mapNode.forbiddenHulls; for (HullClassification hullClassification = HullClassification.Human; hullClassification < HullClassification.Count; hullClassification++) { bool flag = false; int num = 1 << (int)hullClassification; List <MapNode.Link> list3 = mapNode.links; for (int l = 0; l < list3.Count; l++) { if ((list3[l].hullMask & num) != 0) { flag = true; break; } } if (!flag) { hullMask |= (HullMask)num; } } list.Add(new NodeGraph.Node { position = mapNode.transform.position, linkListIndex = new NodeGraph.LinkListIndex { index = count, size = (uint)mapNode.links.Count }, forbiddenHulls = hullMask, flags = mapNode.flags, lineOfSightMask = new SerializableBitArray(lineOfSightMasks[j]), gateIndex = this.RegisterGateName(mapNode.gateName) }); } this.nodes = list.ToArray(); this.links = list2.ToArray(); }