Buildings as entities instead of map layer
This commit is contained in:
19
game/main.c
19
game/main.c
@@ -103,9 +103,9 @@ void loadMap(Game *game, const char *path) {
|
||||
.layers[LAYER_TERRAIN]=(BzTileLayerDesc) {"terrain", .renderer=terrainRender, .applyColliders=true},
|
||||
.layers[LAYER_ROCKS]=(BzTileLayerDesc) {"rocks"},
|
||||
.layers[LAYER_ROCKS2]=(BzTileLayerDesc) {"rocks_s"},
|
||||
.layers[LAYER_TREES]=(BzTileLayerDesc) {"trees"},
|
||||
.layers[LAYER_TREES2]=(BzTileLayerDesc) {"trees_s"},
|
||||
.layers[LAYER_BUILDINGS]=(BzTileLayerDesc) {"buildings", .applyColliders=true},
|
||||
.layers[LAYER_TREES]=(BzTileLayerDesc) {"trees", BZ_TILE_LAYER_SKIP_RENDER},
|
||||
.layers[LAYER_TREES2]=(BzTileLayerDesc) {"trees_s", BZ_TILE_LAYER_SKIP_RENDER},
|
||||
.layers[LAYER_BUILDINGS]=(BzTileLayerDesc) {"buildings", BZ_TILE_LAYER_SKIP_RENDER},
|
||||
.layers[LAYER_BUILDING_OWNER]=(BzTileLayerDesc) {"building_ownership", BZ_TILE_LAYER_SKIP_RENDER},
|
||||
|
||||
.objectGroups[OBJECTS_GAME]=(BzTileObjectsDesc) {"game"},
|
||||
@@ -129,6 +129,7 @@ void loadMap(Game *game, const char *path) {
|
||||
bzTileMapOverrideLayer(&game->map, LAYER_TREES2, initTreesLayer);
|
||||
|
||||
bzTileMapOverrideLayer(&game->map, LAYER_BUILDING_OWNER, initBuildingsLayer);
|
||||
bzTileMapOverrideLayer(&game->map, LAYER_BUILDINGS, BZ_TILE_LAYER_CLEAR);
|
||||
|
||||
bzTileMapOverrideObjectGroup(&game->map, OBJECTS_GAME, initGameObjectsLayer);
|
||||
bzTileMapOverrideObjectGroup(&game->map, OBJECTS_ENTITIES, initEntityObjectsLayer);
|
||||
@@ -197,6 +198,8 @@ bool init(void *userData) {
|
||||
{ecs_id(Selected)}
|
||||
}
|
||||
});
|
||||
|
||||
input->building = BUILDING_NONE;
|
||||
}
|
||||
{
|
||||
InitAudioDevice();
|
||||
@@ -652,8 +655,6 @@ void igInspectWindow(ecs_entity_t entity, bool *open) {
|
||||
igTagCheckbox("Attackable", ECS, entity, Attackable);
|
||||
}
|
||||
igInspectComp("Resource", entity, ecs_id(Resource), igResource);
|
||||
igInspectComp("TilePosition", entity, ecs_id(TilePosition), igTilePosition);
|
||||
igInspectComp("TileSize", entity, ecs_id(TileSize), igTileSize);
|
||||
igInspectComp("Owner", entity, ecs_id(Owner), igOwner);
|
||||
igInspectComp("SpatialGridID", entity, ecs_id(SpatialGridID), igSpatialGridID);
|
||||
igInspectComp("Position", entity, ecs_id(Position), igVec2Comp);
|
||||
@@ -735,11 +736,13 @@ void imguiRender(float dt, void *userData) {
|
||||
igText("Population: %lld", game->resources.pop);
|
||||
}
|
||||
if (igCollapsingHeader_TreeNodeFlags("BuildMenu", 0)) {
|
||||
for (int i = 0; i < BUILDING_COUNT; i++) {
|
||||
if (igSelectable_Bool(getBuildingStr(i), input->building == i, 0, (ImVec2){0, 0}))
|
||||
for (int i = BUILDING_NONE; i < BUILDING_COUNT; i++) {
|
||||
const char *buildingStr = getBuildingStr(i);
|
||||
if (!buildingStr) buildingStr = "NONE";
|
||||
if (igSelectable_Bool(buildingStr, input->building == i, 0, (ImVec2){0, 0}))
|
||||
input->building = i;
|
||||
}
|
||||
if (input->building)
|
||||
if (input->building > BUILDING_NONE && input->building < BUILDING_COUNT)
|
||||
input->state = INPUT_BUILDING;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user