worldbox-observer-mod/IdleSpectator/GraveHover.cs
DazedAnon c11b87aa2e Implement gravestone features and enhance Lore interactions.
- Add gravestone management with max stack and lifetime settings
- Introduce new commands for grave interactions in scenarios
- Update Lore handling to include gravestone context and details
- Refactor death cause formatting for improved readability
- Increment version to 0.28.11 in mod.json
2026-07-17 16:32:10 -05:00

108 lines
2.5 KiB
C#

using UnityEngine;
namespace IdleSpectator;
/// <summary>
/// World skull hover highlight + click → Lore (no separate grave window).
/// </summary>
public static class GraveHover
{
private const float HitRadius = 1.35f;
/// <summary>Stack key under mouse - drives skull hover flicker.</summary>
public static long HighlightStackKey { get; private set; }
public static void Update()
{
HighlightStackKey = 0;
if (!ModSettings.Enabled || !ModSettings.GravestonesEnabled)
{
return;
}
if (GraveMarkers.StackCount <= 0)
{
return;
}
bool overUi = false;
try
{
overUi = World.world != null && World.world.isOverUI();
}
catch
{
overUi = false;
}
if (overUi
&& !ChronicleHud.IsPointerOverPanel()
&& !WatchCaption.IsPointerOverPanel())
{
// Pointer on other game UI - no hover highlight / click.
}
else
{
GraveMarkers.GraveStack hover = ResolveHoverStack();
if (hover != null)
{
HighlightStackKey = hover.Key;
}
}
HandleWorldClick();
}
private static void HandleWorldClick()
{
if (!InputHelpers.GetMouseButtonDown(0))
{
return;
}
if (ChronicleHud.IsPointerOverPanel() || WatchCaption.IsPointerOverInteractive())
{
return;
}
try
{
if (World.world != null && World.world.isOverUI())
{
return;
}
}
catch
{
return;
}
GraveMarkers.GraveStack stack = ResolveHoverStack();
if (stack == null || stack.Entries.Count == 0)
{
return;
}
InspectUi.MarkGraveSession();
ChronicleHud.OpenGraveStack(stack.TileX, stack.TileY, pauseIdle: true);
}
private static GraveMarkers.GraveStack ResolveHoverStack()
{
try
{
WorldTile tile = World.world.getMouseTilePosCachedFrame() ?? World.world.getMouseTilePos();
if (tile != null && GraveMarkers.TryGetStack(tile.x, tile.y, out GraveMarkers.GraveStack atTile))
{
return atTile;
}
Vector2 mouse = World.world.getMousePos();
return GraveMarkers.FindNearestStack(mouse, HitRadius);
}
catch
{
return null;
}
}
}