Polishing

This commit is contained in:
Justin van der Leij 2018-01-30 12:45:35 +01:00
parent 58549d6b0a
commit 2d21fe97a5
8 changed files with 136 additions and 109 deletions

View file

@ -1,6 +1,6 @@
local PATH = (...):gsub('%.[^%.]+$', '')
local Pool = require(PATH..".pool")
local List = require(PATH..".list")
local EventManager = require(PATH..".eventManager")
local Instance = {}
@ -8,7 +8,7 @@ Instance.__index = Instance
function Instance.new()
local instance = setmetatable({
entities = Pool(),
entities = List(),
eventManager = EventManager(),
systems = {},
@ -26,16 +26,14 @@ end
function Instance:checkEntity(e)
for _, system in ipairs(self.systems) do
if system:entityUpdated(e) then
e.systems[#e.systems + 1] = system
end
system:checkEntity(e)
end
end
function Instance:destroyEntity(e)
function Instance:removeEntity(e)
self.entities:remove(e)
for _, system in ipairs(e.systems) do
for _, system in ipairs(self.systems) do
system:remove(e)
end
end
@ -69,18 +67,6 @@ function Instance:emit(...)
return self
end
function Instance:update(dt)
self:emit("update", dt)
return self
end
function Instance:draw()
self:emit("draw")
return self
end
return setmetatable(Instance, {
__call = function(_, ...) return Instance.new(...) end,
})