示例#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));
 }