summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthe lemons <citrons@mondecitronne.com>2022-08-28 00:15:24 -0500
committerthe lemons <citrons@mondecitronne.com>2022-08-28 00:20:00 -0500
commit56ea4768c6decc07df7fd9025561835ac8be9d64 (patch)
treef51b5e694881128f62154275c4ede279a543461c
parenta96780e04d22c916921be996a6b99487efc4e569 (diff)
obj:remove: error on dependency problem
-rw-r--r--world.lua10
1 files 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)