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)); } }
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; })); } }
public static IEnumerable <Actor> FindActorsInBox(this World world, CPos tl, CPos br) { return(world.FindActorsInBox(tl.TopLeft, br.BottomRight)); }
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)); }