from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
SKY_H = ROOT / "Source" / "AgrarianGame" / "AgrarianSkyLightingController.h"
SKY_CPP = ROOT / "Source" / "AgrarianGame" / "AgrarianSkyLightingController.cpp"
MAP_SETUP = ROOT / "Scripts" / "setup_ground_zero_demo_map.py"
TDD = ROOT / "Docs" / "TechnicalDesignDocument.md"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"


EXPECTED = {
    SKY_H: [
        "class AAgrarianSkyLightingController : public AActor",
        "TObjectPtr<UDirectionalLightComponent> SunLight;",
        "TObjectPtr<USkyLightComponent> SkyLight;",
        "TObjectPtr<UExponentialHeightFogComponent> HeightFog;",
        "void RefreshSkyLighting();",
        "float CalculateSunAlpha",
        "float CalculateWeatherCloudAlpha",
    ],
    SKY_CPP: [
        "#include \"AgrarianGameState.h\"",
        "SunLight = CreateDefaultSubobject<UDirectionalLightComponent>",
        "SkyLight = CreateDefaultSubobject<USkyLightComponent>",
        "HeightFog = CreateDefaultSubobject<UExponentialHeightFogComponent>",
        "GameState->SunriseHourLocal",
        "GameState->SunsetHourLocal",
        "GameState->ActiveWeatherInputs.CloudCoverPercent",
        "SunLight->SetWorldRotation",
        "SunLight->SetIntensity",
        "SkyLight->SetIntensity",
        "HeightFog->SetFogDensity",
    ],
    MAP_SETUP: [
        "AGR_DemoSkyLightingController",
        "unreal.AgrarianSkyLightingController",
        "LEGACY_DEMO_LIGHTING_LABELS",
        "\"AGR_DemoSun\"",
        "\"AGR_DemoSkyLight\"",
        "\"AGR_DemoFog\"",
    ],
    TDD: [
        "`AAgrarianSkyLightingController`",
        "movable sun, skylight, and exponential-height-fog components",
    ],
    ROADMAP: [
        "[x] Add first-pass sky and lighting.",
    ],
}


def main() -> None:
    missing = []
    for path, snippets in EXPECTED.items():
        text = path.read_text(encoding="utf-8")
        for snippet in snippets:
            if snippet not in text:
                missing.append(f"{path.relative_to(ROOT)}: {snippet}")
    if missing:
        raise RuntimeError("Sky lighting controller verification failed: " + "; ".join(missing))
    print("Agrarian sky lighting controller verification complete.")


if __name__ == "__main__":
    main()
