using IslaApocalypse.Core;
namespace IslaApocalypse.Tools
{
///
/// The generator's configuration, including the per-element ABLATION TOGGLES.
///
/// ═══ WHY EVERY PASS-1 ELEMENT IS GATED ═══
///
/// This is the standing A/B discipline: every shaping change ships behind a gate with the
/// previous behaviour surviving on the other side, so changes stay comparable as a pair rather
/// than as a memory of last week's render, and a rejected change costs a flipped default rather
/// than a reverted commit. → `Design - Tooling - Iteration and Batching.md`.
///
/// For THIS task the gates do a second job: they are the PORT-FIDELITY CHECK. Generating
/// base-noise-only, then adding one element at a time, shows each ported element doing what the
/// reference's did — rather than judging six simultaneous changes by their sum.
///
/// ⚠ Lives in Tools/, not Core/. It configures the generator specifically; Core carries the
/// world's data contracts and the scaling rule, not a tool's dials.
///
public sealed class TerrainGenConfig
{
// ---- world ----------------------------------------------------------
///
/// Map side in columns. A GENERATION PARAMETER — never baked in.
/// Iteration runs small (2048–4096); the shape is scale-invariant by construction, so the
/// island reads the same at any size and a full-size pass is confirmation, not iteration.
///
public int MapSize = 2048;
///
/// The noise seed. POSITIVE ONLY. Zero or negative means "pick one and print it" — a run
/// whose seed is not recorded is a run that cannot be reproduced, so the resolved seed is
/// always printed and always in the filename.
///
public int Seed = 0;
// ---- island shape (reference ConfigManager defaults, READ from source) ----
/// Falloff X axis ratio. Reference: ConfigManager.LEGACY_AXIS_X = 1.15f.
public float IslandAxisX = 1.15f;
/// Falloff Y axis ratio. Reference: ConfigManager.LEGACY_AXIS_Y = 0.90f.
public float IslandAxisY = 0.90f;
///
/// Multiplier on the falloff term in the combine.
/// Reference: [Export] public float FalloffStrength = 1.0f; (MapGenerator ~:11),
/// and NOT overridden in MapPreview.tscn — so 1.0f is the value the island was tuned at.
///
public float FalloffStrength = 1.0f;
///
/// The flat sea level, in raw height units. Reference: ConfigManager.SeaLevelValue = 0.15f
/// with SeaLevelModel = "flat", so GetSeaLevel ignores latitude entirely.
///
/// ⚠ PHASE 1 USES THIS AS A VISUALIZATION THRESHOLD ONLY — the boundary between the
/// bathymetric and hypsometric colour ramps. No water is modelled, no water bodies are
/// identified, nothing floods. That is Phase 2.
///
public float SeaLevel = 0.15f;
// ---- ABLATION TOGGLES — the pass-1 ladder ---------------------------
/// Rung 1: the base terrain noise, (noise(x,y)+1)/2. Off = flat zero.
public bool BaseNoise = true;
///
/// Rung 2: the island falloff/mask — squircle + ellipse blend, and the Pow(·, 2.5f).
/// ⚠ Off also disables rungs 3–5 in effect: edge noise, the sinker and the Trench are all
/// modifiers OF the falloff, so with no falloff there is nothing for them to modify. The
/// toggles stay independent so the ladder reads honestly; the report says so.
///
public bool IslandFalloff = true;
/// Rung 3: coastline edge roughness, modulated by the squircle.
public bool EdgeNoise = true;
/// Rung 4: the southern sinker — extra sinking pressure in the bottom 25%.
public bool SouthernSinker = true;
/// Rung 5: the Trench — the map-anchored outer-band wall that guarantees an ocean border.
public bool Trench = true;
/// Rung 6: the mountain spine up the centre-X axis.
public bool MountainSpine = true;
/// A short label for this variant, used in output filenames. E.g. "full", "base_only".
public string VariantLabel = "full";
/// The scale object every distance and frequency in the generator derives from.
public GenerationScale Scale => new GenerationScale(MapSize);
public TerrainGenConfig Clone() => (TerrainGenConfig)MemberwiseClone();
public override string ToString() =>
$"MapSize={MapSize} Seed={Seed} axis={IslandAxisX:F2}x/{IslandAxisY:F2}y " +
$"falloffStrength={FalloffStrength:F2} sea={SeaLevel:F2} variant={VariantLabel} " +
$"[base={BaseNoise} falloff={IslandFalloff} edge={EdgeNoise} sinker={SouthernSinker} " +
$"trench={Trench} spine={MountainSpine}]";
}
}