Properly handle map collisions when placing/destroying buildings

This commit is contained in:
2024-01-08 15:27:58 +01:00
parent c08fca9670
commit 88cbfe4a37
8 changed files with 56 additions and 7 deletions

View File

@@ -645,6 +645,12 @@ void igInspectWindow(ecs_entity_t entity, bool *open) {
char buf[64];
snprintf(buf, sizeof(buf), "Entity: %ld", entity);
if (igBegin(buf, open, 0)) {
if (igSmallButton("Destroy")) {
ecs_delete(ECS, entity);
igEnd();
*open = false;
return;
}
if (igCollapsingHeader_TreeNodeFlags("Tags", 0)) {
//igTagCheckbox("GameEntity", ECS, entity, GameEntity);
igTagCheckbox("Selectable", ECS, entity, Selectable);
@@ -711,7 +717,6 @@ void imguiRender(float dt, void *userData) {
case INPUT_SELECTED_UNITS:
case INPUT_SELECTED_OBJECT:
case INPUT_SELECTED_BUILDING: {
ecs_defer_begin(ECS);
ecs_iter_t it = ecs_query_iter(ECS, input->queries.selected);
while (ecs_iter_next(&it)) {
for (i32 i = 0; i < it.count; i++) {
@@ -719,7 +724,6 @@ void imguiRender(float dt, void *userData) {
igText("Entity: %ld", entity);
}
}
ecs_defer_end(ECS);
break;
}
default:
@@ -761,6 +765,7 @@ void imguiRender(float dt, void *userData) {
}
igEnd();
ecs_defer_begin(ECS);
i32 inspectLen = bzArraySize(game->debug.inspecting);
for (i32 i = inspectLen - 1; i >= 0; i--) {
bool open = true;
@@ -769,5 +774,6 @@ void imguiRender(float dt, void *userData) {
bzArrayDelSwap(game->debug.inspecting, i);
}
}
ecs_defer_end(ECS);
}