Add arms destructor (cleans up attached components

This commit is contained in:
2024-01-07 09:36:35 +01:00
parent 07e03702ad
commit e4111d2014

View File

@@ -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);