#ifndef WATER_PHYSICS_EDITOR_HPP
#define WATER_PHYSICS_EDITOR_HPP
#pragma once

#include "ComponentEditor.hpp"
#include "../components/WaterPhysics.hpp"

/**
 * Editor for WaterPhysics component
 */
class WaterPhysicsEditor : public ComponentEditor<WaterPhysics> {
public:
	bool renderComponent(flecs::entity entity,
			     WaterPhysics &component) override
	{
		bool changed = false;

		ImGui::Text("Water Physics Settings");
		ImGui::Separator();

		// Enabled toggle
		if (ImGui::Checkbox("Enabled", &component.enabled)) {
			changed = true;
		}

		// Water surface Y level
		if (ImGui::SliderFloat("Water Surface Y",
				       &component.waterSurfaceY, -10.0f, 10.0f,
				       "%.2f")) {
			changed = true;
		}

		// Water density
		if (ImGui::SliderFloat("Water Density (kg/m³)",
				       &component.waterDensity, 500.0f, 2000.0f,
				       "%.0f")) {
			changed = true;
		}

		// Gravity
		if (ImGui::SliderFloat("Gravity (m/s²)", &component.gravity,
				       0.0f, 20.0f, "%.2f")) {
			changed = true;
		}

		ImGui::Separator();
		ImGui::Text("Default Buoyancy Parameters");

		// Default buoyancy
		if (ImGui::SliderFloat("Default Buoyancy",
				       &component.defaultBuoyancy, 0.0f, 5.0f,
				       "%.2f")) {
			changed = true;
		}
		ImGui::SameLine();
		ImGui::TextDisabled("(?)");
		if (ImGui::IsItemHovered()) {
			ImGui::SetTooltip(
				"Default buoyancy density multiplier (1.0 = neutral buoyancy)");
		}

		// Default linear drag
		if (ImGui::SliderFloat("Default Linear Drag",
				       &component.defaultLinearDrag, 0.0f, 1.0f,
				       "%.3f")) {
			changed = true;
		}
		ImGui::SameLine();
		ImGui::TextDisabled("(?)");
		if (ImGui::IsItemHovered()) {
			ImGui::SetTooltip(
				"Default linear drag coefficient for objects in water");
		}

		// Default angular drag
		if (ImGui::SliderFloat("Default Angular Drag",
				       &component.defaultAngularDrag, 0.0f,
				       1.0f, "%.3f")) {
			changed = true;
		}
		ImGui::SameLine();
		ImGui::TextDisabled("(?)");
		if (ImGui::IsItemHovered()) {
			ImGui::SetTooltip(
				"Default angular drag coefficient for objects in water");
		}

		// Default submerged threshold
		if (ImGui::SliderFloat("Submerged Threshold",
				       &component.defaultSubmergedThreshold,
				       0.0f, 1.0f, "%.2f")) {
			changed = true;
		}
		ImGui::SameLine();
		ImGui::TextDisabled("(?)");
		if (ImGui::IsItemHovered()) {
			ImGui::SetTooltip(
				"Minimum submerged fraction to apply buoyancy (0.0 = any contact, 1.0 = fully submerged)");
		}

		return changed;
	}

	const char *getName() const override
	{
		return "Water Physics";
	}
};

#endif // WATER_PHYSICS_EDITOR_HPP
