Ludeon Forums

RimWorld => Mods => Help => Topic started by: mipen on November 26, 2014, 05:55:21 AM

Title: How to find all the IntVec3s in a given area?
Post by: mipen on November 26, 2014, 05:55:21 AM
How would I go about building a list containing all the IntVec3s, given a centre position and a radius? Say I want to build a list of all the cells in a 5 cell radius around a pawns position, what would be the best way to go about doing this? Thanks
Title: Re: How to find all the IntVec3s in a given area?
Post by: skullywag on November 26, 2014, 06:10:30 AM
Off the top of my head theres withinhorizontaldistance you could use maybe. Not near a pc so cant check further.
Title: Re: How to find all the IntVec3s in a given area?
Post by: Rikiki on November 26, 2014, 06:17:11 AM
Test this:
IEnumerable<IntVec3> cellsWithinRange = Find.Map.AllCells.Where(cellPosition => cellPosition.WithinHorizontalDistanceOf(center, distance));
With center the pawn position and distance the desired radius.