From 90e5ff1a8def64419d86a14fbbe44c53be483e8c Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Sun, 12 Mar 2023 20:48:44 -0700 Subject: [PATCH] FACTO-266: Base center is now the average of all chunks associated with base --- changelog.txt | 1 + libs/BaseUtils.lua | 2 ++ libs/ChunkPropertyUtils.lua | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/changelog.txt b/changelog.txt index 9d63420..4b58e9e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -35,6 +35,7 @@ Version: 3.2.0 - Recording the resource chunks covered by a given base as a property of a base - Use the enemy seed value instead of the map seed for puesdo random generating used by AI - Vengence settlers now cost ~3x of vengence squad + - Enemy regional bases now are centered on the average of all chunks that are part of the base Bugfixes: - Removed layer-13 from projectiles - script_raised_built now looks for enemy faction and registers as needed diff --git a/libs/BaseUtils.lua b/libs/BaseUtils.lua index 29d136f..f19283d 100644 --- a/libs/BaseUtils.lua +++ b/libs/BaseUtils.lua @@ -578,6 +578,8 @@ function BaseUtils.createBase(map, chunk, tick) local base = { x = x, y = y, + totalX = x, + totalY = y, distanceThreshold = distanceThreshold * Universe.baseDistanceModifier, tick = tick, alignment = alignment, diff --git a/libs/ChunkPropertyUtils.lua b/libs/ChunkPropertyUtils.lua index 4015503..51e864b 100644 --- a/libs/ChunkPropertyUtils.lua +++ b/libs/ChunkPropertyUtils.lua @@ -234,6 +234,10 @@ function ChunkPropertyUtils.removeChunkBase(chunk, base) end base.chunkCount = base.chunkCount - 1 + base.totalX = base.totalX - chunk.x + base.totalY = base.totalY - chunk.y + base.x = base.totalX / base.chunkCount + base.y = base.totalY / base.chunkCount chunk.base = nil end @@ -243,6 +247,10 @@ function ChunkPropertyUtils.setChunkBase(chunk, base) end base.chunkCount = base.chunkCount + 1 + base.totalX = base.totalX + chunk.x + base.totalY = base.totalY + chunk.y + base.x = base.totalX / base.chunkCount + base.y = base.totalY / base.chunkCount chunk.base = base end