Properly handle map collisions when placing/destroying buildings
This commit is contained in:
@@ -75,7 +75,17 @@ ECS_DTOR(Arms, arms, {
|
||||
})
|
||||
ECS_MOVE(Arms, dst, src, {
|
||||
*dst = *src;
|
||||
});
|
||||
})
|
||||
|
||||
ECS_DTOR(Building, building, {
|
||||
Vec2i pos = building->pos;
|
||||
Vec2i size = building->size;
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
bzTileMapSetCollisions(&game->map, false, pos.x, pos.y, size.x, size.y);
|
||||
})
|
||||
ECS_MOVE(Building, dst, src, {
|
||||
*dst = *src;
|
||||
})
|
||||
|
||||
void setupSystems() {
|
||||
ecs_set_hooks(ECS, SpatialGridID, {
|
||||
@@ -90,6 +100,10 @@ void setupSystems() {
|
||||
.dtor = ecs_dtor(Arms),
|
||||
.move_dtor = ecs_move(Arms)
|
||||
});
|
||||
ecs_set_hooks(ECS, Building, {
|
||||
.dtor = ecs_dtor(Building),
|
||||
.move_dtor = ecs_move(Building)
|
||||
});
|
||||
|
||||
ECS_OBSERVER(ECS, entityPathRemove, EcsOnRemove, Path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user