#ifndef EDITSCENE_CHARACTERSLOTS_HPP
#define EDITSCENE_CHARACTERSLOTS_HPP
#pragma once
#include <Ogre.h>
#include <unordered_map>
#include <vector>

/**
 * Selection criteria for a single character slot.
 * Layer 0 (nude base) is always implicit.
 * Layer 1 and 2 are selected via combo boxes.
 */
struct SlotSelection {
	Ogre::String layer1Mesh; // "none" or exact mesh name for layer 1
	Ogre::String layer2Mesh; // "none" or exact mesh name for layer 2
	Ogre::String explicitMesh; // backward-compat override
};

/**
 * Multi-slot mesh component for character parts sharing a skeleton.
 * The "face" slot (or first available slot) serves as the master skeleton.
 *
 * Age is now stored in CharacterRegistry::CharacterRecord::age
 * and should be retrieved from there when needed.
 */
struct CharacterSlotsComponent {
	Ogre::String sex = "male";

	/* Backward-compat: old mesh-name map. Deserialized into slotSelections on load. */
	std::unordered_map<Ogre::String, Ogre::String> slots;

	/* Per-slot layer selections (runtime) */
	std::unordered_map<Ogre::String, SlotSelection> slotSelections;

	bool dirty = true;

	/* Runtime: master entity with shared skeleton (set by CharacterSlotSystem) */
	Ogre::Entity *masterEntity = nullptr;

	/**
	 * Front-facing axis for this character model.
	 * Most models face -Z (NEGATIVE_UNIT_Z), but some face +Z.
	 */
	Ogre::Vector3 frontAxis = Ogre::Vector3::NEGATIVE_UNIT_Z;

	CharacterSlotsComponent() = default;
};

/**
 * Global shape key weights for a character.
 * Same name applies to all slots uniformly.
 */
struct CharacterShapeKeysComponent {
	std::unordered_map<Ogre::String, float> weights;
	bool dirty = true;
};

#endif // EDITSCENE_CHARACTERSLOTS_HPP
