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

a076b70: Added resource chunks to bases

This commit is contained in:
Aaron Veden 2023-01-18 21:38:07 -08:00
parent e3bf7f0efe
commit b7ae56c1a2
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
5 changed files with 40 additions and 1 deletions

View File

@ -20,6 +20,7 @@ local upgrade = {}
local constants = require("libs/Constants")
local chunkProcessor = require("libs/ChunkProcessor")
local chunkPropertyUtils = require("libs/chunkPropertyUtils")
local mapUtils = require("libs/MapUtils")
-- constants
@ -50,6 +51,9 @@ local TICKS_A_MINUTE = constants.TICKS_A_MINUTE
-- imported functions
local addBaseResourceChunk = chunkPropertyUtils.addBaseResourceChunk
local getChunkBase = chunkPropertyUtils.getChunkBase
local getResourceGenerator = chunkPropertyUtils.getResourceGenerator
local sFind = string.find
local queueGeneratedChunk = mapUtils.queueGeneratedChunk
local processPendingChunks = chunkProcessor.processPendingChunks
@ -640,10 +644,23 @@ function upgrade.attempt(universe)
base.sentExpansionGroups = 0
base.resetExpensionGroupsTick = 0
base.alignmentHistory = {}
base.resourceChunks = {}
base.resourceChunkCount = 0
end
for _,map in pairs(universe.maps) do
map.chunkToPermanentDeathGenerator = {}
if (map.surface.valid) then
for _, chunk in pairs(map.processQueue) do
if getResourceGenerator(map, chunk) > 0 then
local base = getChunkBase(map, chunk)
if base then
addBaseResourceChunk(base, chunk)
end
end
end
map.chunkToPermanentDeathGenerator = {}
end
end
game.print("Rampant - Version 3.2.0")

View File

@ -32,6 +32,7 @@ Version: 3.2.0
- Reduced range of enemy structures and unit sizes
- Moved new enemies creation from data-update-final to data stage
- Reduced the size of stickers applied by Rampant new enemies to player entities
- Recording the resource chunks covered by a given base as a property of a base
Bugfixes:
- Removed layer-13 from projectiles
- script_raised_built now looks for enemy faction and registers as needed

View File

@ -522,6 +522,8 @@ function baseUtils.createBase(map, chunk, tick)
builtEnemyBuilding = 0,
ionCannonBlasts = 0,
artilleryBlasts = 0,
resourceChunks = {},
resourceChunkCount = 0,
temperament = 0.5,
temperamentScore = 0,
universe = universe,

View File

@ -215,6 +215,20 @@ function chunkPropertyUtils.getNestCount(map, chunk)
return nestPack.v
end
function chunkPropertyUtils.addBaseResourceChunk(base, chunk)
if chunkPropertyUtils.getResourceGenerator(base.map, chunk) > 0 then
base.resourceChunkCount = base.resourceChunkCount + 1
base.resourceChunks[chunk.id] = true
end
end
function chunkPropertyUtils.removeBaseResourceChunk(base, chunk)
if base.resourceChunks[chunk.id] then
base.resourceChunkCount = base.resourceChunkCount - 1
base.resourceChunks[chunk.id] = nil
end
end
function chunkPropertyUtils.getChunkBase(map, chunk)
return map.chunkToBase[chunk.id]
end

View File

@ -65,6 +65,9 @@ local GENERATOR_PHEROMONE_LEVEL_6 = constants.GENERATOR_PHEROMONE_LEVEL_6
-- imported functions
local removeBaseResourceChunk = chunkPropertyUtils.removeBaseResourceChunk
local addBaseResourceChunk = chunkPropertyUtils.addBaseResourceChunk
local setAreaInQueryChunkSize = queryUtils.setAreaInQueryChunkSize
local setAreaXInQuery = queryUtils.setAreaXInQuery
local setAreaYInQuery = queryUtils.setAreaYInQuery
@ -510,6 +513,7 @@ function chunkUtils.registerEnemyBaseStructure(map, entity, base, skipCount)
if addFunc(map, chunk, entityUnitNumber) then
added = true
setChunkBase(map, chunk, base)
addBaseResourceChunk(base, chunk)
end
if (hiveType == "spitter-spawner") or (hiveType == "biter-spawner") then
processNestActiveness(map, chunk)
@ -568,6 +572,7 @@ function chunkUtils.unregisterEnemyBaseStructure(map, entity, damageTypeName, sk
end
end
if (getEnemyStructureCount(map, chunk) <= 0) then
removeBaseResourceChunk(base, chunk)
removeChunkBase(map, chunk, base)
end
end