コード例 #1
0
 public static void ProcessEquidistantCells(IntVec3 center, float radius, Func <List <IntVec3>, bool> processor, Map map = null)
 {
     if (GenRadial.working)
     {
         Log.Error("Nested calls to ProcessEquidistantCells() are not allowed.");
     }
     else
     {
         GenRadial.tmpCells.Clear();
         GenRadial.working = true;
         try
         {
             float num  = -1f;
             int   num2 = GenRadial.NumCellsInRadius(radius);
             for (int i = 0; i < num2; i++)
             {
                 IntVec3 intVec = center + GenRadial.RadialPattern[i];
                 if (map == null || intVec.InBounds(map))
                 {
                     float num3 = (float)intVec.DistanceToSquared(center);
                     if (Mathf.Abs(num3 - num) > 9.9999997473787516E-05)
                     {
                         if (GenRadial.tmpCells.Any() && processor(GenRadial.tmpCells))
                         {
                             return;
                         }
                         num = num3;
                         GenRadial.tmpCells.Clear();
                     }
                     GenRadial.tmpCells.Add(intVec);
                 }
             }
             if (GenRadial.tmpCells.Any())
             {
                 processor(GenRadial.tmpCells);
             }
         }
         finally
         {
             GenRadial.tmpCells.Clear();
             GenRadial.working = false;
         }
     }
 }
コード例 #2
0
 public static void ProcessEquidistantCells(IntVec3 center, float radius, Func <List <IntVec3>, bool> processor, Map map = null)
 {
     if (working)
     {
         Log.Error("Nested calls to ProcessEquidistantCells() are not allowed.");
         return;
     }
     tmpCells.Clear();
     working = true;
     try
     {
         float num  = -1f;
         int   num2 = NumCellsInRadius(radius);
         for (int i = 0; i < num2; i++)
         {
             IntVec3 intVec = center + RadialPattern[i];
             if (map != null && !intVec.InBounds(map))
             {
                 continue;
             }
             float num3 = intVec.DistanceToSquared(center);
             if (Mathf.Abs(num3 - num) > 0.0001f)
             {
                 if (tmpCells.Any() && processor(tmpCells))
                 {
                     return;
                 }
                 num = num3;
                 tmpCells.Clear();
             }
             tmpCells.Add(intVec);
         }
         if (tmpCells.Any())
         {
             processor(tmpCells);
         }
     }
     finally
     {
         tmpCells.Clear();
         working = false;
     }
 }