mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-02 20:33:54 -04:00
Allowed for entities to be in multiple systems. Fixed the removal issue.
This commit is contained in:
parent
c750ea119f
commit
100d6320c7
5 changed files with 28 additions and 10 deletions
|
@ -1,3 +1,7 @@
|
|||
local PATH = (...):gsub('%.[^%.]+$', '')
|
||||
|
||||
local List = require(PATH..".list")
|
||||
|
||||
local Entity = {}
|
||||
Entity.__index = Entity
|
||||
|
||||
|
@ -6,7 +10,8 @@ Entity.__index = Entity
|
|||
function Entity.new()
|
||||
local e = setmetatable({
|
||||
components = {},
|
||||
instance = nil,
|
||||
removed = {},
|
||||
instances = List(),
|
||||
}, Entity)
|
||||
|
||||
return e
|
||||
|
@ -26,15 +31,27 @@ end
|
|||
-- @param component The Component to remove
|
||||
-- @return self
|
||||
function Entity:remove(component)
|
||||
self.components[component] = nil
|
||||
self.removed[component] = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function Entity:destroy()
|
||||
for i = 1, self.instances.size do
|
||||
self.instances:get(i):removeEntity(self)
|
||||
end
|
||||
end
|
||||
|
||||
--- Checks the Entity against the pools again.
|
||||
-- @return self
|
||||
function Entity:check()
|
||||
self.instance:checkEntity(self)
|
||||
function Entity:apply()
|
||||
for i = 1, self.instances.size do
|
||||
self.instances:get(i):checkEntity(self)
|
||||
end
|
||||
|
||||
for _, component in pairs(self.removed) do
|
||||
self.components[component] = nil
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue