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