From 07ba48c1216546ea4362d99d6be7cb74c5e4365a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 4 Sep 2023 11:05:42 +0700 Subject: [PATCH] Fix repeating chunks not being put into collect --- .../ru/dbotthepony/kstarbound/world/World.kt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt index c5ed7374..7cb4e223 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt @@ -42,6 +42,7 @@ abstract class World, ChunkType : Chunk, ChunkType : Chunk, ChunkType : Chunk, ChunkType : Chunk, ChunkType : Chunk { + fun collect(boundingBox: AABBi): List { val output = ArrayList() for (pos in boundingBox.chunkPositions) { val chunk = chunkMap[pos] - if (chunk != null && chunk !in output) { + if (chunk != null && (loopX || chunkMap.x.inBoundsChunk(pos.x)) && (loopY || chunkMap.y.inBoundsChunk(pos.y))) { output.add(chunk) } } @@ -418,13 +428,13 @@ abstract class World, ChunkType : Chunk> { + fun collectPositionAware(boundingBox: AABBi): List> { val output = ArrayList>() for (pos in boundingBox.chunkPositions) { val chunk = chunkMap[pos] - if (chunk != null && !output.any { it.second === chunk }) { + if (chunk != null && (loopX || chunkMap.x.inBoundsChunk(pos.x)) && (loopY || chunkMap.y.inBoundsChunk(pos.y))) { output.add(pos to chunk) } }