#include "ActionDatabase.hpp"
#include "ActionDebug.hpp"
#include "BehaviorTree.hpp"
#include "GoapAction.hpp"
#include "GoapGoal.hpp"
#include "GoapBlackboard.hpp"
#include "../ui/ComponentRegistration.hpp"
#include "../ui/ActionDatabaseEditor.hpp"
#include "../ui/BehaviorTreeEditor.hpp"

REGISTER_COMPONENT_GROUP("Action Database", "AI", ActionDatabaseComponent,
			 ActionDatabaseEditor)
{
	registry.registerComponent<ActionDatabaseComponent>(
		"Action Database", "AI",
		std::make_unique<ActionDatabaseEditor>(),
		// Adder
		[](flecs::entity e) {
			if (!e.has<ActionDatabaseComponent>())
				e.set<ActionDatabaseComponent>({});
		},
		// Remover
		[](flecs::entity e) {
			if (e.has<ActionDatabaseComponent>())
				e.remove<ActionDatabaseComponent>();
		});
}

REGISTER_COMPONENT_GROUP("Behavior Tree", "AI", BehaviorTreeComponent,
			 BehaviorTreeEditor)
{
	registry.registerComponent<BehaviorTreeComponent>(
		"Behavior Tree", "AI", std::make_unique<BehaviorTreeEditor>(),
		// Adder
		[](flecs::entity e) {
			if (!e.has<BehaviorTreeComponent>()) {
				BehaviorTreeComponent bt;
				bt.root.type = "sequence";
				e.set<BehaviorTreeComponent>(bt);
			}
		},
		// Remover
		[](flecs::entity e) {
			if (e.has<BehaviorTreeComponent>())
				e.remove<BehaviorTreeComponent>();
		});
}
