diff options
Diffstat (limited to 'honey/ecs.lua')
-rw-r--r-- | honey/ecs.lua | 56 |
1 files changed, 3 insertions, 53 deletions
diff --git a/honey/ecs.lua b/honey/ecs.lua index d544a37..260c389 100644 --- a/honey/ecs.lua +++ b/honey/ecs.lua @@ -77,11 +77,13 @@ end -- load database from file function EntityDb.load(self, filename) + print(collectgarbage("count")) self.entities = {} self.components = {} + collectgarbage() + print(collectgarbage("count")) local env = { Entity = function(id, components) - print("add entity:", id) self:createEntity(id) self:addComponents(id, components) end, @@ -261,56 +263,4 @@ function SystemDb.removeSystem(self, id) end ---===== Database =====-- - -Database = {} -Database.__index = Database - -function Database.new(_) - local self = {} - self.entityDb = EntityDb() - self.systemDb = SystemDb(self.entityDb) - setmetatable(self, Database) - return self -end -setmetatable(Database, {__call=Database.new}) - - -function Database.isValidEntity(self, id) - return self.entityDb:checkIsValid(id) -end -function Database.createEntity(self, id) - return self.entityDb:createEntity(id) -end -function Database.addComponent(self, id, name, value) - return self.entityDb:addComponent(id, name, value) -end -function Database.queryComponent(self, name) - return self.entityDb:queryComponent(name) -end -function Database.queryEntity(self, id) - return self.entityDb:queryEntity(id) -end -function Database.getComponent(self, id, name) - return self.entityDb:getComponent(id, name) -end -function Database.removeComponent(self, id, name) - return self.entityDb:removeComponent(id, name) -end -function Database.deleteEntity(self, id) - return self.entityDb.deleteEntity(id) -end - - -function Database.addSystem(self, func, params) - return self.systemDb:addSystem(func, params) -end -function Database.update(self, dt) - return self.systemDb:update(dt) -end -function Database.removeSystem(self, id) - return self.systemDb:removeSystem(id) -end - - return module |