2016-08-05 06:47:51 +02:00
|
|
|
local chunkProcessor = {}
|
|
|
|
|
2016-08-20 04:52:27 +02:00
|
|
|
-- imports
|
|
|
|
|
2016-08-05 06:47:51 +02:00
|
|
|
local chunkUtils = require("ChunkUtils")
|
2016-08-20 04:52:27 +02:00
|
|
|
|
|
|
|
-- imported functions
|
|
|
|
|
|
|
|
local createChunk = chunkUtils.createChunk
|
2016-08-21 23:48:55 +02:00
|
|
|
local checkChunkPassability = chunkUtils.checkChunkPassability
|
|
|
|
local scoreChunk = chunkUtils.scoreChunk
|
2016-08-05 06:47:51 +02:00
|
|
|
|
2016-08-20 04:52:27 +02:00
|
|
|
-- module code
|
|
|
|
|
2017-05-24 08:46:23 +02:00
|
|
|
function chunkProcessor.processPendingChunks(natives, regionMap, surface, pendingStack)
|
2016-10-15 02:00:18 +02:00
|
|
|
local processQueue = regionMap.processQueue
|
|
|
|
|
2016-08-30 06:08:22 +02:00
|
|
|
for _=#pendingStack, 1, -1 do
|
2016-08-05 06:47:51 +02:00
|
|
|
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)
|
2016-08-05 06:47:51 +02:00
|
|
|
|
|
|
|
local chunkX = chunk.cX
|
|
|
|
|
|
|
|
if regionMap[chunkX] == nil then
|
|
|
|
regionMap[chunkX] = {}
|
|
|
|
end
|
|
|
|
regionMap[chunkX][chunk.cY] = chunk
|
|
|
|
|
2016-08-30 06:08:22 +02:00
|
|
|
checkChunkPassability(chunk, surface)
|
2017-05-24 08:46:23 +02:00
|
|
|
scoreChunk(natives, chunk, surface)
|
2016-08-20 04:52:27 +02:00
|
|
|
processQueue[#processQueue+1] = chunk
|
2016-08-05 06:47:51 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-30 06:08:22 +02:00
|
|
|
return chunkProcessor
|