diff options
author | sanine-a <sanine.not@pm.me> | 2023-05-12 14:10:48 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2023-05-12 14:10:48 -0500 |
commit | 0d96ebc90c9740e7e66a70aa11168b11f49d220b (patch) | |
tree | 758403f74f4fbcab61a228ef58e720850b3f70db /honey/ecs/script.lua | |
parent | 6036d1b5d7e0fc160637ce70595bac57ed1fcd00 (diff) |
run working program with refactored code
Diffstat (limited to 'honey/ecs/script.lua')
-rw-r--r-- | honey/ecs/script.lua | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/honey/ecs/script.lua b/honey/ecs/script.lua index 9ae7d72..46af4fa 100644 --- a/honey/ecs/script.lua +++ b/honey/ecs/script.lua @@ -1,3 +1,6 @@ +local ecs = require 'honey.ecs.ecs' +local node = require 'honey.ecs.node' + local module = {} setmetatable(module, {__index=_G}) setfenv(1, module) @@ -16,8 +19,8 @@ end --===== dispatch messages to handlers =====-- -dispatch = function(entities, msg, data) - local query = entities:queryComponent(msg) +dispatch = function(db, msg, data) + local query = db:queryComponent(msg) for id, handler in pairs(query) do local f = getFunction(handler) f(entities, id, data) @@ -26,19 +29,16 @@ end --===== script system =====-- -system = function(params) - return { - db=params.db, - update=function(self, dt) - local entities = self.db:queryComponent("script") - for id, script in pairs(entities) do - local f = getFunction(script) - f(self.db, id, dt) - end - end - } -end +local script = ecs.System("script", function(db, dt, params) + local entities = db:queryComponent("script") + for id, script in pairs(entities) do + local f = getFunction(script) + f(db, id, dt) + end +end) +script:addDependencies(node.system) +system = {script} return module |