import unreal


def load(path):
    asset = unreal.EditorAssetLibrary.load_asset(path)
    if not asset:
        raise RuntimeError(f"Could not load {path}")
    return asset


def main():
    game_mode_bp = load("/Game/Agrarian/Blueprints/Characters/BP_AgrarianGameMode")
    game_mode_cdo = unreal.get_default_object(game_mode_bp.generated_class())
    expected_hud_class = unreal.load_class(None, "/Script/AgrarianGame.AgrarianDebugHUD")
    character_class = unreal.load_class(None, "/Script/AgrarianGame.AgrarianGameCharacter")
    hud_cdo = unreal.get_default_object(expected_hud_class) if expected_hud_class else None
    character_cdo = unreal.get_default_object(character_class) if character_class else None

    missing = []
    if not expected_hud_class:
        missing.append("could not load AgrarianDebugHUD class")
    elif game_mode_cdo.get_editor_property("hud_class") != expected_hud_class:
        missing.append("BP_AgrarianGameMode HUD class is not AgrarianDebugHUD")
    elif hud_cdo:
        if not bool(hud_cdo.get_editor_property("bShowInteractionPrompt")):
            missing.append("AgrarianDebugHUD bShowInteractionPrompt is disabled")
        if float(hud_cdo.get_editor_property("PromptTextScale")) <= 0.0:
            missing.append("AgrarianDebugHUD PromptTextScale is not positive")

    if not character_class:
        missing.append("could not load AgrarianGameCharacter class")
    elif character_cdo:
        character_cdo.get_editor_property("InteractionPromptText")
        character_cdo.get_editor_property("FocusedInteractableActor")

    if missing:
        raise RuntimeError("Interaction prompt verification failed: " + "; ".join(missing))

    unreal.log("Agrarian interaction prompt verification complete.")


main()
