Unload chunks that fall outside a certain radius

This commit is contained in:
Joscha 2017-04-08 17:05:09 +00:00
parent c364faf8ff
commit c5af7c2480
2 changed files with 14 additions and 4 deletions

View file

@ -170,14 +170,14 @@ class ChunkPool():
for pos in coords:
self.unload(pos)
def clean_up(self, except_for=[], condition=lambda chunk: True):
def clean_up(self, except_for=[], condition=lambda pos, chunk: True):
# old list comprehension which became too long:
#coords = [pos for pos, chunk in self._chunks.items() if not pos in except_for and condition(chunk)]
coords = []
for pos, chunk in self._chunks.items():
if not pos in except_for and condition(chunk):
if not pos in except_for and condition(pos, chunk):
coords.append(pos)
self.unload_list(coords)