1
0
mirror of https://github.com/veden/Rampant.git synced 2025-03-17 20:58:35 +02:00

corrected base chunk count logic in upgrade and chunk properties

This commit is contained in:
Aaron Veden 2021-12-04 13:21:07 -08:00
parent 4bf9b7ac7b
commit edb589816a
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
2 changed files with 33 additions and 41 deletions

View File

@ -460,25 +460,27 @@ function upgrade.attempt(universe)
for i=1,#map.processQueue do
local chunk = map.processQueue[i]
chunk.dOrigin = euclideanDistancePoints(chunk.x, chunk.y, 0, 0)
local base = getChunkBase(map, chunk)
if base then
if not map.bases[base.id] then
map.bases[base.id] = base
end
if not base.damagedBy then
base.damagedBy = {}
end
if not base.deathEvents then
base.deathEvents = 0
end
if not base.chunkCount then
base.chunkCount = 0
end
if not base.mutations then
base.mutations = 0
end
if not base.alignment[1] then
basesToRemove[base.id] = true
if universe.NEW_ENEMIES then
local base = getChunkBase(map, chunk)
if base then
if not map.bases[base.id] then
map.bases[base.id] = base
end
if not base.damagedBy then
base.damagedBy = {}
end
if not base.deathEvents then
base.deathEvents = 0
end
if not base.chunkCount then
base.chunkCount = 0
end
if not base.mutations then
base.mutations = 0
end
if not base.alignment[1] then
basesToRemove[base.id] = true
end
end
end
end
@ -512,31 +514,21 @@ function upgrade.attempt(universe)
end
end
processPendingChunks(map, tick, true)
for i=1,#map.processQueue do
local chunk = map.processQueue[i]
local base = getChunkBase(map, chunk)
if (getEnemyStructureCount(map, chunk) > 0) then
base.chunkCount = (base.chunkCount or 0) + 1
if universe.NEW_ENEMIES then
for baseId in pairs(basesToRemove) do
map.bases[baseId] = nil
end
if base and (not base.alignment[1]) then
removeChunkBase(map, chunk, base)
end
if (getEnemyStructureCount(map, chunk) > 0) and not base then
local newBase = findNearbyBase(map, chunk)
if not newBase then
createBase(map, chunk, tick)
else
map.chunkToBases = {}
for i=1,#map.processQueue do
local chunk = map.processQueue[i]
if (getEnemyStructureCount(map, chunk) > 0) then
local newBase = findNearbyBase(map, chunk)
if not newBase then
createBase(map, chunk, tick)
end
setChunkBase(map, chunk, newBase)
end
end
if base and getEnemyStructureCount(map, chunk) == 0 then
removeChunkBase(map, chunk, base)
end
end
for baseId in pairs(basesToRemove) do
map.bases[baseId] = nil
end
for _,squad in pairs(map.groupNumberToSquad) do
squad.commandTick = tick

View File

@ -162,7 +162,7 @@ end
function chunkPropertyUtils.removeChunkBase(map, chunk, base)
if map.chunkToBase[chunk] then
base.chunkCount = base.chunkCount + 1
base.chunkCount = base.chunkCount - 1
map.chunkToBase[chunk] = nil
end
end