area area_within_range(grid_node x, int r = threat) { area target_area = new area(); target_area.pos_in_area = new List <grid_node>(); target_area.pos_in_area.Add(x); for (int i = 0; i < r; i++) { int num = target_area.pos_in_area.Count; for (int index = 0; index < num; index++) { foreach (grid_node nb in sg.pure_neighbour(target_area.pos_in_area[index])) { if (!target_area.pos_in_area.Contains(nb)) { target_area.pos_in_area.Add(nb); } } } } return(target_area); }