mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-04 05:13:55 -04:00
Allow Entity.new to take a world
This commit is contained in:
parent
fea5fc7223
commit
ce32d16b8d
2 changed files with 10 additions and 4 deletions
|
@ -9,7 +9,11 @@ Entity.__index = Entity
|
|||
|
||||
--- Creates and initializes a new Entity.
|
||||
-- @return A new Entity
|
||||
function Entity.new()
|
||||
function Entity.new(world)
|
||||
if (world ~= nil and not Type.isWorld(world)) then
|
||||
error("bad argument #1 to 'Entity.new' (world/nil expected, got "..type(world)..")", 2)
|
||||
end
|
||||
|
||||
local e = setmetatable({
|
||||
__world = nil,
|
||||
__components = {},
|
||||
|
@ -17,6 +21,10 @@ function Entity.new()
|
|||
__isEntity = true,
|
||||
}, Entity)
|
||||
|
||||
if (world) then
|
||||
world:addEntity(e)
|
||||
end
|
||||
|
||||
return e
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue