#!/usr/bin/env python3
"""Verify replicated world actors no longer use deprecated net cull assignment."""

from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"

EXPECTED_SETTERS = {
    "Source/AgrarianGame/AgrarianItemPickup.cpp": "SetNetCullDistanceSquared(FMath::Square(3000.0f));",
    "Source/AgrarianGame/AgrarianResourceNode.cpp": "SetNetCullDistanceSquared(FMath::Square(4500.0f));",
    "Source/AgrarianGame/AgrarianCampfire.cpp": "SetNetCullDistanceSquared(FMath::Square(6000.0f));",
    "Source/AgrarianGame/AgrarianShelterActor.cpp": "SetNetCullDistanceSquared(FMath::Square(6000.0f));",
    "Source/AgrarianGame/AgrarianWildlifeBase.cpp": "SetNetCullDistanceSquared(FMath::Square(6000.0f));",
    "Source/AgrarianGame/AgrarianWaterSource.cpp": "SetNetCullDistanceSquared(FMath::Square(6500.0f));",
    "Source/AgrarianGame/AgrarianWeatherExposureZone.cpp": "SetNetCullDistanceSquared(FMath::Square(6500.0f));",
    "Source/AgrarianGame/AgrarianWildlifeSpawnManager.cpp": "SetNetCullDistanceSquared(FMath::Square(8000.0f));",
}


def main() -> None:
    missing: list[str] = []
    for relative_path, setter in EXPECTED_SETTERS.items():
        path = ROOT / relative_path
        text = path.read_text(encoding="utf-8")
        if "NetCullDistanceSquared =" in text:
            missing.append(f"{relative_path} still uses direct NetCullDistanceSquared assignment")
        if setter not in text:
            missing.append(f"{relative_path} missing {setter!r}")

    roadmap_text = ROADMAP.read_text(encoding="utf-8")
    if "[x] Clean up Unreal API deprecation warnings from packaged builds" not in roadmap_text:
        missing.append("roadmap item is not marked complete")
    if "SetNetCullDistanceSquared" not in roadmap_text:
        missing.append("roadmap summary does not mention SetNetCullDistanceSquared")

    if missing:
        raise SystemExit("FAILED: " + "; ".join(missing))
    print("OK: net cull deprecation cleanup uses SetNetCullDistanceSquared across replicated world actors.")


if __name__ == "__main__":
    main()
