1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-07 23:01:39 +02:00
Rampant/libs/ChunkProcessor.lua

38 lines
1007 B
Lua
Raw Normal View History

local chunkProcessor = {}
-- imports
local chunkUtils = require("ChunkUtils")
-- imported functions
local createChunk = chunkUtils.createChunk
2016-08-21 23:48:55 +02:00
local checkChunkPassability = chunkUtils.checkChunkPassability
local scoreChunk = chunkUtils.scoreChunk
-- module code
function chunkProcessor.processPendingChunks(natives, regionMap, surface, pendingStack)
2016-10-15 02:00:18 +02:00
local processQueue = regionMap.processQueue
for _=#pendingStack, 1, -1 do
local event = pendingStack[#pendingStack]
pendingStack[#pendingStack] = nil
2016-08-26 00:20:06 +02:00
local chunk = createChunk(event.area.left_top.x, event.area.left_top.y)
local chunkX = chunk.cX
if regionMap[chunkX] == nil then
regionMap[chunkX] = {}
end
regionMap[chunkX][chunk.cY] = chunk
checkChunkPassability(chunk, surface)
scoreChunk(natives, chunk, surface)
processQueue[#processQueue+1] = chunk
end
end
return chunkProcessor