Esempio n. 1
0
 public PathList[] GetPath(PathfinderNode[] StartNodes, PathfinderNode FinishNode, int Accuracy, int MinClearance)
 {
     int num;
     int num4;
     int num9;
     int num13 = StartNodes.GetUpperBound(0) + 1;
     PathList[] listArray2 = new PathList[(this.NodeLayerCount - 1) + 1];
     PathfinderNode[,] nodeArray3 = new PathfinderNode[(this.NodeLayerCount - 1) + 1, (num13 - 1) + 1];
     PathfinderNode[] nodeArray2 = new PathfinderNode[(this.NodeLayerCount - 1) + 1];
     PathfinderNode[] nodeArray = new PathfinderNode[0x18];
     int[] numArray2 = new int[0x18];
     bool[] flagArray = new bool[(num13 - 1) + 1];
     Path[] pathArray = new Path[0x18];
     float[] numArray = new float[0x18];
     bool[] flagArray2 = this.NetworkLargeArrays.Nodes_Booleans;
     float[] numArray3 = this.NetworkLargeArrays.Nodes_ValuesA;
     PathfinderNode[] nodeArray4 = this.NetworkLargeArrays.Nodes_Nodes;
     Path path = this.NetworkLargeArrays.Nodes_Path;
     int index = StartNodes[0].Layer.Network_LayerNum;
     nodeArray2[index] = FinishNode;
     int num2 = index;
     while (true)
     {
         if (nodeArray2[num2].ParentNode == null)
         {
             num9 = num2;
             break;
         }
         nodeArray2[num2 + 1] = nodeArray2[num2].ParentNode;
         num2++;
     }
     int num14 = num13 - 1;
     for (num = 0; num <= num14; num++)
     {
         nodeArray3[index, num] = StartNodes[num];
         num2 = index;
         while (true)
         {
             if (nodeArray3[num2, num].ParentNode == null)
             {
                 if (nodeArray3[num2, num] == nodeArray2[num2])
                 {
                     flagArray[num] = true;
                     num4++;
                 }
                 break;
             }
             nodeArray3[num2 + 1, num] = nodeArray3[num2, num].ParentNode;
             num2++;
         }
     }
     if (num4 != 0)
     {
         int num11 = num9;
         listArray2[num11].Paths = new Path[] { new Path() };
         listArray2[num11].PathCount = 1;
         listArray2[num11].Paths[0].Nodes = new PathfinderNode[] { nodeArray2[num11] };
         listArray2[num11].Paths[0].NodeCount = 1;
         do
         {
             int num3;
             int num5;
             int num6;
             int num7;
             bool flag;
             int num12;
             bool flag3;
             PathfinderNode node;
             PathfinderNode otherNode;
             int num10 = num11;
             num11--;
             if (num11 < index)
             {
                 return listArray2;
             }
             if (flag3)
             {
                 if (Accuracy < 0)
                 {
                     Debugger.Break();
                 }
                 int num15 = listArray2[num10].PathCount - 1;
                 for (num12 = 0; num12 <= num15; num12++)
                 {
                     numArray2[num12] = Math.Min(Accuracy, listArray2[num10].Paths[num12].NodeCount - 1);
                 }
                 nodeArray[0] = listArray2[num10].Paths[0].Nodes[numArray2[0]];
                 num6 = 1;
                 flag = true;
             }
             else
             {
                 if (Accuracy >= 0)
                 {
                     int num16 = listArray2[num10].PathCount - 1;
                     for (num12 = 0; num12 <= num16; num12++)
                     {
                         if (listArray2[num10].Paths[num12].NodeCount > Accuracy)
                         {
                             flag3 = true;
                             break;
                         }
                     }
                 }
                 nodeArray[0] = nodeArray2[num11];
                 if (num11 == index)
                 {
                     num6 = 1;
                 }
                 else
                 {
                     int num17 = nodeArray[0].ConnectionCount - 1;
                     num = 0;
                     while (num <= num17)
                     {
                         nodeArray[1 + num] = nodeArray[0].Connections[num].GetOtherNode(nodeArray[0]);
                         num++;
                     }
                     num6 = 1 + nodeArray[0].ConnectionCount;
                 }
                 int num18 = listArray2[num10].PathCount - 1;
                 for (num12 = 0; num12 <= num18; num12++)
                 {
                     numArray2[num12] = listArray2[num10].Paths[num12].NodeCount - 1;
                 }
                 flag = false;
             }
             int num19 = listArray2[num10].PathCount - 1;
             for (num12 = 0; num12 <= num19; num12++)
             {
                 int num20 = numArray2[num12];
                 num = 0;
                 while (num <= num20)
                 {
                     node = listArray2[num10].Paths[num12].Nodes[num];
                     int num21 = node.ConnectionCount - 1;
                     num5 = 0;
                     while (num5 <= num21)
                     {
                         otherNode = node.Connections[num5].GetOtherNode(node);
                         int num22 = otherNode.ConnectionCount - 1;
                         num7 = 0;
                         while (num7 <= num22)
                         {
                             num3 = otherNode.Connections[num7].GetOtherNode(otherNode).Layer_NodeNum;
                             flagArray2[num3] = false;
                             num7++;
                         }
                         num5++;
                     }
                     num++;
                 }
             }
             int num23 = listArray2[num10].PathCount - 1;
             num12 = 0;
             while (num12 <= num23)
             {
                 int num24 = numArray2[num12];
                 num = 0;
                 while (num <= num24)
                 {
                     node = listArray2[num10].Paths[num12].Nodes[num];
                     num3 = node.Layer_NodeNum;
                     flagArray2[num3] = true;
                     int num25 = node.NodeCount - 1;
                     num7 = 0;
                     while (num7 <= num25)
                     {
                         num3 = node.Nodes[num7].Layer_NodeNum;
                         numArray3[num3] = float.MaxValue;
                         num7++;
                     }
                     int num26 = node.ConnectionCount - 1;
                     for (num5 = 0; num5 <= num26; num5++)
                     {
                         otherNode = node.Connections[num5].GetOtherNode(node);
                         num3 = otherNode.Layer_NodeNum;
                         flagArray2[num3] = true;
                         int num27 = otherNode.NodeCount - 1;
                         for (num7 = 0; num7 <= num27; num7++)
                         {
                             num3 = otherNode.Nodes[num7].Layer_NodeNum;
                             numArray3[num3] = float.MaxValue;
                         }
                     }
                     num++;
                 }
                 num12++;
             }
             sFloodRouteArgs args = new sFloodRouteArgs {
                 CurrentPath = path,
                 FinishNodes = nodeArray,
                 FinishNodeCount = num6,
                 FinishIsParent = flag,
                 Visit = flagArray2,
                 NodeValues = numArray3,
                 SourceNodes = nodeArray4,
                 MinClearance = MinClearance
             };
             int num28 = num6 - 1;
             for (num = 0; num <= num28; num++)
             {
                 pathArray[num] = null;
                 numArray[num] = float.MaxValue;
             }
             int num29 = num13 - 1;
             for (num = 0; num <= num29; num++)
             {
                 if (flagArray[num])
                 {
                     path.NodeCount = 1;
                     path.Nodes[0] = nodeArray3[num11, num];
                     path.Value = 0f;
                     args.BestPaths = new Path[(num6 - 1) + 1];
                     this.FloodRoute(ref args);
                     int num30 = num6 - 1;
                     num12 = 0;
                     while (num12 <= num30)
                     {
                         if ((args.BestPaths[num12] != null) && (args.BestPaths[num12].Value < numArray[num12]))
                         {
                             numArray[num12] = args.BestPaths[num12].Value;
                             pathArray[num12] = args.BestPaths[num12];
                         }
                         num12++;
                     }
                 }
             }
             listArray2[num11].Paths = new Path[(num6 - 1) + 1];
             listArray2[num11].PathCount = 0;
             int num31 = num6 - 1;
             for (num12 = 0; num12 <= num31; num12++)
             {
                 if (pathArray[num12] != null)
                 {
                     listArray2[num11].Paths[listArray2[num11].PathCount] = pathArray[num12];
                     PathList[] listArray3 = listArray2;
                     int num32 = num11;
                     listArray3[num32].PathCount++;
                 }
             }
             listArray2[num11].Paths = (Path[]) Utils.CopyArray((Array) listArray2[num11].Paths, new Path[(listArray2[num11].PathCount - 1) + 1]);
         }
         while (listArray2[num11].PathCount != 0);
     }
     return null;
 }
Esempio n. 2
0
 public Path[] GetAllPaths(PathfinderNode[] StartNodes, PathfinderNode FinishNode, int MinClearance)
 {
     int num4;
     int num7;
     sFloodRouteAllArgs args;
     int num10 = StartNodes.GetUpperBound(0) + 1;
     PathfinderNode[,] nodeArray3 = new PathfinderNode[0x20, (num10 - 1) + 1];
     PathfinderNode[] nodeArray2 = new PathfinderNode[0x20];
     PathfinderNode[] nodeArray = new PathfinderNode[0x18];
     bool[] flagArray = new bool[(num10 - 1) + 1];
     Path[] pathArray2 = new Path[0x20];
     PathfinderNode[] nodeArray4 = this.NetworkLargeArrays.Nodes_Nodes;
     bool[] flagArray2 = this.NetworkLargeArrays.Nodes_Booleans;
     float[] numArray = this.NetworkLargeArrays.Nodes_ValuesA;
     float[] numArray2 = this.NetworkLargeArrays.Nodes_ValuesB;
     int index = StartNodes[0].Layer.Network_LayerNum;
     nodeArray2[index] = FinishNode;
     int num2 = index;
     while (true)
     {
         if (nodeArray2[num2].ParentNode == null)
         {
             num7 = num2;
             break;
         }
         nodeArray2[num2 + 1] = nodeArray2[num2].ParentNode;
         num2++;
     }
     int num11 = num10 - 1;
     int num = 0;
     while (num <= num11)
     {
         nodeArray3[index, num] = StartNodes[num];
         num2 = index;
         while (true)
         {
             if (nodeArray3[num2, num].ParentNode == null)
             {
                 if (nodeArray3[num2, num] == nodeArray2[num2])
                 {
                     flagArray[num] = true;
                     num4++;
                 }
                 break;
             }
             nodeArray3[num2 + 1, num] = nodeArray3[num2, num].ParentNode;
             num2++;
         }
         num++;
     }
     if (num4 == 0)
     {
         return null;
     }
     int num9 = num7;
     pathArray2[num9] = new Path();
     pathArray2[num9].Nodes = new PathfinderNode[] { nodeArray2[num9] };
     pathArray2[num9].NodeCount = 1;
     do
     {
         int num3;
         PathfinderNode node;
         int num8 = num9;
         num9--;
         if (num9 < index)
         {
             return pathArray2;
         }
         int num12 = pathArray2[num8].NodeCount - 1;
         num = 0;
         while (num <= num12)
         {
             node = pathArray2[num8].Nodes[num];
             int num13 = node.ConnectionCount - 1;
             for (num2 = 0; num2 <= num13; num2++)
             {
                 num3 = node.Connections[num2].GetOtherNode(node).Layer_NodeNum;
                 flagArray2[num3] = false;
             }
             num++;
         }
         int num14 = pathArray2[num8].NodeCount - 1;
         num = 0;
         while (num <= num14)
         {
             node = pathArray2[num8].Nodes[num];
             num3 = node.Layer_NodeNum;
             flagArray2[num3] = true;
             int num15 = node.NodeCount - 1;
             for (int i = 0; i <= num15; i++)
             {
                 num3 = node.Nodes[i].Layer_NodeNum;
                 numArray[num3] = float.MaxValue;
                 numArray2[num3] = float.MaxValue;
             }
             num++;
         }
         args = new sFloodRouteAllArgs {
             FinishNode = nodeArray2[num9],
             Visit = flagArray2,
             NodeValuesA = numArray,
             SourceNodes = nodeArray4,
             NodeValuesB = numArray2,
             MinClearance = MinClearance,
             BestTolerance = (float) Math.Pow(1.1, (double) num9),
             StartNodes = new PathfinderNode[(num10 - 1) + 1]
         };
         int num16 = num10 - 1;
         num = 0;
         while (num <= num16)
         {
             if (flagArray[num])
             {
                 args.StartNodes[args.StartNodeCount] = nodeArray3[num9, num];
                 args.StartNodeCount++;
             }
             num++;
         }
         args.StartNodes = (PathfinderNode[]) Utils.CopyArray((Array) args.StartNodes, new PathfinderNode[(args.StartNodeCount - 1) + 1]);
         this.FloodRouteAll(ref args);
         pathArray2[num9] = new Path();
         pathArray2[num9].Nodes = new PathfinderNode[(args.BestNodeCount - 1) + 1];
         int num17 = args.BestNodeCount - 1;
         for (num = 0; num <= num17; num++)
         {
             pathArray2[num9].Nodes[num] = args.SourceNodes[num];
         }
         pathArray2[num9].NodeCount = args.BestNodeCount;
     }
     while (args.BestNodeCount != 0);
     Debugger.Break();
     return pathArray2;
 }