From a3ea48c6e1b82770e29fc8e305fafb31510ec587 Mon Sep 17 00:00:00 2001 From: cake Date: Sun, 28 Dec 2025 03:15:15 +0100 Subject: [PATCH] Fixed some comments --- .../LightFinder/LightFinderPlateHandler.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/LightlessSync/Services/LightFinder/LightFinderPlateHandler.cs b/LightlessSync/Services/LightFinder/LightFinderPlateHandler.cs index e11fd5c..6f0a185 100644 --- a/LightlessSync/Services/LightFinder/LightFinderPlateHandler.cs +++ b/LightlessSync/Services/LightFinder/LightFinderPlateHandler.cs @@ -679,7 +679,7 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe ImGui.PopStyleVar(2); - // --- Debug settings (wired via handler fields; no hotkey / no extra debug window here) --- + // Debug flags bool dbgEnabled = false; bool dbgDisableOcc = false; bool dbgDrawUiRects = false; @@ -737,11 +737,9 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe var scale = baseFontSize > 0 ? (info.FontSize / baseFontSize) : 1f; var size = baseSize * scale; - // label rect for occlusion checking (in game screen coords, NOT viewport-pos-adjusted) var topLeft = info.ScreenPosition - new Vector2(size.X * info.Pivot.X, size.Y * info.Pivot.Y); var labelRect = new RectF(topLeft.X, topLeft.Y, topLeft.X + size.X, topLeft.Y + size.Y); - // "Would this be occluded?" (we track this even if we force-draw) bool wouldOcclude = IsOccludedByAnyUi(labelRect); if (wouldOcclude) occludedThisFrame++; @@ -769,7 +767,7 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe drawList.AddScreenText(drawPos, info.Text, info.TextColor, info.FontSize, info.Pivot, info.EdgeColor, font); } - // Debug: draw UI rects (occluders) + // Debug: draw UI rects if any if (dbgEnabled && dbgDrawUiRects && _uiRects.Count > 0) { var useOff = useViewportOffset ? vpPos : Vector2.Zero; @@ -788,7 +786,6 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe } #if DEBUG - // --- Publish per-frame debug counters for the UI Debug tab --- DebugLabelCountLastFrame = copyCount; DebugUiRectCountLastFrame = _uiRects.Count; DebugOccludedCountLastFrame = occludedThisFrame; @@ -951,13 +948,16 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe if (addon == null) return false; + // Addon must be visible if (!addon->IsVisible) return false; + // Root must be visible var root = addon->RootNode; if (root == null || !root->IsVisible()) return false; + // Must have multiple nodes to be useful var nodeCount = addon->UldManager.NodeListCount; var nodeList = addon->UldManager.NodeList; if (nodeCount <= 1 || nodeList == null) @@ -968,7 +968,6 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe if (!IsFinite(rsx) || rsx <= 0f) rsx = 1f; if (!IsFinite(rsy) || rsy <= 0f) rsy = 1f; - // clamp insane root scales (rare but prevents explosions) // clamp insane root scales (rare but prevents explosions) rsx = MathF.Min(rsx, 6f); rsy = MathF.Min(rsy, 6f); @@ -998,10 +997,11 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe if (rootR <= rootL || rootB <= rootT) return false; + // Root dimensions var rootW = rootR - rootL; var rootH = rootB - rootT; - // --- Union of drawable-ish nodes, but constrained by root rect --- + // Find union of all probably-drawable nodes intersecting root bool any = false; float l = float.MaxValue, t = float.MaxValue, r = float.MinValue, b = float.MinValue; @@ -1082,6 +1082,7 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe return true; } + // Validate final union rect var uw = r - l; var uh = b - t; if (uw < 4f || uh < 4f) @@ -1090,6 +1091,7 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe return true; } + // If union is excessively larger than root, fallback to root rect if (uw > rootW * 1.35f || uh > rootH * 1.35f) { rect = new RectF(rootL, rootT, rootR, rootB); @@ -1105,9 +1107,11 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe if (n == null || !n->IsVisible()) return false; - if (n->Color.A == 0) + // Check alpha + if (n->Color.A == 16) return false; + // Check node type return n->Type switch { NodeType.Text => true,