Exemplo n.º 1
0
 public PathfinderConnection(PathfinderConnection SourceConnection)
 {
     this.Layer_ConnectionNum = -1;
     this.NodeA_ConnectionNum = -1;
     this.NodeB_ConnectionNum = -1;
     this.Value = 1f;
     this.CalcValueNum = -1;
     this.NodeA = SourceConnection.NodeA.ParentNode;
     this.NodeB = SourceConnection.NodeB.ParentNode;
     this.NodeA.Connection_Add(this, ref this.NodeA_ConnectionNum);
     this.NodeB.Connection_Add(this, ref this.NodeB_ConnectionNum);
     this.NodeA.Layer.Connection_Add(this);
     this.ValueCalc();
 }
Exemplo n.º 2
0
 public void Connection_Add(PathfinderConnection NewConnection)
 {
     if (this.Connections.GetUpperBound(0) < this.ConnectionCount)
     {
         this.Connections = (PathfinderConnection[]) Utils.CopyArray((Array) this.Connections, new PathfinderConnection[(((this.ConnectionCount + 1) * 2) - 1) + 1]);
     }
     this.Connections[this.ConnectionCount] = NewConnection;
     this.Connections[this.ConnectionCount].Layer_ConnectionNum = this.ConnectionCount;
     this.ConnectionCount++;
 }
Exemplo n.º 3
0
 public clsResult GenerateRamps()
 {
     int num;
     int num6;
     int num7;
     int num9;
     clsResult result2 = new clsResult("Ramps");
     int num13 = this.ConnectionCount - 1;
     for (num = 0; num <= num13; num++)
     {
         this.Connections[num].IsRamp = false;
     }
     clsPassageNodeNework nework = this.MakePassageNodeNetwork();
     PathfinderNode[,] passageNodePathNodes = nework.PassageNodePathNodes;
     clsConnection[] connectionArray = new clsConnection[(this.ConnectionCount - 1) + 1];
     PathfinderNode[] startNodes = new PathfinderNode[1];
     bool[] flagArray = new bool[(this.ConnectionCount - 1) + 1];
     int num14 = this.ConnectionCount - 1;
     int index = 0;
     while (index <= num14)
     {
         if (Math.Abs((int) (this.Connections[index].PassageNodeA.Level - this.Connections[index].PassageNodeB.Level)) == 1)
         {
             if ((!(this.Connections[index].PassageNodeA.IsOnBorder | this.Connections[index].PassageNodeB.IsOnBorder) & (this.Connections[index].PassageNodeA.MirrorNum == 0)) & (this.Connections[index].PassageNodeA.Num != this.Connections[index].PassageNodeB.Num))
             {
                 flagArray[index] = true;
             }
             else
             {
                 flagArray[index] = false;
             }
         }
         else
         {
             flagArray[index] = false;
         }
         index++;
     }
     clsNodeConnectedness connectedness = new clsNodeConnectedness {
         NodeConnectedness = new float[(this.PassageNodeCount - 1) + 1],
         PassageNodeVisited = new bool[(this.SymmetryBlockCount - 1) + 1, (this.PassageNodeCount - 1) + 1],
         PassageNodePathNodes = passageNodePathNodes,
         PassageNodePathMap = nework.Network
     };
     PathfinderConnection[] connectionArray2 = new PathfinderConnection[4];
     clsUpdateNodeConnectednessArgs args3 = new clsUpdateNodeConnectednessArgs();
     clsUpdateNetworkConnectednessArgs args2 = new clsUpdateNetworkConnectednessArgs();
     args3.Args = connectedness;
     args2.Args = connectedness;
     args2.PassageNodeUpdated = new bool[(this.PassageNodeCount - 1) + 1];
     args2.SymmetryBlockCount = this.SymmetryBlockCount;
     int num15 = this.PassageNodeCount - 1;
     for (num = 0; num <= num15; num++)
     {
         connectedness.NodeConnectedness[num] = 0f;
         int num16 = this.PassageNodeCount - 1;
         for (index = 0; index <= num16; index++)
         {
             int num17 = this.SymmetryBlockCount - 1;
             num7 = 0;
             while (num7 <= num17)
             {
                 connectedness.PassageNodeVisited[num7, index] = false;
                 num7++;
             }
         }
         args3.OriginalNode = this.PassageNodes[0, num];
         this.UpdateNodeConnectedness(args3, this.PassageNodes[0, num]);
     }
     Label_0269:
     num6 = -1;
     double num4 = 1.0;
     double num5 = 0.0;
     int num10 = 0;
     int num18 = this.ConnectionCount - 1;
     index = 0;
     while (index <= num18)
     {
         if (flagArray[index] & !this.Connections[index].IsRamp)
         {
             if (this.CheckRampAngles(this.Connections[index], 1.3962634015954636, 2.0943951023931953, 0.0))
             {
                 modMath.sXY_int _int;
                 startNodes[0] = passageNodePathNodes[this.Connections[index].PassageNodeA.MirrorNum, this.Connections[index].PassageNodeA.Num];
                 PathfinderNetwork.PathList[] listArray = nework.Network.GetPath(startNodes, passageNodePathNodes[this.Connections[index].PassageNodeB.MirrorNum, this.Connections[index].PassageNodeB.Num], -1, 0);
                 double maxValue = double.MaxValue;
                 _int.X = (int) Math.Round((double) (((double) (this.Connections[index].PassageNodeA.Pos.X + this.Connections[index].PassageNodeB.Pos.X)) / 2.0));
                 _int.Y = (int) Math.Round((double) (((double) (this.Connections[index].PassageNodeA.Pos.Y + this.Connections[index].PassageNodeB.Pos.Y)) / 2.0));
                 int num19 = this.TotalPlayerCount - 1;
                 num9 = 0;
                 while (num9 <= num19)
                 {
                     modMath.sXY_int _int2 = this.PlayerBases[num9].Pos - _int;
                     double magnitude = _int2.ToDoubles().GetMagnitude();
                     if (magnitude < maxValue)
                     {
                         maxValue = magnitude;
                     }
                     num9++;
                 }
                 double num11 = Math.Max((double) (this.MaxDisconnectionDist * Math.Pow(this.RampBase, maxValue / 1024.0)), (double) 1.0);
                 if (listArray == null)
                 {
                     double num12 = connectedness.NodeConnectedness[this.Connections[index].PassageNodeA.Num] + connectedness.NodeConnectedness[this.Connections[index].PassageNodeB.Num];
                     if (double.MaxValue > num4)
                     {
                         num4 = double.MaxValue;
                         num5 = num12;
                         connectionArray[0] = this.Connections[index];
                         num10 = 1;
                     }
                     else if (num12 < num5)
                     {
                         num5 = num12;
                         connectionArray[0] = this.Connections[index];
                         num10 = 1;
                     }
                     else if (num12 == num5)
                     {
                         connectionArray[num10] = this.Connections[index];
                         num10++;
                     }
                 }
                 else
                 {
                     if (listArray[0].PathCount != 1)
                     {
                         result2.ProblemAdd("Error: Invalid number of routes returned.");
                         goto Label_088A;
                     }
                     if ((((double) listArray[0].Paths[0].Value) / num11) > num4)
                     {
                         num4 = ((double) listArray[0].Paths[0].Value) / num11;
                         connectionArray[0] = this.Connections[index];
                         num10 = 1;
                     }
                     else if ((((double) listArray[0].Paths[0].Value) / num11) == num4)
                     {
                         connectionArray[num10] = this.Connections[index];
                         num10++;
                     }
                     else if (listArray[0].Paths[0].Value <= num11)
                     {
                         flagArray[index] = false;
                     }
                 }
             }
             else
             {
                 flagArray[index] = false;
             }
         }
         else
         {
             flagArray[index] = false;
         }
         index++;
     }
     if (num10 > 0)
     {
         num6 = (int) Math.Round((double) ((float) (App.Random.Next() * num10)));
         connectionArray[num6].IsRamp = true;
         clsPassageNode passageNodeA = connectionArray[num6].PassageNodeA;
         clsPassageNode passageNodeB = connectionArray[num6].PassageNodeB;
         PathfinderNode nodeA = passageNodePathNodes[passageNodeA.MirrorNum, passageNodeA.Num];
         PathfinderNode otherNode = passageNodePathNodes[passageNodeB.MirrorNum, passageNodeB.Num];
         PathfinderConnection connection = nodeA.CreateConnection(otherNode, this.GetNodePosDist(nodeA, otherNode));
         int num20 = connectionArray[num6].ReflectionCount - 1;
         for (num7 = 0; num7 <= num20; num7++)
         {
             connectionArray[num6].Reflections[num7].IsRamp = true;
             passageNodeA = connectionArray[num6].Reflections[num7].PassageNodeA;
             passageNodeB = connectionArray[num6].Reflections[num7].PassageNodeB;
             nodeA = passageNodePathNodes[passageNodeA.MirrorNum, passageNodeA.Num];
             otherNode = passageNodePathNodes[passageNodeB.MirrorNum, passageNodeB.Num];
             connection = nodeA.CreateConnection(otherNode, this.GetNodePosDist(nodeA, otherNode));
         }
         nework.Network.FindCalc();
         int num21 = this.PassageNodeCount - 1;
         for (num9 = 0; num9 <= num21; num9++)
         {
             args2.PassageNodeUpdated[num9] = false;
         }
         if (connectionArray[num6].PassageNodeA.MirrorNum == 0)
         {
             this.UpdateNetworkConnectedness(args2, connectionArray[num6].PassageNodeA);
             goto Label_0269;
         }
         if (connectionArray[num6].PassageNodeB.MirrorNum == 0)
         {
             this.UpdateNetworkConnectedness(args2, connectionArray[num6].PassageNodeB);
             goto Label_0269;
         }
         result2.ProblemAdd("Error: Initial ramp not in area 0.");
     }
     else
     {
         PathfinderNetwork.sFloodProximityArgs args;
         args.StartNode = nework.PassageNodePathNodes[0, 0];
         args.NodeValues = nework.Network.NetworkLargeArrays.Nodes_ValuesA;
         int num22 = this.PassageNodeCount - 1;
         for (num = 0; num <= num22; num++)
         {
             int num23 = this.SymmetryBlockCount - 1;
             index = 0;
             while (index <= num23)
             {
                 args.NodeValues[nework.PassageNodePathNodes[index, num].Layer_NodeNum] = float.MaxValue;
                 index++;
             }
         }
         nework.Network.FloodProximity(ref args);
         int num24 = this.PassageNodeCount - 1;
         for (num = 0; num <= num24; num++)
         {
             int num25 = this.SymmetryBlockCount - 1;
             for (index = 0; index <= num25; index++)
             {
                 if (!this.PassageNodes[index, num].IsWater && (args.NodeValues[nework.PassageNodePathNodes[index, num].Layer_NodeNum] == float.MaxValue))
                 {
                     result2.ProblemAdd("Land is unreachable. Reduce variation or retry.");
                     break;
                 }
             }
         }
     }
     Label_088A:
     nework.Network.Deallocate();
     return result2;
 }
Exemplo n.º 4
0
 public void Connection_Add(PathfinderConnection Connection, ref int OutputNum)
 {
     OutputNum = this.ConnectionCount;
     if (this.Connections.GetUpperBound(0) < this.ConnectionCount)
     {
         this.Connections = (PathfinderConnection[]) Utils.CopyArray((Array) this.Connections, new PathfinderConnection[((this.ConnectionCount * 2) + 1) + 1]);
     }
     this.Connections[this.ConnectionCount] = Connection;
     this.ConnectionCount++;
     if (this.ParentNode == null)
     {
         this.Layer.Network.FindParentNode_Add(this);
     }
 }
Exemplo n.º 5
0
 public void UnlinkParentDependants()
 {
     if (this.DependantConnection != null)
     {
         PathfinderConnection dependantConnection = this.DependantConnection;
         this.DependantConnection = null;
         dependantConnection.LinkDecrease();
     }
 }
Exemplo n.º 6
0
 public void RaiseDependant()
 {
     if ((this.DependantConnection == null) && ((this.NodeA.ParentNode != this.NodeB.ParentNode) && ((this.NodeA.ParentNode != null) & (this.NodeB.ParentNode != null))))
     {
         PathfinderConnection connection = this.NodeA.ParentNode.FindConnection(this.NodeB.ParentNode);
         if (connection == null)
         {
             this.DependantConnection = new PathfinderConnection(this);
             this.DependantConnection.LinkIncrease();
             this.DependantConnection.RaiseDependant();
         }
         else
         {
             this.DependantConnection = connection;
             this.DependantConnection.LinkIncrease();
         }
     }
 }
Exemplo n.º 7
0
 public void ForceDeallocate()
 {
     this.DependantConnection = null;
     this.NodeA = null;
     this.NodeB = null;
 }