Add Game as singleton

This commit is contained in:
2023-11-15 08:18:56 +01:00
parent 274612b035
commit d37936ce7f
6 changed files with 55 additions and 27 deletions

View File

@@ -70,6 +70,7 @@ bool canPlaceBuilding(BzTileMap *map, BuildingType type, BzTile tileX, BzTile ti
}
ecs_entity_t placeBuilding(BzTileMap *map, BuildingType type, BzTile tileX, BzTile tileY) {
Game *game = ecs_singleton_get_mut(ECS, Game);
i32 sizeX, sizeY;
getBuildingSize(type, &sizeX, &sizeY);
ECS_COMPONENT(ECS, TilePosition);
@@ -94,7 +95,7 @@ ecs_entity_t placeBuilding(BzTileMap *map, BuildingType type, BzTile tileX, BzTi
bzTileLayerSetTile(buildingLayer, layerTile, x, y, 1, 1);
buildingTile++;
GAME->entityMap[y * buildingLayer->width + x] = e;
game->entityMap[y * buildingLayer->width + x] = e;
bzTileMapUpdateCollider(map, x, y);
}