mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
update entity script semantics
This commit is contained in:
parent
c54be7b2b1
commit
fc3994446a
11 changed files with 193 additions and 69 deletions
|
|
@ -25,11 +25,25 @@ end
|
|||
|
||||
-- Entity class
|
||||
|
||||
local Entity = {__index={}}
|
||||
local Entity = {__index={
|
||||
despawn=function(self) return entity.despawn(self.eid) end,
|
||||
}}
|
||||
|
||||
return {new_Entity = function(eid)
|
||||
local entity = setmetatable({eid=eid}, Entity)
|
||||
entity.transform = new_Transform(eid)
|
||||
entity.rigidbody = new_Rigidbody(eid)
|
||||
return entity
|
||||
end}
|
||||
local entities = {}
|
||||
|
||||
return {
|
||||
new_Entity = function(eid)
|
||||
local entity = setmetatable({eid=eid}, Entity)
|
||||
entity.transform = new_Transform(eid)
|
||||
entity.rigidbody = new_Rigidbody(eid)
|
||||
entities[eid] = entity;
|
||||
return entity
|
||||
end,
|
||||
remove_Entity = function(eid)
|
||||
local entity = entities[eid]
|
||||
if entity and entity.on_despawn then
|
||||
entity.on_despawn()
|
||||
end
|
||||
entities[eid] = nil;
|
||||
end
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue