1
0
mirror of https://github.com/veden/Rampant.git synced 2025-04-13 11:40:33 +02:00
Rampant/libs/BaseProcessor.lua

40 lines
760 B
Lua
Raw Normal View History

2017-05-11 21:50:06 -07:00
local baseProcessor = {}
-- imports
2017-05-19 00:47:24 -07:00
local baseUtils = require("BaseUtils")
local constants = require("Constants")
-- constants
2017-05-11 21:50:06 -07:00
local BASE_QUEUE_SIZE = constants.BASE_QUEUE_SIZE
-- imported functions
local mMin = math.min
2017-05-19 00:47:24 -07:00
local buildOrder = baseUtils.buildOrder
2017-05-11 21:50:06 -07:00
-- module code
2017-05-19 00:47:24 -07:00
function baseProcessor.processBases(regionMap, surface, natives, tick)
2017-05-11 21:50:06 -07:00
local baseIndex = natives.baseIndex
local bases = natives.bases
local endIndex = mMin(baseIndex+BASE_QUEUE_SIZE, #bases)
for index = baseIndex, endIndex do
local base = bases[index]
2017-05-19 00:47:24 -07:00
buildOrder(regionMap, natives, base, surface, tick)
2017-05-11 21:50:06 -07:00
end
if (endIndex == #bases) then
natives.baseIndex = 1
else
natives.baseIndex = endIndex + 1
end
end
return baseProcessor