#include "CharacterSlots.hpp"
#include "../ui/ComponentRegistration.hpp"
#include "../ui/CharacterSlotsEditor.hpp"
#include "../systems/CharacterSlotSystem.hpp"
#include "Transform.hpp"

REGISTER_COMPONENT_GROUP("Character Slots", "Rendering",
				 CharacterSlotsComponent, CharacterSlotsEditor)
{
	CharacterSlotSystem::loadCatalog();

	registry.registerComponent<CharacterSlotsComponent>(
		"Character Slots",
		"Rendering",
		std::make_unique<CharacterSlotsEditor>(sceneMgr),
		/* Adder */
		[sceneMgr](flecs::entity e) {
			if (!e.has<TransformComponent>()) {
				TransformComponent transform;
				transform.node =
					sceneMgr->getRootSceneNode()
						->createChildSceneNode();
				e.set<TransformComponent>(transform);
			}
			CharacterSlotsComponent cs;
			cs.dirty = true;
			e.set<CharacterSlotsComponent>(cs);
		},
		/* Remover */
		[sceneMgr](flecs::entity e) {
			(void)sceneMgr;
			e.remove<CharacterSlotsComponent>();
		}
	);
}
