Rewritten grid matching in more declarative way
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "queries.h"
|
||||
#include "building_layout_graph.h"
|
||||
#include "growth_module.h"
|
||||
// TODO: make sure Enterance is at outside wall, can do this on region level or on cell level
|
||||
|
||||
growth_module::growth_module(flecs::world &ecs)
|
||||
{
|
||||
@@ -15,6 +16,10 @@ growth_module::growth_module(flecs::world &ecs)
|
||||
ecs.component<WorldEditor::components::internal_wall_west>();
|
||||
ecs.component<WorldEditor::components::internal_wall_north>();
|
||||
ecs.component<WorldEditor::components::internal_wall_south>();
|
||||
ecs.component<WorldEditor::components::internal_door_east>();
|
||||
ecs.component<WorldEditor::components::internal_door_west>();
|
||||
ecs.component<WorldEditor::components::internal_door_north>();
|
||||
ecs.component<WorldEditor::components::internal_door_south>();
|
||||
ecs.component<WorldEditor::components::outside_wall_east>();
|
||||
ecs.component<WorldEditor::components::outside_wall_west>();
|
||||
ecs.component<WorldEditor::components::outside_wall_north>();
|
||||
@@ -30,6 +35,7 @@ growth_module::growth_module(flecs::world &ecs)
|
||||
flecs::entity GraphSolve = ecs.lookup("::graph_module::GraphSolve");
|
||||
assert(GraphSolve.is_valid());
|
||||
GraphFilter.disable();
|
||||
assert(ecs.lookup("::growth_module::window_east").is_valid());
|
||||
|
||||
ecs.system("RunGrow")
|
||||
.immediate()
|
||||
|
||||
@@ -127,7 +127,7 @@ protected:
|
||||
int y = 0;
|
||||
int z = cell.index / grid_size;
|
||||
Transform base_transform(Basis(),
|
||||
Vector3(x * 4, 0, z * 4));
|
||||
Vector3(x * 4, y, z * 4));
|
||||
int matches = 0;
|
||||
struct pmatch {
|
||||
int check;
|
||||
@@ -243,38 +243,43 @@ protected:
|
||||
-Math_PI / 2),
|
||||
Vector3(2, 0, 0), false },
|
||||
};
|
||||
if (e.has<WorldEditor::components::outside_wall_north>())
|
||||
matches |= 1;
|
||||
if (e.has<WorldEditor::components::outside_wall_south>())
|
||||
matches |= 2;
|
||||
if (e.has<WorldEditor::components::outside_wall_west>())
|
||||
matches |= 4;
|
||||
if (e.has<WorldEditor::components::outside_wall_east>())
|
||||
matches |= 8;
|
||||
if (e.has<WorldEditor::components::internal_wall_north>())
|
||||
matches |= 16;
|
||||
if (e.has<WorldEditor::components::internal_wall_south>())
|
||||
matches |= 32;
|
||||
if (e.has<WorldEditor::components::internal_wall_west>())
|
||||
matches |= 64;
|
||||
if (e.has<WorldEditor::components::internal_wall_east>())
|
||||
matches |= 128;
|
||||
if (e.has<WorldEditor::components::window_north>())
|
||||
matches |= 256;
|
||||
if (e.has<WorldEditor::components::window_south>())
|
||||
matches |= 512;
|
||||
if (e.has<WorldEditor::components::window_west>())
|
||||
matches |= 1024;
|
||||
if (e.has<WorldEditor::components::window_east>())
|
||||
matches |= 2048;
|
||||
if (e.has<WorldEditor::components::internal_door_north>())
|
||||
matches |= 4096;
|
||||
if (e.has<WorldEditor::components::internal_door_south>())
|
||||
matches |= 8192;
|
||||
if (e.has<WorldEditor::components::internal_door_west>())
|
||||
matches |= 16384;
|
||||
if (e.has<WorldEditor::components::internal_door_east>())
|
||||
matches |= 32768;
|
||||
struct match_window {
|
||||
const char *cmp_name;
|
||||
int match;
|
||||
};
|
||||
struct match_window cmp_matches[] = {
|
||||
{ "::growth_module::outside_wall_north", 1 },
|
||||
{ "::growth_module::outside_wall_south", 2 },
|
||||
{ "::growth_module::outside_wall_west", 4 },
|
||||
{ "::growth_module::outside_wall_east", 8 },
|
||||
{ "::growth_module::internal_wall_north", 16 },
|
||||
{ "::growth_module::internal_wall_south", 32 },
|
||||
{ "::growth_module::internal_wall_west", 64 },
|
||||
{ "::growth_module::internal_wall_east", 128 },
|
||||
{ "::growth_module::window_north", 256 },
|
||||
{ "::growth_module::window_south", 512 },
|
||||
{ "::growth_module::window_west", 1024 },
|
||||
{ "::growth_module::window_east", 2048 },
|
||||
{ "::growth_module::internal_door_north",
|
||||
4096 },
|
||||
{ "::growth_module::internal_door_south",
|
||||
8192 },
|
||||
{ "::growth_module::internal_door_west",
|
||||
16384 },
|
||||
{ "::growth_module::internal_door_east",
|
||||
32768 },
|
||||
};
|
||||
for (i = 0; i < (int)sizeof(cmp_matches) /
|
||||
(int)sizeof(cmp_matches[0]);
|
||||
i++) {
|
||||
flecs::entity cmp = e.world().lookup(
|
||||
cmp_matches[i].cmp_name);
|
||||
flecs::log::dbg("component: %s",
|
||||
cmp_matches[i].cmp_name);
|
||||
assert(cmp.is_valid());
|
||||
if (e.has(cmp))
|
||||
matches |= cmp_matches[i].match;
|
||||
}
|
||||
for (i = 0; i < 2; i++)
|
||||
item_data[i].items.clear();
|
||||
for (i = 0; i < (int)sizeof(match_data) /
|
||||
|
||||
Reference in New Issue
Block a user