From da8fea152ab9efb1cc6e91516c9105ecfb1cccdf Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 20 Jun 2022 10:30:00 +0200 Subject: [PATCH] =?UTF-8?q?Factor=C2=A0out=20windmill=C2=A0check=20in?= =?UTF-8?q?=C2=A0shape=C2=A0patch=C2=A0generation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/game/map_chunk.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/js/game/map_chunk.js b/src/js/game/map_chunk.js index b966a322..825f52b9 100644 --- a/src/js/game/map_chunk.js +++ b/src/js/game/map_chunk.js @@ -226,17 +226,7 @@ export class MapChunk { ]; } - // Makes sure windmills never spawn as whole - let windmillCount = 0; - for (let i = 0; i < subShapes.length; ++i) { - if (subShapes[i] === enumSubShape.windmill) { - ++windmillCount; - } - } - if (windmillCount > 1) { - subShapes[0] = enumSubShape.rect; - subShapes[1] = enumSubShape.rect; - } + this.filterShapePatch({ subShapes, distanceToOriginInChunks }); const definition = this.root.shapeDefinitionMgr.getDefinitionFromSimpleShapes(subShapes); this.internalGeneratePatch( @@ -246,6 +236,27 @@ export class MapChunk { ); } + /** + * Makes sure windmills never spawn as whole + * + * @param {object} param0 + * @param {[enumSubShape, enumSubShape, enumSubShape, enumSubShape]} param0.subShapes + * @param {number} param0.distanceToOriginInChunks + */ + filterShapePatch({ subShapes, distanceToOriginInChunks }) { + let windmillCount = 0; + for (let i = 0; i < subShapes.length; ++i) { + if (subShapes[i] === enumSubShape.windmill) { + ++windmillCount; + } + } + + if (windmillCount > 1) { + subShapes[0] = enumSubShape.rect; + subShapes[1] = enumSubShape.rect; + } + } + /** * Chooses a random shape with the given weights * @param {RandomNumberGenerator} rng