xurfer/xurfer/ext/skeleton/main.lua

37 lines
853 B
Lua

local api = ...
local ecs = api.ecs
return {
name = "skeleton",
enabled = true,
init = function()
--api.ext.skeleton.extendECS()
end,
update = function(dt) end,
load = function() end,
draw = function(pass,dt) end,
-- ECS API docs: https://bakpakin.github.io/tiny-ecs/doc
extendECS = function()
local exampleSystem = ecs.processingSystem({
updatethread = true,
-- drawthread = true
filter = ecs.requireAll('mycomponent'),
onAdd = function(self,obj) print_r(obj) end,
onRemove = function(self,obj) end,
process = function(self,obj) end,
})
ecs.addSystem( api.world, exampleSystem )
-- add example entity object
local obj = { foo = "bar", mycomponent = { a = 1 } }
ecs.add( api.world, obj )
obj.commit() -- notify other systems to update entitycache
end
}