#include <vector>
#include <goap/goap.hpp>
#include "world-build.h"

namespace ECS
{
GameWorldModule::GameWorldModule(flecs::world &ecs)
{
	ecs.module<GameWorldModule>();
	ecs.component<GameWorld>().add(flecs::Singleton);
	ecs.set<GameWorld>({ nullptr });
	ecs.system<GameWorld>("RunUpdateQueue")
		.kind(flecs::OnUpdate)
		.rate(5)
		.each([](GameWorld &gw) {
			while (!gw.queue.empty()) {
				GameWorld::QueueTask task = gw.queue.front();
				gw.queue.pop_front();
				(*task.command)(task.args);
			}
		});
}
}
