private void UpdateAffectedCellsInRect(IntVec3 pos1, IntVec3 pos2) {
affectedCells.Clear();
// estabilish bounds
int minX, maxX, minZ, maxZ;
if (pos1.x <= pos2.x) {
minX = pos1.x;
maxX = pos2.x;
} else {
minX = pos2.x;
maxX = pos1.x;
}
if (pos1.z <= pos2.z) {
minZ = pos1.z;
maxZ = pos2.z;
} else {
minZ = pos2.z;
maxZ = pos1.z;
}
// check all items against bounds
var allTheThings = Find.ListerThings.AllThings;
for (var i = 0; i < allTheThings.Count; i++) {
var thing = allTheThings[i];
var thingPos = thing.Position;
if (thing.def.selectable && thingPos.x >= minX && thingPos.x <= maxX && thingPos.z >= minZ && thingPos.z <= maxZ && filterCallback(thing)) {
affectedCells.Add(thingPos);
}
}
}