mirror of
https://github.com/veden/Rampant.git
synced 2024-12-26 20:54:12 +02:00
FACTO-257: Removed unneeded iterators
This commit is contained in:
parent
1b2d7da3ea
commit
a7cdf98ce2
@ -61,6 +61,7 @@ Version: 3.2.0
|
||||
- Centralized base points manipulation and chat messaging (Dagothur)
|
||||
- Base point deductions for unit losses are now batched in 20 to reduce chat spam when using the print AI points to chat options (Dagothur)
|
||||
- Reduced corpse and particle variation to optimize increased entity times due to high entity counts
|
||||
- Removed unneeded iterators
|
||||
- Moved map properties directly into chunk object
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
13
control.lua
13
control.lua
@ -576,12 +576,7 @@ local function processSurfaceTile(map, position, chunks, tick)
|
||||
local chunk = getChunkByPosition(map, position)
|
||||
|
||||
if (chunk ~= -1) then
|
||||
if not map.Universe.chunkToPassScan[chunk.id] then
|
||||
map.Universe.chunkToPassScan[chunk.id] = {
|
||||
map=map,
|
||||
chunk=chunk
|
||||
}
|
||||
end
|
||||
Universe.chunkToPassScan[chunk.id] = chunk
|
||||
else
|
||||
local x,y = positionToChunkXY(position)
|
||||
local addMe = true
|
||||
@ -1015,11 +1010,9 @@ local function onBuilderArrived(event)
|
||||
game.print(map.surface.name.." Settled: [gps=" .. builder.position.x .. "," .. builder.position.y .."]")
|
||||
end
|
||||
if Universe.enabledPurpleSettlerCloud then
|
||||
local len = Universe.settlePurpleCloud.len + 1
|
||||
Universe.settlePurpleCloud.len = len
|
||||
Universe.settlePurpleCloud[len] = {
|
||||
Universe.eventId = Universe.eventId + 1
|
||||
Universe.settlePurpleCloud[Universe.eventId] = {
|
||||
map = map,
|
||||
position = builder.position,
|
||||
group = builder,
|
||||
tick = event.tick + SETTLE_CLOUD_WARMUP
|
||||
}
|
||||
|
@ -193,16 +193,7 @@ function aiAttackWave.rallyUnits(chunk, tick, base)
|
||||
if (x ~= cX) and (y ~= cY) then
|
||||
local rallyChunk = getChunkByXY(map, x, y)
|
||||
if (rallyChunk ~= -1) and rallyChunk.nestCount then
|
||||
local pack = vengenceQueue[rallyChunk.id]
|
||||
if not pack then
|
||||
pack = {
|
||||
v = 0,
|
||||
map = map,
|
||||
base = base
|
||||
}
|
||||
vengenceQueue[rallyChunk.id] = pack
|
||||
end
|
||||
pack.v = pack.v + 1
|
||||
vengenceQueue[rallyChunk.id] = rallyChunk
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -65,198 +65,171 @@ local tInsert = table.insert
|
||||
|
||||
function ChunkProcessor.processPendingChunks(tick, flush)
|
||||
local pendingChunks = Universe.pendingChunks
|
||||
local eventId = Universe.chunkProcessorIterator
|
||||
local event
|
||||
local eventId, event = next(pendingChunks, nil)
|
||||
|
||||
if not eventId then
|
||||
eventId, event = next(pendingChunks, nil)
|
||||
else
|
||||
event = pendingChunks[eventId]
|
||||
if (tableSize(pendingChunks) == 0) then
|
||||
-- this is needed as the next command remembers the max length a table has been
|
||||
Universe.pendingChunks = {}
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local endCount = 1
|
||||
if flush then
|
||||
endCount = table_size(pendingChunks)
|
||||
eventId, event = next(pendingChunks, nil)
|
||||
endCount = tableSize(pendingChunks)
|
||||
end
|
||||
for _=1,endCount do
|
||||
if not eventId then
|
||||
Universe.chunkProcessorIterator = nil
|
||||
if (table_size(pendingChunks) == 0) then
|
||||
-- this is needed as the next command remembers the max length a table has been
|
||||
Universe.pendingChunks = {}
|
||||
if not flush and (event.tick > tick) then
|
||||
return
|
||||
end
|
||||
local newEventId, newEvent = next(pendingChunks, eventId)
|
||||
pendingChunks[eventId] = nil
|
||||
local map = event.map
|
||||
if not map.surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local topLeft = event.area.left_top
|
||||
local x = topLeft.x
|
||||
local y = topLeft.y
|
||||
|
||||
if not map[x] then
|
||||
map[x] = {}
|
||||
end
|
||||
|
||||
if map[x][y] then
|
||||
local oldChunk = map[x][y]
|
||||
local chunk = initialScan(oldChunk, map, tick)
|
||||
if (chunk == -1) then
|
||||
removeChunkFromMap(map, oldChunk)
|
||||
end
|
||||
break
|
||||
else
|
||||
if not flush and (event.tick > tick) then
|
||||
Universe.chunkProcessorIterator = eventId
|
||||
return
|
||||
end
|
||||
local newEventId, newEvent = next(pendingChunks, eventId)
|
||||
pendingChunks[eventId] = nil
|
||||
local map = event.map
|
||||
if not map.surface.valid then
|
||||
Universe.chunkProcessorIterator = newEventId
|
||||
return
|
||||
end
|
||||
|
||||
local topLeft = event.area.left_top
|
||||
local x = topLeft.x
|
||||
local y = topLeft.y
|
||||
|
||||
if not map[x] then
|
||||
map[x] = {}
|
||||
end
|
||||
|
||||
if map[x][y] then
|
||||
local oldChunk = map[x][y]
|
||||
local chunk = initialScan(oldChunk, map, tick)
|
||||
if (chunk == -1) then
|
||||
removeChunkFromMap(map, oldChunk)
|
||||
end
|
||||
local initialChunk = createChunk(map, x, y)
|
||||
map[x][y] = initialChunk
|
||||
Universe.chunkIdToChunk[initialChunk.id] = initialChunk
|
||||
local chunk = initialScan(initialChunk, map, tick)
|
||||
if (chunk ~= -1) then
|
||||
tInsert(
|
||||
map.processQueue,
|
||||
findInsertionPoint(map.processQueue, chunk),
|
||||
chunk
|
||||
)
|
||||
else
|
||||
local initialChunk = createChunk(map, x, y)
|
||||
map[x][y] = initialChunk
|
||||
Universe.chunkIdToChunk[initialChunk.id] = initialChunk
|
||||
local chunk = initialScan(initialChunk, map, tick)
|
||||
if (chunk ~= -1) then
|
||||
tInsert(
|
||||
map.processQueue,
|
||||
findInsertionPoint(map.processQueue, chunk),
|
||||
chunk
|
||||
)
|
||||
else
|
||||
map[x][y] = nil
|
||||
Universe.chunkIdToChunk[initialChunk.id] = nil
|
||||
end
|
||||
map[x][y] = nil
|
||||
Universe.chunkIdToChunk[initialChunk.id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
eventId = newEventId
|
||||
event = newEvent
|
||||
eventId = newEventId
|
||||
event = newEvent
|
||||
if not eventId then
|
||||
return
|
||||
end
|
||||
end
|
||||
Universe.chunkProcessorIterator = eventId
|
||||
end
|
||||
|
||||
function ChunkProcessor.processPendingUpgrades(tick)
|
||||
local entityId = Universe.pendingUpgradeIterator
|
||||
local entityData
|
||||
local entityId, entityData = next(Universe.pendingUpgrades, nil)
|
||||
if not entityId then
|
||||
entityId, entityData = next(Universe.pendingUpgrades, nil)
|
||||
else
|
||||
entityData = Universe.pendingUpgrades[entityId]
|
||||
end
|
||||
if not entityId then
|
||||
Universe.pendingUpgradeIterator = nil
|
||||
if table_size(Universe.pendingUpgrades) == 0 then
|
||||
if tableSize(Universe.pendingUpgrades) == 0 then
|
||||
Universe.pendingUpgrades = {}
|
||||
end
|
||||
else
|
||||
local entity = entityData.entity
|
||||
if entity.valid then
|
||||
Universe.pendingUpgradeIterator = next(Universe.pendingUpgrades, entityId)
|
||||
if entityData.delayTLL and tick < entityData.delayTLL then
|
||||
return
|
||||
end
|
||||
Universe.pendingUpgrades[entityId] = nil
|
||||
local base = entityData.base
|
||||
local map = base.map
|
||||
local baseAlignment = base.alignment
|
||||
local position = entityData.position or entity.position
|
||||
return
|
||||
end
|
||||
local entity = entityData.entity
|
||||
if not entity.valid then
|
||||
Universe.pendingUpgrades[entityId] = nil
|
||||
end
|
||||
if entityData.delayTLL and tick < entityData.delayTLL then
|
||||
return
|
||||
end
|
||||
Universe.pendingUpgrades[entityId] = nil
|
||||
local base = entityData.base
|
||||
local map = base.map
|
||||
local baseAlignment = base.alignment
|
||||
local position = entityData.position or entity.position
|
||||
|
||||
local pickedBaseAlignment
|
||||
if baseAlignment[2] then
|
||||
if Universe.random() < 0.75 then
|
||||
pickedBaseAlignment = baseAlignment[2]
|
||||
else
|
||||
pickedBaseAlignment = baseAlignment[1]
|
||||
end
|
||||
else
|
||||
pickedBaseAlignment = baseAlignment[1]
|
||||
end
|
||||
|
||||
local currentEvo = entity.prototype.build_base_evolution_requirement or 0
|
||||
|
||||
local distance = mMin(1, euclideanDistancePoints(position.x, position.y, 0, 0) * BASE_DISTANCE_TO_EVO_INDEX)
|
||||
local evoIndex = mMax(distance, Universe.evolutionLevel)
|
||||
|
||||
local name = findEntityUpgrade(pickedBaseAlignment,
|
||||
currentEvo,
|
||||
evoIndex,
|
||||
entity,
|
||||
map,
|
||||
entityData.evolve)
|
||||
|
||||
local entityName = entity.name
|
||||
if not name and PROXY_ENTITY_LOOKUP[entityName] then
|
||||
entity.destroy()
|
||||
return
|
||||
elseif (name == entityName) or not name then
|
||||
return
|
||||
end
|
||||
|
||||
local surface = entity.surface
|
||||
local query = Universe.ppuUpgradeEntityQuery
|
||||
query.name = name
|
||||
|
||||
unregisterEnemyBaseStructure(map, entity, nil, true)
|
||||
entity.destroy()
|
||||
local foundPosition = surface.find_non_colliding_position(BUILDING_SPACE_LOOKUP[name],
|
||||
position,
|
||||
2,
|
||||
1,
|
||||
true)
|
||||
setPositionInQuery(query, foundPosition or position)
|
||||
|
||||
local createdEntity = surface.create_entity({
|
||||
name = query.name,
|
||||
position = query.position
|
||||
})
|
||||
if createdEntity and createdEntity.valid then
|
||||
if entityData.register then
|
||||
registerEnemyBaseStructure(map, createdEntity, base, tick, true)
|
||||
end
|
||||
if not entityData.evolve and Universe.printBaseUpgrades then
|
||||
surface.print("["..base.id.."]:"..surface.name.." Upgrading ".. entityName .. " to " .. name .. " [gps=".. position.x ..",".. position.y .."]")
|
||||
end
|
||||
if remote.interfaces["kr-creep"] then
|
||||
remote.call("kr-creep", "spawn_creep_at_position", surface, foundPosition or position, false, createdEntity.name)
|
||||
end
|
||||
end
|
||||
local pickedBaseAlignment
|
||||
if baseAlignment[2] then
|
||||
if Universe.random() < 0.75 then
|
||||
pickedBaseAlignment = baseAlignment[2]
|
||||
else
|
||||
Universe.pendingUpgradeIterator = next(Universe.pendingUpgrades, entityId)
|
||||
Universe.pendingUpgrades[entityId] = nil
|
||||
pickedBaseAlignment = baseAlignment[1]
|
||||
end
|
||||
else
|
||||
pickedBaseAlignment = baseAlignment[1]
|
||||
end
|
||||
|
||||
local currentEvo = entity.prototype.build_base_evolution_requirement or 0
|
||||
|
||||
local distance = mMin(1, euclideanDistancePoints(position.x, position.y, 0, 0) * BASE_DISTANCE_TO_EVO_INDEX)
|
||||
local evoIndex = mMax(distance, Universe.evolutionLevel)
|
||||
|
||||
local name = findEntityUpgrade(pickedBaseAlignment,
|
||||
currentEvo,
|
||||
evoIndex,
|
||||
entity,
|
||||
map,
|
||||
entityData.evolve)
|
||||
|
||||
local entityName = entity.name
|
||||
if not name and PROXY_ENTITY_LOOKUP[entityName] then
|
||||
entity.destroy()
|
||||
return
|
||||
elseif (name == entityName) or not name then
|
||||
return
|
||||
end
|
||||
|
||||
local surface = entity.surface
|
||||
local query = Universe.ppuUpgradeEntityQuery
|
||||
query.name = name
|
||||
|
||||
unregisterEnemyBaseStructure(map, entity, nil, true)
|
||||
entity.destroy()
|
||||
local foundPosition = surface.find_non_colliding_position(BUILDING_SPACE_LOOKUP[name],
|
||||
position,
|
||||
2,
|
||||
1,
|
||||
true)
|
||||
setPositionInQuery(query, foundPosition or position)
|
||||
|
||||
local createdEntity = surface.create_entity({
|
||||
name = query.name,
|
||||
position = query.position
|
||||
})
|
||||
if createdEntity and createdEntity.valid then
|
||||
if entityData.register then
|
||||
registerEnemyBaseStructure(map, createdEntity, base, tick, true)
|
||||
end
|
||||
if not entityData.evolve and Universe.printBaseUpgrades then
|
||||
surface.print("["..base.id.."]:"..surface.name.." Upgrading ".. entityName .. " to " .. name .. " [gps=".. position.x ..",".. position.y .."]")
|
||||
end
|
||||
if remote.interfaces["kr-creep"] then
|
||||
remote.call("kr-creep", "spawn_creep_at_position", surface, foundPosition or position, false, createdEntity.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function ChunkProcessor.processScanChunks()
|
||||
local chunkId = Universe.chunkToPassScanIterator
|
||||
local chunkPack
|
||||
local chunkId, chunk = next(Universe.chunkToPassScan, nil)
|
||||
if not chunkId then
|
||||
chunkId, chunkPack = next(Universe.chunkToPassScan, nil)
|
||||
else
|
||||
chunkPack = Universe.chunkToPassScan[chunkId]
|
||||
end
|
||||
|
||||
if not chunkId then
|
||||
Universe.chunkToPassScanIterator = nil
|
||||
if (table_size(Universe.chunkToPassScan) == 0) then
|
||||
if (tableSize(Universe.chunkToPassScan) == 0) then
|
||||
-- this is needed as the next command remembers the max length a table has been
|
||||
Universe.chunkToPassScan = {}
|
||||
end
|
||||
else
|
||||
Universe.chunkToPassScanIterator = next(Universe.chunkToPassScan, chunkId)
|
||||
Universe.chunkToPassScan[chunkId] = nil
|
||||
local map = chunkPack.map
|
||||
if not map.surface.valid then
|
||||
return
|
||||
end
|
||||
local chunk = chunkPack.chunk
|
||||
return
|
||||
end
|
||||
|
||||
if (chunkPassScan(chunk, map) == -1) then
|
||||
removeChunkFromMap(map, chunk)
|
||||
end
|
||||
Universe.chunkToPassScan[chunkId] = nil
|
||||
local map = chunk.map
|
||||
if not map.surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if (chunkPassScan(chunk, map) == -1) then
|
||||
removeChunkFromMap(map, chunk)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -409,11 +409,8 @@ function ChunkUtils.entityForPassScan(map, entity)
|
||||
|
||||
for i=1,#overlapArray do
|
||||
local chunk = overlapArray[i]
|
||||
if (chunk ~= -1) and not map.Universe.chunkToPassScan[chunk.id] then
|
||||
map.Universe.chunkToPassScan[chunk.id] = {
|
||||
map = map,
|
||||
chunk = chunk
|
||||
}
|
||||
if (chunk ~= -1) then
|
||||
Universe.chunkToPassScan[chunk.id] = chunk
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -207,16 +207,7 @@ function MapProcessor.processPlayers(players, tick)
|
||||
processNestActiveness(chunk, tick)
|
||||
|
||||
if vengence then
|
||||
local pack = Universe.vengenceQueue[chunk.id]
|
||||
if not pack then
|
||||
pack = {
|
||||
v = 0,
|
||||
map = map,
|
||||
base = base
|
||||
}
|
||||
Universe.vengenceQueue[chunk.id] = pack
|
||||
end
|
||||
pack.v = pack.v + 1
|
||||
Universe.vengenceQueue[chunk.id] = chunk
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -228,21 +219,13 @@ function MapProcessor.processPlayers(players, tick)
|
||||
end
|
||||
end
|
||||
|
||||
local function processCleanUp(chunks, iterator, tick, duration)
|
||||
local chunkId = Universe[iterator]
|
||||
local eventTick
|
||||
local function processCleanUp(chunks, tick, duration)
|
||||
local chunkId, eventTick = next(chunks, nil)
|
||||
if not chunkId then
|
||||
chunkId, eventTick = next(chunks, nil)
|
||||
else
|
||||
eventTick = chunks[chunkId]
|
||||
return
|
||||
end
|
||||
if not chunkId then
|
||||
Universe[iterator] = nil
|
||||
else
|
||||
Universe[iterator] = next(chunks, chunkId)
|
||||
if (tick - eventTick) > duration then
|
||||
chunks[chunkId] = nil
|
||||
end
|
||||
if (tick - eventTick) > duration then
|
||||
chunks[chunkId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -252,11 +235,11 @@ function MapProcessor.cleanUpMapTables(tick)
|
||||
local drained = Universe.chunkToDrained
|
||||
|
||||
for _=1,CLEANUP_QUEUE_SIZE do
|
||||
processCleanUp(retreats, "chunkToRetreatIterator", tick, COOLDOWN_RETREAT)
|
||||
processCleanUp(retreats, tick, COOLDOWN_RETREAT)
|
||||
|
||||
processCleanUp(rallys, "chunkToRallyIterator", tick, COOLDOWN_RALLY)
|
||||
processCleanUp(rallys, tick, COOLDOWN_RALLY)
|
||||
|
||||
processCleanUp(drained, "chunkToDrainedIterator", tick, COOLDOWN_DRAIN)
|
||||
processCleanUp(drained, tick, COOLDOWN_DRAIN)
|
||||
end
|
||||
end
|
||||
|
||||
@ -292,10 +275,6 @@ function MapProcessor.scanPlayerMap(map, tick)
|
||||
end
|
||||
|
||||
function MapProcessor.scanEnemyMap(map, tick)
|
||||
if (map.nextProcessMap == tick) or (map.nextPlayerScan == tick) or (map.nextChunkProcess == tick) then
|
||||
return
|
||||
end
|
||||
|
||||
local index = map.scanEnemyIndex
|
||||
|
||||
local processQueue = map.processQueue
|
||||
@ -319,11 +298,6 @@ function MapProcessor.scanEnemyMap(map, tick)
|
||||
end
|
||||
|
||||
function MapProcessor.scanResourceMap(map, tick)
|
||||
if (map.nextProcessMap == tick) or (map.nextPlayerScan == tick) or
|
||||
(map.nextEnemyScan == tick) or (map.nextChunkProcess == tick)
|
||||
then
|
||||
return
|
||||
end
|
||||
local index = map.scanResourceIndex
|
||||
|
||||
local processQueue = map.processQueue
|
||||
@ -348,32 +322,24 @@ end
|
||||
|
||||
function MapProcessor.processVengence()
|
||||
local vengenceQueue = Universe.vengenceQueue
|
||||
local chunkId = Universe.deployVengenceIterator
|
||||
local vengencePack
|
||||
local chunkId, chunk = next(vengenceQueue, nil)
|
||||
if not chunkId then
|
||||
chunkId, vengencePack = next(vengenceQueue, nil)
|
||||
else
|
||||
vengencePack = vengenceQueue[chunkId]
|
||||
end
|
||||
if not chunkId then
|
||||
Universe.deployVengenceIterator = nil
|
||||
if (tableSize(vengenceQueue) == 0) then
|
||||
Universe.vengenceQueue = {}
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
vengenceQueue[chunkId] = nil
|
||||
local map = chunk.map
|
||||
if not map.surface.valid then
|
||||
return
|
||||
end
|
||||
local base = chunk.base
|
||||
if canMigrate(map, base) and (Universe.random() < 0.075) then
|
||||
formVengenceSettler(chunk, base)
|
||||
else
|
||||
Universe.deployVengenceIterator = next(vengenceQueue, chunkId)
|
||||
vengenceQueue[chunkId] = nil
|
||||
local map = vengencePack.map
|
||||
if not map.surface.valid then
|
||||
return
|
||||
end
|
||||
local chunk = getChunkById(chunkId)
|
||||
local base = vengencePack.base
|
||||
if canMigrate(map, base) and (Universe.random() < 0.075) then
|
||||
formVengenceSettler(map, chunk, base)
|
||||
else
|
||||
formVengenceSquad(map, chunk, base)
|
||||
end
|
||||
formVengenceSquad(chunk, base)
|
||||
end
|
||||
end
|
||||
|
||||
@ -448,10 +414,10 @@ local function processSpawnersBody(iterator, chunks)
|
||||
local migrate = canMigrate(map, base)
|
||||
local attack = canAttack(map, base)
|
||||
if migrate then
|
||||
formSettlers(map, chunk, base)
|
||||
formSettlers(chunk, base)
|
||||
end
|
||||
if attack then
|
||||
formSquads(map, chunk, base)
|
||||
formSquads(chunk, base)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -466,16 +432,14 @@ function MapProcessor.processAttackWaves()
|
||||
end
|
||||
|
||||
function MapProcessor.processClouds(tick)
|
||||
local len = Universe.settlePurpleCloud.len
|
||||
local builderPack = Universe.settlePurpleCloud[len]
|
||||
local eventId, builderPack = next(Universe.settlePurpleCloud, nil)
|
||||
if builderPack and (builderPack.tick <= tick) then
|
||||
Universe.settlePurpleCloud[len] = nil
|
||||
Universe.settlePurpleCloud.len = len - 1
|
||||
Universe.settlePurpleCloud[eventId] = nil
|
||||
local map = builderPack.map
|
||||
if builderPack.group.valid and map.surface.valid then
|
||||
setPositionInQuery(
|
||||
Universe.obaCreateBuildCloudQuery,
|
||||
builderPack.position
|
||||
builderPack.group.position
|
||||
)
|
||||
map.surface.create_entity(Universe.obaCreateBuildCloudQuery)
|
||||
end
|
||||
|
@ -82,10 +82,10 @@ function MapUtils.queueGeneratedChunk(event)
|
||||
return
|
||||
end
|
||||
event.tick = (event.tick or game.tick) + 20
|
||||
Universe.eventId = Universe.eventId + 1
|
||||
event.id = Universe.eventId
|
||||
event.map = map
|
||||
Universe.pendingChunks[event.id] = event
|
||||
Universe.eventId = Universe.eventId + 1
|
||||
end
|
||||
|
||||
function MapUtils.nextMap()
|
||||
@ -155,6 +155,9 @@ function MapUtils.removeChunkFromMap(map, chunk)
|
||||
Universe.chunkToRallys[chunkId] = nil
|
||||
Universe.chunkToPassScan[chunkId] = nil
|
||||
Universe.chunkToNests[chunkId] = nil
|
||||
Universe.chunkToTurrets[chunkId] = nil
|
||||
Universe.chunkToUtilities[chunkId] = nil
|
||||
Universe.chunkToHives[chunkId] = nil
|
||||
Universe.vengenceQueue[chunkId] = nil
|
||||
Universe.processActiveNest[chunkId] = nil
|
||||
Universe.chunkToVictory[chunkId] = nil
|
||||
@ -163,44 +166,13 @@ function MapUtils.removeChunkFromMap(map, chunk)
|
||||
base.chunkCount = base.chunkCount - 1
|
||||
map.chunkToBase[chunkId] = nil
|
||||
end
|
||||
map.chunkToTurrets[chunkId] = nil
|
||||
map.chunkToTraps[chunkId] = nil
|
||||
map.chunkToUtilities[chunkId] = nil
|
||||
map.chunkToHives[chunkId] = nil
|
||||
map.chunkToNestIds[chunkId] = nil
|
||||
map.chunkToHiveIds[chunkId] = nil
|
||||
map.chunkToTrapIds[chunkId] = nil
|
||||
map.chunkToTurretIds[chunkId] = nil
|
||||
map.chunkToUtilityIds[chunkId] = nil
|
||||
map.chunkToPlayerBase[chunkId] = nil
|
||||
map.chunkToResource[chunkId] = nil
|
||||
map.chunkToPlayerCount[chunkId] = nil
|
||||
map.chunkToSquad[chunkId] = nil
|
||||
map.chunkToPassable[chunkId] = nil
|
||||
map.chunkToPathRating[chunkId] = nil
|
||||
map.chunkToDeathGenerator[chunkId] = nil
|
||||
|
||||
if Universe.processActiveNestIterator == chunkId then
|
||||
Universe.processActiveNestIterator = nil
|
||||
end
|
||||
if Universe.victoryScentIterator == chunkId then
|
||||
Universe.victoryScentIterator = nil
|
||||
end
|
||||
if Universe.processNestIterator == chunkId then
|
||||
Universe.processNestIterator = nil
|
||||
end
|
||||
if Universe.chunkToDrainedIterator == chunkId then
|
||||
Universe.chunkToDrainedIterator = nil
|
||||
end
|
||||
if Universe.chunkToRetreatIterator == chunkId then
|
||||
Universe.chunkToRetreatIterator = nil
|
||||
end
|
||||
if Universe.chunkToRallyIterator == chunkId then
|
||||
Universe.chunkToRallyIterator = nil
|
||||
end
|
||||
if Universe.chunkToPassScanIterator == chunkId then
|
||||
Universe.chunkToPassScanIterator = nil
|
||||
end
|
||||
if Universe.processActiveSpawnerIterator == chunkId then
|
||||
Universe.processActiveSpawnerIterator = nil
|
||||
end
|
||||
@ -210,9 +182,6 @@ function MapUtils.removeChunkFromMap(map, chunk)
|
||||
if Universe.processMigrationIterator == chunkId then
|
||||
Universe.processMigrationIterator = nil
|
||||
end
|
||||
if Universe.deployVengenceIterator == chunkId then
|
||||
Universe.deployVengenceIterator = nil
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
|
@ -78,50 +78,43 @@ local mMax = math.max
|
||||
|
||||
-- module code
|
||||
|
||||
function PheromoneUtils.victoryScent(map, chunk, entityType)
|
||||
function PheromoneUtils.victoryScent(chunk, entityType)
|
||||
local value = VICTORY_SCENT[entityType]
|
||||
if value then
|
||||
addVictoryGenerator(map, chunk, value)
|
||||
addVictoryGenerator(chunk, value)
|
||||
end
|
||||
end
|
||||
|
||||
function PheromoneUtils.disperseVictoryScent()
|
||||
local chunkId = Universe.victoryScentIterator
|
||||
local chunkToVictory = Universe.chunkToVictory
|
||||
local pheromonePack
|
||||
local chunkId, pheromonePack = next(chunkToVictory, nil)
|
||||
if not chunkId then
|
||||
chunkId, pheromonePack = next(chunkToVictory, nil)
|
||||
else
|
||||
pheromonePack = chunkToVictory[chunkId]
|
||||
return
|
||||
end
|
||||
if not chunkId then
|
||||
Universe.victoryScentIterator = nil
|
||||
else
|
||||
Universe.victoryScentIterator = next(chunkToVictory, chunkId)
|
||||
chunkToVictory[chunkId] = nil
|
||||
local map = pheromonePack.map
|
||||
if not map.surface.valid then
|
||||
return
|
||||
end
|
||||
local chunk = getChunkById(chunkId)
|
||||
local chunkX = chunk.x
|
||||
local chunkY = chunk.y
|
||||
local i = 1
|
||||
for x=chunkX - VICTORY_SCENT_BOUND, chunkX + VICTORY_SCENT_BOUND,32 do
|
||||
for y = chunkY - VICTORY_SCENT_BOUND, chunkY + VICTORY_SCENT_BOUND,32 do
|
||||
local c = getChunkByXY(map, x, y)
|
||||
if (c ~= -1) then
|
||||
local amount = pheromonePack.v * VICTORY_SCENT_MULTIPLER[i]
|
||||
addDeathGenerator(c, amount)
|
||||
addPermanentDeathGenerator(c, amount)
|
||||
end
|
||||
i = i + 1
|
||||
|
||||
chunkToVictory[chunkId] = nil
|
||||
local chunk = pheromonePack.chunk
|
||||
local map = chunk.map
|
||||
if not map.surface.valid then
|
||||
return
|
||||
end
|
||||
local chunkX = chunk.x
|
||||
local chunkY = chunk.y
|
||||
local i = 1
|
||||
for x=chunkX - VICTORY_SCENT_BOUND, chunkX + VICTORY_SCENT_BOUND,32 do
|
||||
for y = chunkY - VICTORY_SCENT_BOUND, chunkY + VICTORY_SCENT_BOUND,32 do
|
||||
local c = getChunkByXY(map, x, y)
|
||||
if (c ~= -1) then
|
||||
local amount = pheromonePack.v * VICTORY_SCENT_MULTIPLER[i]
|
||||
addDeathGenerator(c, amount)
|
||||
addPermanentDeathGenerator(c, amount)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PheromoneUtils.deathScent(map, chunk, structure)
|
||||
function PheromoneUtils.deathScent(chunk, structure)
|
||||
local amount = -DEATH_PHEROMONE_GENERATOR_AMOUNT
|
||||
if structure then
|
||||
amount = -TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT
|
||||
|
@ -518,9 +518,6 @@ function Upgrade.addUniverseProperties()
|
||||
Universe.pendingChunks = {}
|
||||
Universe.processActiveNest = {}
|
||||
Universe.processActiveNestIterator = nil
|
||||
Universe.deployVengenceIterator = nil
|
||||
Universe.pendingUpgradeIterator = nil
|
||||
Universe.victoryScentIterator = nil
|
||||
Universe.squadIterator = nil
|
||||
Universe.processMapAIIterator = nil
|
||||
Universe.processNestIterator = nil
|
||||
@ -535,16 +532,12 @@ function Upgrade.addUniverseProperties()
|
||||
Universe.processActiveSpawnerIterator = nil
|
||||
Universe.processActiveRaidSpawnerIterator = nil
|
||||
Universe.processMigrationIterator = nil
|
||||
Universe.chunkToDrainedIterator = nil
|
||||
Universe.chunkToActiveNest = {}
|
||||
Universe.chunkToActiveRaidNest = {}
|
||||
Universe.chunkToDrained = {}
|
||||
Universe.chunkToRetreatIterator = nil
|
||||
Universe.chunkToRetreats = {}
|
||||
Universe.chunkToRallyIterator = nil
|
||||
Universe.chunkToRallys = {}
|
||||
Universe.chunkToPassScan = {}
|
||||
Universe.chunkToPassScanIterator = nil
|
||||
Universe.baseId = 0
|
||||
Universe.awake = false
|
||||
|
||||
@ -573,7 +566,6 @@ function Upgrade.addUniverseProperties()
|
||||
|
||||
Universe.pendingUpgrades = {}
|
||||
Universe.settlePurpleCloud = {}
|
||||
Universe.settlePurpleCloud.len = 0
|
||||
end
|
||||
end
|
||||
|
||||
@ -674,45 +666,18 @@ function Upgrade.prepMap(surface)
|
||||
map.scanPlayerIndex = 1
|
||||
map.scanResourceIndex = 1
|
||||
map.scanEnemyIndex = 1
|
||||
map.processStaticIndex = 1
|
||||
map.outgoingScanWave = true
|
||||
map.outgoingStaticScanWave = true
|
||||
|
||||
map.chunkToBase = {}
|
||||
map.chunkToTurrets = {}
|
||||
map.chunkToTraps = {}
|
||||
map.chunkToUtilities = {}
|
||||
map.chunkToHives = {}
|
||||
map.chunkToNestIds = {}
|
||||
map.chunkToHiveIds = {}
|
||||
map.chunkToTrapIds = {}
|
||||
map.chunkToTurretIds = {}
|
||||
map.chunkToUtilityIds = {}
|
||||
map.drainPylons = {}
|
||||
|
||||
map.chunkToPlayerBase = {}
|
||||
map.chunkToResource = {}
|
||||
map.chunkToPlayerCount = {}
|
||||
map.playerToChunk = {}
|
||||
|
||||
map.chunkToSquad = {}
|
||||
|
||||
map.chunkToPassable = {}
|
||||
map.chunkToPathRating = {}
|
||||
map.chunkToDeathGenerator = {}
|
||||
map.chunkToPermanentDeathGenerator = {}
|
||||
map.chunkToPlayerGenerator = {}
|
||||
|
||||
map.chunkScanCounts = {}
|
||||
|
||||
map.emptySquadsOnChunk = {}
|
||||
|
||||
map.surface = surface
|
||||
|
||||
map.bases = {}
|
||||
map.squads = nil
|
||||
map.pendingAttack = nil
|
||||
map.building = nil
|
||||
|
||||
-- queue all current chunks that wont be generated during play
|
||||
local tick = game.tick
|
||||
|
Loading…
Reference in New Issue
Block a user