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,22 +1,14 @@
local Entity = {
entities = {},
}
local Entity = {}
Entity.__index = Entity
--- Creates and initializes a new Entity.
-- @return A new Entity
function Entity.new()
local e = setmetatable({
id = #Entity.entities + 1,
components = {},
systems = {},
keys = {},
instance = nil,
instance = nil,
}, Entity)
Entity.entities[e.id] = e
return e
end
@ -25,7 +17,7 @@ end
-- @param ... The values passed to the Component
-- @return self
function Entity:give(component, ...)
self.components[component] = component:initialize(...)
self.components[component] = component:__initialize(...)
return self
end
@ -47,15 +39,6 @@ function Entity:check()
return self
end
--- Removed an Entity from the instance.
-- @return self
function Entity:destroy()
Entity.entities[self.id] = nil
self.instance:destroyEntity(self)
return self
end
--- Gets a Component from the Entity
-- @param component The Component to get
-- @return The Bag from the Component