From 56ea4768c6decc07df7fd9025561835ac8be9d64 Mon Sep 17 00:00:00 2001 From: the lemons Date: Sun, 28 Aug 2022 00:15:24 -0500 Subject: obj:remove: error on dependency problem --- world.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/world.lua b/world.lua index ec35d07..e32938d 100644 --- a/world.lua +++ b/world.lua @@ -64,8 +64,14 @@ end function obj_proto:remove(ct) local c = assert(self:get(ct)) - self.world:unreg_component(c) - if c.disable then c:disable() end + for oc in obj:all_components() do + for d in ipairs(oc.deps) do + assert(d[1] ~= ct, "dependency") + end + end + self.world:unreg_component(c) + if c.disable then c:disable() end + if c.remove then c:remove() end end function obj_proto:require(ct, instance) -- cgit v1.2.3