#include "NavMesh.hpp"
#include "../ui/ComponentRegistration.hpp"
#include "../ui/NavMeshEditor.hpp"
#include "../ui/NavMeshGeometrySourceEditor.hpp"

REGISTER_COMPONENT_GROUP("NavMesh", "Navigation", NavMeshComponent,
			 NavMeshEditor)
{
	registry.registerComponent<NavMeshComponent>(
		"NavMesh", "Navigation",
		std::make_unique<NavMeshEditor>(),
		// Adder
		[](flecs::entity e) {
			if (!e.has<NavMeshComponent>())
				e.set<NavMeshComponent>({});
		},
		// Remover
		[](flecs::entity e) {
			if (e.has<NavMeshComponent>())
				e.remove<NavMeshComponent>();
		});
}

REGISTER_COMPONENT_GROUP("NavMesh Geometry Source", "Navigation",
			 NavMeshGeometrySource, NavMeshGeometrySourceEditor)
{
	registry.registerComponent<NavMeshGeometrySource>(
		"NavMesh Geometry Source", "Navigation",
		std::make_unique<NavMeshGeometrySourceEditor>(),
		[](flecs::entity e) {
			if (!e.has<NavMeshGeometrySource>())
				e.set<NavMeshGeometrySource>({});
		},
		[](flecs::entity e) {
			if (e.has<NavMeshGeometrySource>())
				e.remove<NavMeshGeometrySource>();
		});
}
