#ifndef EDITSCENE_LOD_HPP
#define EDITSCENE_LOD_HPP
#pragma once

#include <Ogre.h>
#include <flecs.h>
#include <string>
#include "LodSettings.hpp"

/**
 * LodComponent - Per-entity LOD configuration
 * 
 * This component references a LodSettingsComponent by its settingsId
 * for persistent identification across scene loads.
 */
struct LodComponent {
	// Reference to the settings by ID (persistent across scene loads)
	std::string settingsId;
	
	// Runtime entity reference (resolved from settingsId)
	flecs::entity settingsEntity = flecs::entity::null();
	
	// Per-entity distance multiplier (scales all LOD distances)
	float distanceMultiplier = 1.0f;
	
	// Whether LOD has been applied to the mesh
	bool lodApplied = false;
	
	// Last settings version that was applied
	uint32_t appliedVersion = 0;
	
	// Dirty flag for regenerating LOD
	bool dirty = true;
	
	void markDirty() { dirty = true; }
	
	// Helper to check if LOD needs to be regenerated
	bool needsUpdate() const { return dirty; }
	
	// Helper to check if settings reference is valid
	bool hasValidSettings() const {
		return settingsEntity.is_alive() && 
		       settingsEntity.has<LodSettingsComponent>();
	}
};

#endif // EDITSCENE_LOD_HPP
