tests
This commit is contained in:
74
tests/graph_module.cpp
Normal file
74
tests/graph_module.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <core/math/vector2.h>
|
||||
#include <core/math/rect2.h>
|
||||
#include "flecs.h"
|
||||
#include "graph_module.h"
|
||||
namespace WorldEditor
|
||||
{
|
||||
namespace components
|
||||
{
|
||||
struct buildings_layout_zone
|
||||
{
|
||||
int type;
|
||||
bool align_wall;
|
||||
};
|
||||
struct buildings_layout_area
|
||||
{
|
||||
float area;
|
||||
};
|
||||
struct buildings_layout_system
|
||||
{
|
||||
flecs::entity e;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
struct graph_module
|
||||
{
|
||||
graph_module(flecs::world &ecs)
|
||||
{
|
||||
// ecs.module<graph_module>();
|
||||
flecs::entity s = ecs.system<WorldEditor::components::buildings_layout_zone>("ZoneArea2")
|
||||
.kind(0)
|
||||
.without<WorldEditor::components::buildings_layout_area>()
|
||||
.write<WorldEditor::components::buildings_layout_area>()
|
||||
.each([](flecs::iter &it, size_t count,
|
||||
WorldEditor::components::buildings_layout_zone &f)
|
||||
{
|
||||
flecs::entity zone_e = it.entity(count);
|
||||
printf("running...2\n");
|
||||
zone_e.set<
|
||||
WorldEditor::components::buildings_layout_area>(
|
||||
{ 0.0f }); });
|
||||
ecs.system<WorldEditor::components::buildings_layout_zone>("Zone2")
|
||||
.kind(flecs::OnUpdate)
|
||||
.each([](flecs::iter &it, size_t count,
|
||||
WorldEditor::components::buildings_layout_zone &f)
|
||||
{
|
||||
flecs::entity zone_e = it.entity(count);
|
||||
flecs::world w = zone_e.world();
|
||||
flecs::entity se = w.lookup("::graph_module::ZoneArea2");
|
||||
assert(se.is_valid());
|
||||
w.system(se).run(); });
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
flecs::world ecs;
|
||||
ecs.import <graph_module>();
|
||||
printf("1\n");
|
||||
flecs::entity e0 = ecs.entity("base");
|
||||
flecs::entity e1 = ecs.entity("zone1").child_of(e0);
|
||||
printf("2\n");
|
||||
e1.set<WorldEditor::components::buildings_layout_zone>({0, false});
|
||||
flecs::entity e2 = ecs.entity("zone2").child_of(e0);
|
||||
printf("3\n");
|
||||
e2.set<WorldEditor::components::buildings_layout_zone>({1, true});
|
||||
printf("4\n");
|
||||
while (1)
|
||||
ecs.progress();
|
||||
printf("5\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user