Add destructor for SpatialGridID and Path, remove unused Animation code
This commit is contained in:
24
game/main.c
24
game/main.c
@@ -133,6 +133,20 @@ void loadMap(Game *game, const char *path) {
|
||||
bzTileMapOverrideObjectGroup(&game->map, OBJECTS_ENTITIES, initEntityObjectsLayer);
|
||||
|
||||
}
|
||||
ECS_DTOR(SpatialGridID, gridID, {
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
bzSpatialGridRemove(game->entityGrid, *gridID);
|
||||
})
|
||||
ECS_DTOR(Path, path, {
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
BzObjectPool *pool = game->pools.pathData;
|
||||
|
||||
PathData *cur = path[i].paths;
|
||||
while (cur) {
|
||||
bzObjectPoolRelease(pool, cur);
|
||||
cur = cur->next;
|
||||
}
|
||||
})
|
||||
|
||||
bool init(void *userData) {
|
||||
BZ_UNUSED(userData);
|
||||
@@ -185,10 +199,14 @@ bool init(void *userData) {
|
||||
.path="assets/game.tsj",
|
||||
.texturePath="assets/game.png"
|
||||
});
|
||||
loadMap(game, "assets/maps/main_menu_01.tmj");
|
||||
|
||||
|
||||
ECS_OBSERVER(ECS, entitySpatialRemove, EcsOnRemove, SpatialGridID);
|
||||
ecs_set_hooks(ECS, SpatialGridID, {
|
||||
.dtor = ecs_dtor(SpatialGridID)
|
||||
});
|
||||
ecs_set_hooks(ECS, Path, {
|
||||
.dtor = ecs_dtor(Path)
|
||||
});
|
||||
ECS_OBSERVER(ECS, entityPathRemove, EcsOnRemove, Path);
|
||||
|
||||
//ECS_OBSERVER(ECS, entitySetAnimationState, EcsOnSet, Animation, AnimationType);
|
||||
@@ -217,6 +235,8 @@ bool init(void *userData) {
|
||||
ECS_SYSTEM(ECS, renderColliders, EcsOnUpdate, Position, Size);
|
||||
ECS_SYSTEM(ECS, renderRotationDirection, EcsOnUpdate, Position, Rotation, TextureEntities);
|
||||
|
||||
loadMap(game, "assets/maps/main_menu_01.tmj");
|
||||
|
||||
renderDebugPathSystem = renderDebugPath;
|
||||
renderCollidersSystem = renderColliders;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user