From e603997055259039cefcdceaece5604e3856e36d Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 15 Apr 2023 01:56:14 -0500 Subject: fix circular reference bug for physics objects --- honey/ecs.lua | 56 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) (limited to 'honey/ecs.lua') 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 -- cgit v1.2.1