55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
#include <cassert>
|
|
#include <cstdio>
|
|
#include <core/math/vector2.h>
|
|
#include <core/math/rect2.h>
|
|
#include "flecs.h"
|
|
#include "graph_module.h"
|
|
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;
|
|
}
|