public void Split() { int num; PathfinderNode parentNode; if (this.NodeCount != 4) { Debugger.Break(); } PathfinderNode nodeToAdd = null; PathfinderNode node2 = null; PathfinderNode node3 = null; PathfinderNode node4 = null; PathfinderConnection connection = null; PathfinderConnection connection2 = null; PathfinderNode[] nodeArray = new PathfinderNode[(this.NodeCount - 1) + 1]; int num8 = this.NodeCount - 1; for (num = 0; num <= num8; num++) { nodeArray[num] = this.Nodes[num]; } int nodeCount = this.NodeCount; PathfinderLayer newParentLayer = this.Layer; this.Disband(); float maxValue = float.MaxValue; int num9 = nodeCount - 1; for (num = 0; num <= num9; num++) { parentNode = nodeArray[num]; int num10 = nodeCount - 1; for (int i = num + 1; i <= num10; i++) { PathfinderNode node6 = nodeArray[i]; int num11 = nodeCount - 1; int index = 0; while (index <= num11) { if ((nodeArray[index] != parentNode) & (nodeArray[index] != node6)) { break; } index++; } PathfinderNode self = nodeArray[index]; int num12 = nodeCount - 1; int num6 = index + 1; while (num6 <= num12) { if ((nodeArray[num6] != parentNode) & (nodeArray[num6] != node6)) { break; } num6++; } PathfinderNode node8 = nodeArray[num6]; int num13 = parentNode.ConnectionCount - 1; index = 0; while (index <= num13) { connection = parentNode.Connections[index]; if (connection.GetOtherNode(parentNode) == node6) { break; } index++; } int num14 = self.ConnectionCount - 1; num6 = 0; while (num6 <= num14) { connection2 = self.Connections[num6]; if (connection2.GetOtherNode(self) == node8) { break; } num6++; } if ((index < parentNode.ConnectionCount) & (num6 < self.ConnectionCount)) { float num7 = connection.Value + connection2.Value; if (num7 < maxValue) { maxValue = num7; nodeToAdd = parentNode; node2 = node6; node3 = self; node4 = node8; } } } } if (nodeToAdd != null) { if (this.ParentNode != null) { parentNode = this.ParentNode; parentNode.Node_Remove(this.ParentNode_NodeNum); } else { parentNode = null; } if (parentNode != null) { parentNode.CheckIntegrity(); } PathfinderNode newFindParentNode = new PathfinderNode(newParentLayer); PathfinderNode node10 = new PathfinderNode(newParentLayer); newFindParentNode.Node_Add(nodeToAdd); newFindParentNode.Node_Add(node2); newFindParentNode.SpanCalc(); nodeToAdd.RaiseConnections(); node2.RaiseConnections(); newFindParentNode.Layer.Network.FindParentNode_Add(newFindParentNode); node10.Node_Add(node3); node10.Node_Add(node4); node10.SpanCalc(); node3.RaiseConnections(); node4.RaiseConnections(); node10.Layer.Network.FindParentNode_Add(node10); } else { Debugger.Break(); } }
public void FindParent() { PathfinderNode nodeToAdd = null; if ((this.NodeCount == 0) & (this.Layer.Network_LayerNum > 0)) { Debugger.Break(); } else if (this.ParentNode != null) { Debugger.Break(); } else { bool flag2; float maxValue = float.MaxValue; int num7 = this.ConnectionCount - 1; for (int i = 0; i <= num7; i++) { bool flag; float num6; PathfinderConnection connection = this.Connections[i]; PathfinderNode otherNode = connection.GetOtherNode(this); PathfinderNode parentNode = otherNode.ParentNode; if (parentNode == null) { parentNode = connection.GetOtherNode(this); num6 = connection.Value * (0.98f + (VBMath.Rnd() * 0.04f)); if (num6 < maxValue) { maxValue = num6; nodeToAdd = parentNode; flag2 = true; } continue; } if (parentNode.NodeCount == 3) { int num5 = 0; flag = false; int num8 = parentNode.NodeCount - 1; for (int j = 0; j <= num8; j++) { int num9 = parentNode.Nodes[j].ConnectionCount - 1; for (int k = 0; k <= num9; k++) { if (parentNode.Nodes[j].Connections[k].GetOtherNode(parentNode.Nodes[j]) == this) { num5++; if (num5 >= 2) { flag = true; } break; } } } } else { flag = true; } if (flag) { num6 = (otherNode.SiblingSpan + connection.Value) * (0.98f + (VBMath.Rnd() * 0.04f)); if (num6 < maxValue) { maxValue = num6; nodeToAdd = parentNode; flag2 = false; } } } if (nodeToAdd != null) { if (flag2) { PathfinderLayer parentLayer; if (this.Layer.ParentLayer == null) { parentLayer = new PathfinderLayer(this.Layer.Network); } else { parentLayer = this.Layer.ParentLayer; } PathfinderNode newFindParentNode = new PathfinderNode(parentLayer); newFindParentNode.Node_Add(this); newFindParentNode.Node_Add(nodeToAdd); newFindParentNode.SpanCalc(); this.RaiseConnections(); nodeToAdd.RaiseConnections(); newFindParentNode.Layer.Network.FindParentNode_Add(newFindParentNode); } else if (nodeToAdd != null) { nodeToAdd.Node_Add(this); if (nodeToAdd.NodeCount >= 4) { nodeToAdd.Split(); } else { nodeToAdd.SpanCalc(); this.RaiseConnections(); if (nodeToAdd.ParentNode == null) { nodeToAdd.Layer.Network.FindParentNode_Add(nodeToAdd); } } } } else if (this.ConnectionCount > 0) { PathfinderLayer layer2; if (this.Layer.ParentLayer == null) { layer2 = new PathfinderLayer(this.Layer.Network); } else { layer2 = this.Layer.ParentLayer; } PathfinderNode node5 = new PathfinderNode(layer2); node5.Node_Add(this); node5.SpanCalc(); this.RaiseConnections(); node5.Layer.Network.FindParentNode_Add(node5); } } }