Пример #1
0
 private bool TestNearest(clsTestNearestArgs Args)
 {
     int num;
     int num2;
     modMath.sXY_int _int;
     if (Args.PassageNodeA.MirrorNum != 0)
     {
         Debugger.Break();
         return false;
     }
     _int.X = Args.PassageNodeB.Pos.X - Args.PassageNodeA.Pos.X;
     _int.Y = Args.PassageNodeB.Pos.Y - Args.PassageNodeA.Pos.Y;
     int num3 = (_int.X * _int.X) + (_int.Y * _int.Y);
     if (num3 > Args.MaxConDist2)
     {
         return false;
     }
     int num6 = this.PassageNodeCount - 1;
     for (num = 0; num <= num6; num++)
     {
         int num7 = this.SymmetryBlockCount - 1;
         for (num2 = 0; num2 <= num7; num2++)
         {
             if ((this.PassageNodes[num2, num] != Args.PassageNodeA) & (this.PassageNodes[num2, num] != Args.PassageNodeB))
             {
                 modMath.sXY_int _int2 = modMath.PointGetClosestPosOnLine(Args.PassageNodeA.Pos, Args.PassageNodeB.Pos, this.PassageNodes[num2, num].Pos) - this.PassageNodes[num2, num].Pos;
                 if (_int2.ToDoubles().GetMagnitude() < Args.MinConDist)
                 {
                     return false;
                 }
             }
         }
     }
     clsNearest nearest = new clsNearest();
     clsNearest nearest2 = nearest;
     nearest2.Num = this.NearestCount;
     nearest2.Dist2 = num3;
     if (Args.PassageNodeA.MirrorNum == Args.PassageNodeB.MirrorNum)
     {
         nearest2.NodeA = new clsPassageNode[(this.SymmetryBlockCount - 1) + 1];
         nearest2.NodeB = new clsPassageNode[(this.SymmetryBlockCount - 1) + 1];
         int num8 = this.SymmetryBlockCount - 1;
         for (num = 0; num <= num8; num++)
         {
             nearest2.NodeA[num] = this.PassageNodes[num, Args.PassageNodeA.Num];
             nearest2.NodeB[num] = this.PassageNodes[num, Args.PassageNodeB.Num];
         }
         nearest2.NodeCount = this.SymmetryBlockCount;
     }
     else
     {
         int num4;
         int num5;
         if (!this.SymmetryIsRotational)
         {
             if (Args.PassageNodeA.Num != Args.PassageNodeB.Num)
             {
                 return false;
             }
             if (this.SymmetryBlockCount != 4)
             {
                 nearest2.NodeA = new clsPassageNode[1];
                 nearest2.NodeB = new clsPassageNode[1];
                 nearest2.NodeA[0] = Args.PassageNodeA;
                 nearest2.NodeB[0] = Args.PassageNodeB;
                 nearest2.NodeCount = 1;
                 goto Label_04A8;
             }
             nearest2.NodeA = new clsPassageNode[2];
             nearest2.NodeB = new clsPassageNode[2];
             num4 = (int) Math.Round((double) (((double) this.SymmetryBlockCount) / 2.0));
             int num11 = num4 - 1;
             for (num5 = 0; num5 <= num11; num5++)
             {
                 if (this.SymmetryBlocks[0].ReflectToNum[num5] == Args.PassageNodeB.MirrorNum)
                 {
                     break;
                 }
             }
         }
         else
         {
             nearest2.NodeA = new clsPassageNode[(this.SymmetryBlockCount - 1) + 1];
             nearest2.NodeB = new clsPassageNode[(this.SymmetryBlockCount - 1) + 1];
             num4 = (int) Math.Round((double) (((double) this.SymmetryBlockCount) / 2.0));
             int num9 = num4 - 1;
             num5 = 0;
             while (num5 <= num9)
             {
                 if (this.SymmetryBlocks[0].ReflectToNum[num5] == Args.PassageNodeB.MirrorNum)
                 {
                     break;
                 }
                 num5++;
             }
             if (num5 == num4)
             {
                 return false;
             }
             int num10 = this.SymmetryBlockCount - 1;
             for (num = 0; num <= num10; num++)
             {
                 nearest2.NodeA[num] = this.PassageNodes[num, Args.PassageNodeA.Num];
                 nearest2.NodeB[num] = this.PassageNodes[this.SymmetryBlocks[num].ReflectToNum[num5], Args.PassageNodeB.Num];
             }
             nearest2.NodeCount = this.SymmetryBlockCount;
             goto Label_04A8;
         }
         if (num5 == num4)
         {
             return false;
         }
         nearest2.NodeA[0] = Args.PassageNodeA;
         nearest2.NodeB[0] = Args.PassageNodeB;
         num2 = this.SymmetryBlocks[0].ReflectToNum[1 - num5];
         nearest2.NodeA[1] = this.PassageNodes[num2, Args.PassageNodeA.Num];
         nearest2.NodeB[1] = this.PassageNodes[this.SymmetryBlocks[num2].ReflectToNum[num5], Args.PassageNodeB.Num];
         nearest2.NodeCount = 2;
     }
     Label_04A8:
     nearest2.BlockedNearests = new clsNearest[0x200];
     nearest2 = null;
     this.Nearests[this.NearestCount] = nearest;
     this.NearestCount++;
     return true;
 }
Пример #2
0
        private bool TestNearest(clsTestNearestArgs Args)
        {
            sXY_int XY_int = new sXY_int();
            clsNearest NearestA = default(clsNearest);
            int Dist2 = 0;
            int A = 0;
            int B = 0;
            int ReflectionNum = 0;
            int ReflectionCount = 0;

            if ( Args.PassageNodeA.MirrorNum != 0 )
            {
                Debugger.Break();
                return false;
            }

            XY_int.X = Args.PassageNodeB.Pos.X - Args.PassageNodeA.Pos.X;
            XY_int.Y = Args.PassageNodeB.Pos.Y - Args.PassageNodeA.Pos.Y;
            Dist2 = XY_int.X * XY_int.X + XY_int.Y * XY_int.Y;
            if ( Dist2 > Args.MaxConDist2 )
            {
                return false;
            }
            for ( A = 0; A <= PassageNodeCount - 1; A++ )
            {
                for ( B = 0; B <= SymmetryBlockCount - 1; B++ )
                {
                    if ( PassageNodes[B, A] != Args.PassageNodeA && PassageNodes[B, A] != Args.PassageNodeB )
                    {
                        XY_int = MathUtil.PointGetClosestPosOnLine(Args.PassageNodeA.Pos, Args.PassageNodeB.Pos, PassageNodes[B, A].Pos);
                        if ( (XY_int - PassageNodes[B, A].Pos).ToDoubles().GetMagnitude() < Args.MinConDist )
                        {
                            return false;
                        }
                    }
                }
            }

            NearestA = new clsNearest();
            NearestA.Num = NearestCount;
            NearestA.Dist2 = Dist2;
            if ( Args.PassageNodeA.MirrorNum == Args.PassageNodeB.MirrorNum )
            {
                NearestA.NodeA = new clsPassageNode[SymmetryBlockCount];
                NearestA.NodeB = new clsPassageNode[SymmetryBlockCount];
                for ( A = 0; A <= SymmetryBlockCount - 1; A++ )
                {
                    NearestA.NodeA[A] = PassageNodes[A, Args.PassageNodeA.Num];
                    NearestA.NodeB[A] = PassageNodes[A, Args.PassageNodeB.Num];
                }
                NearestA.NodeCount = SymmetryBlockCount;
            }
            else
            {
                if ( SymmetryIsRotational )
                {
                    NearestA.NodeA = new clsPassageNode[SymmetryBlockCount];
                    NearestA.NodeB = new clsPassageNode[SymmetryBlockCount];
                    ReflectionCount = (int)(SymmetryBlockCount / 2.0D);
                    for ( ReflectionNum = 0; ReflectionNum <= ReflectionCount - 1; ReflectionNum++ )
                    {
                        if ( SymmetryBlocks[0].ReflectToNum[ReflectionNum] == Args.PassageNodeB.MirrorNum )
                        {
                            break;
                        }
                    }
                    if ( ReflectionNum == ReflectionCount )
                    {
                        return false;
                    }
                    for ( A = 0; A <= SymmetryBlockCount - 1; A++ )
                    {
                        NearestA.NodeA[A] = PassageNodes[A, Args.PassageNodeA.Num];
                        NearestA.NodeB[A] = PassageNodes[SymmetryBlocks[A].ReflectToNum[ReflectionNum], Args.PassageNodeB.Num];
                    }
                    NearestA.NodeCount = SymmetryBlockCount;
                }
                else
                {
                    if ( Args.PassageNodeA.Num != Args.PassageNodeB.Num )
                    {
                        return false;
                    }
                    if ( SymmetryBlockCount == 4 )
                    {
                        NearestA.NodeA = new clsPassageNode[2];
                        NearestA.NodeB = new clsPassageNode[2];
                        ReflectionCount = (int)(SymmetryBlockCount / 2.0D);
                        for ( ReflectionNum = 0; ReflectionNum <= ReflectionCount - 1; ReflectionNum++ )
                        {
                            if ( SymmetryBlocks[0].ReflectToNum[ReflectionNum] == Args.PassageNodeB.MirrorNum )
                            {
                                break;
                            }
                        }
                        if ( ReflectionNum == ReflectionCount )
                        {
                            return false;
                        }
                        NearestA.NodeA[0] = Args.PassageNodeA;
                        NearestA.NodeB[0] = Args.PassageNodeB;
                        B = Convert.ToInt32(SymmetryBlocks[0].ReflectToNum[1 - ReflectionNum]);
                        NearestA.NodeA[1] = PassageNodes[B, Args.PassageNodeA.Num];
                        NearestA.NodeB[1] = PassageNodes[SymmetryBlocks[B].ReflectToNum[ReflectionNum], Args.PassageNodeB.Num];
                        NearestA.NodeCount = 2;
                    }
                    else
                    {
                        NearestA.NodeA = new clsPassageNode[1];
                        NearestA.NodeB = new clsPassageNode[1];
                        NearestA.NodeA[0] = Args.PassageNodeA;
                        NearestA.NodeB[0] = Args.PassageNodeB;
                        NearestA.NodeCount = 1;
                    }
                }
            }

            NearestA.BlockedNearests = new clsNearest[512];
            Nearests[NearestCount] = NearestA;
            NearestCount++;

            return true;
        }