From e4111d2014a73033016fd802e9947a5debc69c89 Mon Sep 17 00:00:00 2001 From: Klemen Plestenjak Date: Sun, 7 Jan 2024 09:36:35 +0100 Subject: [PATCH] Add arms destructor (cleans up attached components --- game/systems/systems.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/game/systems/systems.c b/game/systems/systems.c index 2311893..14e5969 100644 --- a/game/systems/systems.c +++ b/game/systems/systems.c @@ -28,6 +28,13 @@ ECS_MOVE(Path, dst, src, { *dst = *src; }) +ECS_DTOR(Arms, arms, { + if (arms->primary) + ecs_delete(ECS, arms->primary); + if (arms->secondary) + ecs_delete(ECS, arms->secondary); +}); + void setupSystems() { ecs_set_hooks(ECS, SpatialGridID, { .dtor = ecs_dtor(SpatialGridID), @@ -37,6 +44,9 @@ void setupSystems() { .dtor = ecs_dtor(Path), .move_dtor = ecs_move(Path) }); + ecs_set_hooks(ECS, Arms, { + .dtor = ecs_dtor(Arms) + }); ECS_OBSERVER(ECS, entityPathRemove, EcsOnRemove, Path);