Better drawing of layout tiles

This commit is contained in:
2024-12-01 19:04:49 +03:00
parent 42dc811cf6
commit 5dfa476a54
3 changed files with 74 additions and 20 deletions

View File

@@ -873,12 +873,46 @@ void BuildingLayoutGraphUI::draw_2d_grid_view(Control *draw)
Color(0.1f, 0.1f, 0.1f, 1.0f), Color(0.1f, 0.1f, 0.1f, 1.0f),
false); false);
if (fc.has<WorldEditor::components:: if (fc.has<WorldEditor::components::
outside_wall>()) outside_wall>()) {
draw->draw_circle( draw->draw_circle(
Vector2(dx + 0.5f * dsize, Vector2(dx + 0.5f * dsize,
dy + 0.5f * dsize), dy + 0.5f * dsize),
dsize * 0.4f, dsize * 0.4f,
Color(0, 0, 1, 1)); Color(0, 0, 1, 1));
if (fc.has<WorldEditor::components::
outside_wall_west>())
draw->draw_rect(
Rect2(dx - dsize * 0.25f,
dy, dsize * 0.25f,
dsize),
Color(0, 0, 1, 1),
true);
if (fc.has<WorldEditor::components::
outside_wall_east>())
draw->draw_rect(
Rect2(dx + dsize, dy,
dsize * 0.25f,
dsize),
Color(0, 0, 1, 1),
true);
if (fc.has<WorldEditor::components::
outside_wall_north>())
draw->draw_rect(
Rect2(dx,
dy - dsize * 0.25f,
dsize,
dsize * 0.25),
Color(0, 0, 1, 1),
true);
if (fc.has<WorldEditor::components::
outside_wall_south>())
draw->draw_rect(
Rect2(dx, dy + dsize,
dsize,
dsize * 0.25),
Color(0, 0, 1, 1),
true);
}
if (fc.has<WorldEditor::components::border>()) if (fc.has<WorldEditor::components::border>())
draw->draw_circle( draw->draw_circle(
Vector2(dx + 0.5f * dsize, Vector2(dx + 0.5f * dsize,

View File

@@ -114,8 +114,20 @@ growth_module::growth_module(flecs::world &ecs)
.ptr()); .ptr());
if (!neighbor_e.is_valid()) { if (!neighbor_e.is_valid()) {
outside = true; outside = true;
break; if (id == west_id)
e.add<WorldEditor::components::
outside_wall_west>();
else if (id == east_id)
e.add<WorldEditor::components::
outside_wall_east>();
else if (id == north_id)
e.add<WorldEditor::components::
outside_wall_north>();
else if (id == south_id)
e.add<WorldEditor::components::
outside_wall_south>();
} }
#if 0
if (!e.parent() if (!e.parent()
.get<WorldEditor::components:: .get<WorldEditor::components::
buildings_layout_grid_floor>() buildings_layout_grid_floor>()
@@ -123,26 +135,30 @@ growth_module::growth_module(flecs::world &ecs)
outside = true; outside = true;
break; break;
} }
#endif
} }
flecs::log::dbg("outside: %d", outside); flecs::log::dbg("outside: %d", outside);
#if 0 #ifdef MAKE_BORDER
for (i = 0; i < (int)neighbors.size(); i++) { for (i = 0; i < (int)neighbors.size(); i++) {
int id = neighbors[i]; int id = neighbors[i];
print_line("id=" + itos(id)); print_line("id=" + itos(id));
String neighbor_name = "cell_" + itos(id); String neighbor_name =
flecs::entity neighbor_e = "cell_" + itos(id);
e.parent().lookup(neighbor_name.ascii().ptr()); flecs::entity neighbor_e =
if (!neighbor_e.is_valid()) e.parent().lookup(
continue; neighbor_name.ascii()
const WorldEditor::components::buildings_layout_grid_cell .ptr());
*neighbor_cell = neighbor_e.get< if (!neighbor_e.is_valid())
WorldEditor::components:: continue;
buildings_layout_grid_cell>(); const WorldEditor::components::buildings_layout_grid_cell
if (cell.type != neighbor_cell->type) { *neighbor_cell = neighbor_e.get<
border = true; WorldEditor::components::
break; buildings_layout_grid_cell>();
} if (cell.type != neighbor_cell->type) {
} border = true;
break;
}
}
#endif #endif
if (outside) { if (outside) {
e.add<WorldEditor::components:: e.add<WorldEditor::components::

View File

@@ -123,6 +123,10 @@ public:
struct border {}; struct border {};
struct belongs_room {}; struct belongs_room {};
struct outside_wall {}; struct outside_wall {};
struct outside_wall_east {};
struct outside_wall_west {};
struct outside_wall_north {};
struct outside_wall_south {};
struct corridoor {}; struct corridoor {};
struct buildings_layout_grid_floor { struct buildings_layout_grid_floor {
Set<int> cells; Set<int> cells;