using UnityEngine; namespace IdleSpectator; /// /// Outside-click dismiss for Lore + idle dossier. Always turns Idle Spectator off. /// public static class InspectUi { /// True after a skull open until . public static bool GraveSessionActive { get; private set; } public static void MarkGraveSession() { GraveSessionActive = true; } /// /// Close Lore / dossier pin, clear grave scope, and force Idle Spectator off. /// public static void DismissAll() { GraveSessionActive = false; // Outside dismiss must not auto-resume idle when Lore was opened via L. ChronicleHud.NotifyManualIdleToggle(); if (SpectatorMode.Active) { SpectatorMode.SetActive(false, quiet: true); } ChronicleHud.ClearGraveStackScope(); if (ChronicleHud.DetailUnitId != 0) { ChronicleHud.ClearUnitDetail(); } if (ChronicleHud.Visible) { ChronicleHud.SetVisible(false); } WatchCaption.HideForDismiss(); } public static void Update() { bool loreOpen = ChronicleHud.Visible; bool dossierOpen = WatchCaption.Visible; bool idleOn = SpectatorMode.Active; if (!loreOpen && !dossierOpen && !idleOn && !GraveSessionActive) { return; } if (!InputHelpers.GetMouseButtonDown(0)) { return; } if (Time.unscaledTime < ChronicleHud.IgnoreDismissUntil) { return; } if (ChronicleHud.IsTypingSearch) { return; } if (ChronicleHud.IsPointerOverPanel() || WatchCaption.IsPointerOverPanel()) { return; } // Skull click opens Lore this frame; leave the new session alone. if (IsClickingGraveSkull()) { return; } DismissAll(); } private static bool IsClickingGraveSkull() { if (!ModSettings.GravestonesEnabled || GraveMarkers.StackCount <= 0) { return false; } try { if (World.world != null && World.world.isOverUI()) { return false; } WorldTile tile = World.world.getMouseTilePosCachedFrame() ?? World.world.getMouseTilePos(); if (tile != null && GraveMarkers.TryGetStack(tile.x, tile.y, out _)) { return true; } Vector2 mouse = World.world.getMousePos(); return GraveMarkers.FindNearestStack(mouse, 1.35f) != null; } catch { return false; } } }