How to find all the IntVec3s in a given area?

Started by mipen, November 26, 2014, 05:55:21 AM

Previous topic - Next topic

mipen

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

skullywag

Off the top of my head theres withinhorizontaldistance you could use maybe. Not near a pc so cant check further.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Rikiki

Test this:
IEnumerable<IntVec3> cellsWithinRange = Find.Map.AllCells.Where(cellPosition => cellPosition.WithinHorizontalDistanceOf(center, distance));
With center the pawn position and distance the desired radius.