예제 #1
0
 public static IEnumerable <Actor> FindActorsInCircle(this World world, WPos origin, WRange r)
 {
     using (new PerfSample("FindUnitsInCircle"))
     {
         // Target ranges are calculated in 2D, so ignore height differences
         var vec = new WVec(r, r, WRange.Zero);
         var rSq = r.Range * r.Range;
         return(world.FindActorsInBox(origin - vec, origin + vec).Where(
                    a => (a.CenterPosition - origin).HorizontalLengthSquared <= rSq));
     }
 }
예제 #2
0
 public static IEnumerable <Actor> FindActorsInCircle(this World world, WPos origin, WRange r)
 {
     using (new PerfSample("FindUnitsInCircle"))
     {
         // Target ranges are calculated in 2D, so ignore height differences
         var vec = new WVec(r, r, WRange.Zero);
         var rSq = r.Range * r.Range;
         return(world.FindActorsInBox(origin - vec, origin + vec).Where(a =>
         {
             var pos = a.CenterPosition;
             var dx = (long)(pos.X - origin.X);
             var dy = (long)(pos.Y - origin.Y);
             return dx * dx + dy * dy <= rSq;
         }));
     }
 }
예제 #3
0
 public static IEnumerable <Actor> FindActorsInBox(this World world, CPos tl, CPos br)
 {
     return(world.FindActorsInBox(tl.TopLeft, br.BottomRight));
 }
예제 #4
0
 public static IEnumerable <Actor> FindActorsInBox(this World world, CPos tl, CPos br)
 {
     // TODO: Support diamond boxes for isometric maps?
     return(world.FindActorsInBox(tl.TopLeft, br.BottomRight));
 }