From 5014f13cd0751773d7aa51a1416cdb0475fecbb4 Mon Sep 17 00:00:00 2001 From: Klemen Plestenjak Date: Fri, 29 Dec 2023 19:47:28 +0100 Subject: [PATCH] Add moveDtor to properly manage lifecycle --- game/systems/systems.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/game/systems/systems.c b/game/systems/systems.c index 8a2a0b1..7d14594 100644 --- a/game/systems/systems.c +++ b/game/systems/systems.c @@ -8,6 +8,10 @@ ecs_entity_t renderDebugPathSystem; ECS_DTOR(SpatialGridID, gridID, { Game *game = ecs_singleton_get_mut(ECS, Game); bzSpatialGridRemove(game->entityGrid, *gridID); + bzLogInfo("Removed"); +}) +ECS_MOVE(SpatialGridID, dst, src, { + *dst = *src; }) ECS_DTOR(Path, path, { Game *game = ecs_singleton_get_mut(ECS, Game); @@ -19,13 +23,18 @@ ECS_DTOR(Path, path, { cur = cur->next; } }) +ECS_MOVE(Path, dst, src, { + *dst = *src; +}) void setupSystems() { ecs_set_hooks(ECS, SpatialGridID, { - .dtor = ecs_dtor(SpatialGridID) + .dtor = ecs_dtor(SpatialGridID), + .move_dtor = ecs_move(SpatialGridID) }); ecs_set_hooks(ECS, Path, { - .dtor = ecs_dtor(Path) + .dtor = ecs_dtor(Path), + .move_dtor = ecs_move(Path) }); ECS_OBSERVER(ECS, entityPathRemove, EcsOnRemove, Path);