RynthCore as of 2026-11-08 (internal 9297e93): release 2026.11.8.1

This commit is contained in:
Tom Bohar 2026-11-08 15:48:45 -05:00
commit c68204f160
99 changed files with 5032 additions and 185 deletions

View file

@ -3,7 +3,8 @@
// The Classic look's Gear tab: RynthAi's Items lists (UiSources.Items, the
// Items panel's source) in the retail style. Weapons with their element (a
// drop-down; a weapon no longer carried shows "missing"), consumables with
// their kind, a remove mark on each row; add the item selected in game as a
// their kind, a remove mark on each row, a "No buff" gem on a shield row
// (when RynthAi sends noBuff); add the item selected in game as a
// weapon, a shield or a consumable; drop the missing ones; the shield and
// mana-tap settings that ride the same list. Saved like the Items panel: the
// whole payload (ItemsCommands.SetJson), older snapshots ignored after a save
@ -176,6 +177,18 @@ internal sealed class ClassicGearTab : IClassicTab
}
SafeImGui.SetItemTooltip("The damage this weapon deals (picks it for monsters weak to it)");
}
else if (e.ShowsNoBuff)
{
// A shield has no element: its column is the "No buff" toggle (a RynthAi that sends noBuff).
bool nb = e.NoBuff == true;
if (Gem("##nobuff", "No buff", new Vector2(p.X + listW - xW - ddW - Px(2), p.Y), ddW, nb, 19))
{
e.NoBuff = !nb;
Save();
}
SafeImGui.SetItemTooltip("Never buff this shield - for a shield that already carries its buffs.\n"
+ "RynthAi then aims no armor spells at it, and its spells running low never start a rebuff.");
}
if (RemoveMark("##x", new Vector2(p.X + listW - xW, p.Y), rowH)) remove = i;
SafeImGui.SetItemTooltip("Remove " + e.Name + " from the list");
ImGuiNET.ImGui.PopID();

View file

@ -18,7 +18,11 @@
// automatic.
// Under a monster's row, when the plugin sends them (the row's "mstats",
// UI/Data/DamageRowStats.cs, 2026-10-30): how often it evades and resists you
// and you it since login, the full numbers on hover.
// and you it since login, the full numbers on hover; "XP/kill" first when the
// plugin counts XP ("xp"/"xk", 2026-11-08), then "corpse 2.1 s" when it times
// the death animation ("cd"/"cn"), then "Hits taken: shield 11 avg (front 95%),
// no shield 54 avg" when the plugin has learned its hits by shield and facing
// ("h/d/m" + sf..nu, 2026-11-08; kept across logins, not since login).
// Where the server plugin reports difficulty tiers: a tier chip after Reset stats
// (DamageView.Tier) - which tier the numbers are for, and a picker; "~" marks an
// HP estimated from tier 0's. Hidden elsewhere.

View file

@ -8,6 +8,8 @@
// current loot profile until it's out of keys."
// Select the chest in the world, press Use selected as chest;
// select the key in your pack, press Use selected as key; Start.
// Chest re-lock wait (s): how long after the open the next key
// goes on (RynthAi's setting, "/ra itemtool relock N").
// Quick give Select an item in your pack (Use selected as item) and a player
// or NPC in the world (Use selected as target), press Give: every
// such item in your packs is handed over, one give at a time.
@ -76,6 +78,8 @@ internal sealed class ItemToolFace : IImGuiPanel
if (hit == 0) ItemToolCommands.Send("chest set");
else if (hit == 1) ItemToolCommands.Send("chest key");
DrawRelockWait(c, w);
hit = StartStop("##chest_run", "Start", "Stop", ready && !c.Running, c.Running, w);
if (hit == 0) ItemToolCommands.Send("chest start");
else if (hit == 1) ItemToolCommands.Send("chest stop");
@ -83,6 +87,44 @@ internal sealed class ItemToolFace : IImGuiPanel
Wrapped(c.Status, c.Running ? Amber : Text, w);
}
// The slider's value while it is dragged, and after the release until RynthAi reports it back
// (the snapshot is 250 ms behind; without this the slider jumps back for a moment).
private static int _relockEdit;
private static bool _relockPending;
private static long _relockSentAt;
private const long RelockPendingMs = 2000;
/// <summary>
/// "Chest re-lock wait (s)" (2026-11-05): how long after the chest was opened the next key goes on
/// it. Sent on release as "relock N" (RynthAi clamps, saves it in the profile and answers in chat).
/// Hidden for a RynthAi that predates it (no relockSec); greyed until the profile has loaded.
/// </summary>
private static void DrawRelockWait(ChestToolState c, float w)
{
if (c.RelockSec <= 0) return;
int min = Math.Max(1, c.RelockMin), max = Math.Max(min, c.RelockMax);
long now = Environment.TickCount64;
if (_relockPending && (c.RelockSec == _relockEdit || now - _relockSentAt >= RelockPendingMs)) _relockPending = false;
Label("Chest re-lock wait (s)", Mute);
int v = _relockPending ? _relockEdit : c.RelockSec;
ImGuiNET.ImGui.BeginDisabled(!c.RelockReady);
ImGuiNET.ImGui.SetNextItemWidth(Math.Max(80, w - 4));
ImGuiNET.ImGui.SliderInt("##chest_relock", ref v, min, max, "%d s", ImGuiSliderFlags.AlwaysClamp);
if (ImGuiNET.ImGui.IsItemActive()) { _relockEdit = v; _relockPending = true; _relockSentAt = now; }
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
{
_relockEdit = v;
_relockPending = true;
_relockSentAt = now;
ItemToolCommands.Send("relock " + v.ToString(System.Globalization.CultureInfo.InvariantCulture));
}
SafeImGui.SetItemTooltip(c.RelockReady
? "How long after the chest was opened the next key goes on it (sooner when it reads locked again).\n125 s fits the usual 2-minute chest reset; a chest that resets sooner can use less.\nToo short costs nothing: the key is only tried again, never spent. Ctrl+click to type a value."
: "Waiting for this character's settings profile to load.");
ImGuiNET.ImGui.EndDisabled();
}
// ── Quick give ──────────────────────────────────────────────────────
private static void DrawGive(GiveToolState g, float w)

View file

@ -5,6 +5,9 @@
// and mana stone tapping (on/off, keep count, min max-mana to tap). A listed
// weapon the character no longer carries (RynthAi's missingIds) shows in amber
// with a warning icon and "(missing)", and says what to do in its tooltip.
// A shield row (Action "Shield") from a RynthAi that sends noBuff shows a
// "No buff" toggle in place of its element column: on = RynthAi never buffs
// that shield. Weapon rows are unchanged.
//
// Edits change a private copy and save the whole payload (ItemsCommands,
// pump thread). A newer snapshot replaces the copy; snapshots from before
@ -91,8 +94,15 @@ internal sealed class ItemsFace : IImGuiPanel
int i = idx[k];
ItemsPanel.WeaponEntry wpn = _data.Weapons[i];
ImGuiNET.ImGui.PushID("w" + i);
int r = Row(wpn.Name, wpn.Element, shown++, bw, _data.MissingIds.Contains(wpn.Id), k > 0, k < idx.Count - 1);
int r = Row(wpn.Name, wpn.Element, shown++, bw, _data.MissingIds.Contains(wpn.Id), k > 0, k < idx.Count - 1,
wpn.ShowsNoBuff ? wpn.NoBuff : null);
ImGuiNET.ImGui.PopID();
if (r == 5)
{
wpn.NoBuff = !(wpn.NoBuff ?? false);
Save();
continue;
}
// Up / down inside its group: the order is RynthAi's preference (the buff wand, the
// first weapon of a kind), and it couldn't be changed but by removing and re-adding.
if (r == 3 || r == 4)
@ -273,13 +283,19 @@ internal sealed class ItemsFace : IImGuiPanel
// The up / down buttons' width in a row (two 20 px buttons and their gaps).
private const float MoveW = 46;
private const string NoBuffTip = "Never buff this shield - for a shield that already carries its buffs.\n"
+ "RynthAi then aims no armor spells at it, and its spells running low never start a rebuff.";
/// <summary>
/// Name | up | down | [value picker] | Del. Returns 1 when the picker was clicked, 2 for Del,
/// 3 for up, 4 for down, else 0. Up / down are drawn dim and do nothing at the ends.
/// <paramref name="missing"/>: the item isn't carried any more (amber, a warning icon,
/// "(missing)" and a tooltip saying what to do).
/// 3 for up, 4 for down, 5 for the "No buff" toggle, else 0. Up / down are drawn dim and do
/// nothing at the ends. <paramref name="missing"/>: the item isn't carried any more (amber, a
/// warning icon, "(missing)" and a tooltip saying what to do). <paramref name="noBuff"/>
/// non-null (a shield row, RynthAi sending noBuff): the value column is the "No buff" toggle
/// instead of the picker (a shield has no element; its column only said "Shield").
/// </summary>
private static int Row(string name, string value, int index, float w, bool missing, bool canUp = false, bool canDown = false)
private static int Row(string name, string value, int index, float w, bool missing, bool canUp = false, bool canDown = false,
bool? noBuff = null)
{
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
var dl = ImGuiNET.ImGui.GetWindowDrawList();
@ -311,7 +327,14 @@ internal sealed class ItemsFace : IImGuiPanel
if (IconButton("##down", PhosphorIcons.CaretDown, new Vector2(bx + 22, p.Y + 2), new Vector2(20, 20), canDown ? Teal : Mute, BtnFill) && canDown) result = 4;
ImGuiNET.ImGui.SetItemTooltip("Move down");
bx += MoveW;
if (Button("##pick", value, new Vector2(bx, p.Y + 2), new Vector2(96, 20), Text, BtnFill)) result = 1;
if (noBuff is bool nb)
{
// The tapping toggle's look: lit while the shield is left out of buffing.
if (Button("##nobuff", (nb ? PhosphorIcons.CheckSquare : PhosphorIcons.Square) + " No buff", new Vector2(bx, p.Y + 2), new Vector2(96, 20),
nb ? OnText : Mute, nb ? OnBg : BtnFill)) result = 5;
ImGuiNET.ImGui.SetItemTooltip(NoBuffTip);
}
else if (Button("##pick", value, new Vector2(bx, p.Y + 2), new Vector2(96, 20), Text, BtnFill)) result = 1;
if (IconButton("##del", PhosphorIcons.Trash, new Vector2(bx + 100, p.Y + 2), new Vector2(42, 20), Red, BtnFill)) result = 2;
ImGuiNET.ImGui.SetItemTooltip("Remove");
NextLine(p, 24);

View file

@ -119,7 +119,7 @@ internal sealed class PluginWindowFace : IImGuiPanel
}
if (result == PluginManager.EmbedDrawn)
{
if (_fitHeight) Fit(want.Y, avail.X);
if (_fitHeight) Fit(want.Y, avail.X, want.X);
return;
}
@ -137,12 +137,23 @@ internal sealed class PluginWindowFace : IImGuiPanel
/// client px) and scales its width with a text size change. Docked only (popped out, the OS window
/// is the player's to size); never while the mouse is down, so a drag or a resize isn't fought.
/// </summary>
private void Fit(float wantPx, float widthPx)
private void Fit(float wantPx, float widthPx, float wantWidthPx = 0f)
{
if (wantPx <= 0f || ImGuiPopOuts.InPopOutFrame) return;
float place = Math.Max(0.01f, ImGuiPanelHost.PlacementScale());
float height = MathF.Ceiling(wantPx / place);
float width = widthPx / place;
// A plugin that sizes its own width too (2026-11-07: RynthDreamWeave's retail Character panel, a
// fixed design width at its text size) reports a width other than the one it was given: the window
// takes it, as it takes the height. Every other plugin hands back the width it got: no change.
if (wantWidthPx > 0f && MathF.Abs(wantWidthPx - widthPx) > 1f && ImGuiNET.ImGui.IsMouseDown(ImGuiNET.ImGuiMouseButton.Left) == false)
{
_contentHeight = height;
_fitWidth = MathF.Ceiling(wantWidthPx / place);
_fitK = PanelTextScale.Factor(ImGuiFonts.CurrentStep);
ImGuiPanelHost.RequestSize(_title, new Vector2(_fitWidth, height));
return;
}
float k = PanelTextScale.Factor(ImGuiFonts.CurrentStep);
float shownHeight = ImGuiNET.ImGui.GetWindowHeight() / place;
bool mouseUp = !ImGuiNET.ImGui.IsMouseDown(ImGuiNET.ImGuiMouseButton.Left);

View file

@ -0,0 +1,37 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/RadarDrag.cs
// Whether a press on the radar may move it (2026-11-04). Docked click-through
// ("Docked click-through (dots still work; Ctrl for the rest)") gives the game
// every click, except on a dot or the buttons: there the radar's window takes
// input for that press (RadarFace._hot / _pressHot) so the dot can be hovered and
// clicked to select. The surface under the dot is the same InvisibleButton that
// drags the panel (ImGuiPanelHost.DragWindowWithLastItem), so holding on a dot
// and moving the mouse moved the radar, Ctrl or not (Discord, 2026-11-02). Now a
// press moves the radar only when click-through is off, Ctrl was held when the
// press began, or the radar is popped out (always interactive there). It is
// decided when the press begins and holds until the button is up, so Ctrl let go
// or pressed mid-drag neither stops a move nor starts one.
//
// Pure (no ImGui), so tools\RadarSettingsTests links it.
// ============================================================================
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal sealed class RadarDrag
{
private bool _moves = true;
/// <summary>A press with these settings may move the radar.</summary>
public static bool PressMoves(bool clickThroughOn, bool ctrlHeld, bool poppedOut) =>
!clickThroughOn || ctrlHeld || poppedOut;
/// <summary>
/// Call once a frame right after the surface item: <paramref name="pressBegan"/> is the surface's
/// IsItemActivated. Answers whether this press may move the radar (as decided when it began).
/// </summary>
public bool Update(bool pressBegan, bool clickThroughOn, bool ctrlHeld, bool poppedOut)
{
if (pressBegan) _moves = PressMoves(clickThroughOn, ctrlHeld, poppedOut);
return _moves;
}
}

View file

@ -17,6 +17,8 @@
// The object selected in game is highlighted (RadarSettingsStore.HighlightSelected, RadarSelection):
// a ring in its own colour round its marker and the hover label beside it, or an arrow on the
// edge when it is off the picture.
// Range rings round you at RynthAi's Monster Range and Ring Range (RadarRangeRing; each has a box in
// the settings), read from RynthAi's settings while one is on.
//
// Data: UiSources.Radar (RadarView, lookups precomputed). World geometry is
// drawn without anti-aliasing (crisp tiling like the Avalonia face's aliased
@ -71,6 +73,7 @@ internal sealed class RadarFace : IImGuiPanel
private bool _settingsSub; // subscribed to RynthAi's settings (the retail radar switch) while the window is open
private bool? _hidePending; // the retail-radar switch as just set, until RynthAi's answer shows it
private long _hidePendingAt;
private bool _rangeSub; // subscribed to RynthAi's settings while a range ring is on
// The round radar (RadarSettingsStore.RoundRadar): this frame's circle, read by the drawing helpers.
private static bool _round;
@ -86,6 +89,8 @@ internal sealed class RadarFace : IImGuiPanel
// dot can always be hovered and clicked. A press that began on a dot keeps the panel interactive
// until the button is released.
private bool _hot, _pressHot, _downPrev;
// Whether the current press on the surface may move the panel (off for a dot press under click-through).
private readonly RadarDrag _drag = new();
public bool ClickThrough =>
RadarSettingsStore.CtrlGatedClickThrough && !ImGuiNET.ImGui.GetIO().KeyCtrl && !_hot;
@ -106,10 +111,19 @@ internal sealed class RadarFace : IImGuiPanel
{
UiSources.Radar.Unsubscribe();
if (_settingsSub) { UiSources.Settings.Unsubscribe(); _settingsSub = false; }
if (_rangeSub) { UiSources.Settings.Unsubscribe(); _rangeSub = false; }
}
public void Draw()
{
// The range rings need RynthAi's settings (Monster Range, Ring Range): polled only while one is on.
bool wantRange = RadarSettingsStore.ShowMonsterRangeRing || RadarSettingsStore.ShowRingRangeRing;
if (wantRange != _rangeSub)
{
if (wantRange) { UiSources.Settings.Subscribe(); UiSources.Settings.RequestRefresh(); }
else UiSources.Settings.Unsubscribe();
_rangeSub = wantRange;
}
bool clickThroughNow = ClickThrough; // what the host gave this frame's window (before UpdateHot moves _hot)
_wheelHere = false;
var dl = ImGuiNET.ImGui.GetWindowDrawList();
@ -216,7 +230,11 @@ internal sealed class RadarFace : IImGuiPanel
// ── Surface: drag moves the panel, a click on a dot selects, wheel zooms, right-click menu ──
ImGuiNET.ImGui.SetCursorScreenPos(origin);
bool surfaceClicked = ImGuiNET.ImGui.InvisibleButton("##radar_surface", size);
ImGuiPanelHost.DragWindowWithLastItem();
// 2026-11-04: with docked click-through, a press on a dot only selects it; it never moves the
// radar unless Ctrl was held when it began (RadarDrag; holding on a dot used to drag the panel).
if (_drag.Update(ImGuiNET.ImGui.IsItemActivated(), RadarSettingsStore.CtrlGatedClickThrough,
ImGuiNET.ImGui.GetIO().KeyCtrl, ImGuiPopOuts.InPopOutFrame))
ImGuiPanelHost.DragWindowWithLastItem();
UpdateHot(view, centre, worldMin, worldMax, gearPos, new Vector2(closePos.X + btn, closePos.Y + btn));
if (view != null && RadarSettingsStore.ClickToSelect)
MarkerInput(dl, view, centre, worldMin, worldMax, surfaceClicked);
@ -310,6 +328,8 @@ internal sealed class RadarFace : IImGuiPanel
if (cur + 1 < count && cur >= 0) DrawLayer(dl, view, cur + 1, 0.30f, false, proj, rotate, clipMin, clipMax);
if (cur >= 0) DrawLayer(dl, view, cur, 1.00f, true, proj, rotate, clipMin, clipMax);
DrawRangeRings(dl, centre, clipMin, clipMax, MathF.Max(0.5f, RadarSettingsStore.Zoom));
// Markers (shapes: RadarMarkerStyle). Corpses and items first, creatures on top.
RadarMarkerStyle.FillColors(KindCols);
MarkerStyleSettings markers = RadarSettingsStore.Markers;
@ -350,6 +370,33 @@ internal sealed class RadarFace : IImGuiPanel
dl.AddLine(centre, tip, PlayerCol, 2);
}
// ── Range rings ────────────────────────────────────────────────────────
// Thin circles round you at RynthAi's Monster Range (warm white) and Ring Range (pale blue), over
// the floors and under the markers, each on a faint dark line so it reads on the dark canvas and
// on the world map alike. Nothing until RynthAi has sent its settings (UiSources.Settings).
private static readonly uint MonsterRangeCol = C(0xB3FFE6B3), RingRangeCol = C(0xA680CCFF), RangeUnder = C(0x59000000);
private static void DrawRangeRings(ImDrawListPtr dl, Vector2 centre, Vector2 clipMin, Vector2 clipMax, float zoom)
{
bool monster = RadarSettingsStore.ShowMonsterRangeRing, ring = RadarSettingsStore.ShowRingRangeRing;
if (!monster && !ring) return;
RynthAiSettings? ra = UiSources.Settings.Current?.Value;
if (ra == null) return;
ImDrawListFlags saved = dl.Flags;
dl.Flags = saved | ImDrawListFlags.AntiAliasedLines; // the world is drawn aliased; a circle looks ragged that way
RoundMask? round = _round ? _mask : null;
if (monster) RangeRing(dl, centre, clipMin, clipMax, round, RadarRangeRing.RadiusPx(ra.MonsterRange, zoom), MonsterRangeCol);
if (ring) RangeRing(dl, centre, clipMin, clipMax, round, RadarRangeRing.RadiusPx(ra.RingRange, zoom), RingRangeCol);
dl.Flags = saved;
}
private static void RangeRing(ImDrawListPtr dl, Vector2 centre, Vector2 clipMin, Vector2 clipMax, RoundMask? round, float r, uint col)
{
if (!RadarRangeRing.Shows(r, centre, clipMin, clipMax, round)) return;
dl.AddCircle(centre, r, RangeUnder, 0, 3f); // 0 segments: ImGui picks enough for the radius
dl.AddCircle(centre, r, col, 0, 1.25f);
}
// ── The selected object ────────────────────────────────────────────────
// A ring in the selection colour round its marker (the marker drawn over everything, even when its
// kind's box is off), and the hover label beside it; off the picture, an arrow on the edge pointing
@ -521,7 +568,8 @@ internal sealed class RadarFace : IImGuiPanel
// ── Click-to-select ─────────────────────────────────────────────────────
// Left-click a dot: that object is selected in game, as a click on it in the
// 3D world would. A press that moves more than a few pixels is a drag (the
// panel moves) and selects nothing. Hover shows the object's name and
// panel moves; with docked click-through and no Ctrl it stays put, RadarDrag)
// and selects nothing. Hover shows the object's name and
// distance (and its last known health, when the engine has seen one).
// RynthAi 2026-10-01 and later send each marker's object id, and the click
// selects exactly that id. Older RynthAi builds send no id (Id = 0): then
@ -864,6 +912,7 @@ internal sealed class RadarFace : IImGuiPanel
if (!WorldMapTiles.IsOpen && WorldMapTiles.Status.Length > 0)
SafeImGui.TextDisabled(WorldMapTiles.Status);
}
changed |= RangeRingRows();
RetailRadarRow();
ImGuiNET.ImGui.Separator();
changed |= KindRows();
@ -879,6 +928,29 @@ internal sealed class RadarFace : IImGuiPanel
private static bool Check(string label, ref bool value) => ImGuiNET.ImGui.Checkbox(label, ref value);
/// <summary>
/// The range rings' boxes. Each label shows the range RynthAi has now (its Settings > Ranges set it);
/// the boxes are the radar's own and save with the radar's settings. True when one changed.
/// </summary>
private static bool RangeRingRows()
{
RynthAiSettings? ra = UiSources.Settings.Current?.Value;
var inv = System.Globalization.CultureInfo.InvariantCulture;
string Yards(int v) => ra == null ? "" : " (" + v.ToString(inv) + " yd)";
bool changed = Check("Monster Range ring" + Yards(ra?.MonsterRange ?? 0) + "###mrring", ref RadarSettingsStore.ShowMonsterRangeRing);
if (ImGuiNET.ImGui.IsItemHovered())
ImGuiNET.ImGui.SetTooltip("A ring round you at RynthAi's Monster Range: monsters inside it are ones the bot will attack.\nIt follows the setting (Settings > Ranges). Measured along the ground; RynthAi counts height too,\nso a monster a floor up or down can be inside the ring and still out of range.");
changed |= Check("Ring Range ring" + Yards(ra?.RingRange ?? 0) + "###rrring", ref RadarSettingsStore.ShowRingRangeRing);
if (ImGuiNET.ImGui.IsItemHovered())
ImGuiNET.ImGui.SetTooltip("A second, blue ring at RynthAi's Ring Range: how close monsters must be for its ring spells.");
if (ra == null && (RadarSettingsStore.ShowMonsterRangeRing || RadarSettingsStore.ShowRingRangeRing))
{
ImGuiNET.ImGui.SameLine();
ImGuiNET.ImGui.TextDisabled("(waiting for RynthAi)");
}
return changed;
}
/// <summary>
/// "Hide the retail radar": RynthAi's own SuppressRetailRadar setting (RynthAi pushes it to the engine every
/// tick), the same switch as Settings > UI > Hide retail radar. This reads it from RynthAi's settings payload

View file

@ -0,0 +1,47 @@
// ============================================================================
// RynthCore.Engine - ImGui/Panels/RadarRangeRing.cs
// The range rings round the player on the Radar (2026-11-06, player request): RynthAi's
// Monster Range (how far away a monster can be for the bot to attack it) and, optionally,
// its Ring Range (ring spells), drawn as circles at that many yards. The radar's world is
// in yards (192 per landblock, the same units RynthAi measures in) and its zoom is pixels
// per yard, so the ring's radius on the screen is range x zoom.
//
// Pure (no ImGui), so tools\RadarSettingsTests links it.
// ============================================================================
using System;
using System.Numerics;
namespace RynthCore.Engine.ImGuiBackend.Panels;
internal static class RadarRangeRing
{
/// <summary>Rings smaller than this (px) aren't drawn: they would only blot out your own arrow.</summary>
public const float MinRadiusPx = 4f;
/// <summary>
/// The ring's radius in pixels for a range of <paramref name="yards"/> at the radar's
/// <paramref name="zoom"/> (px per yard, at least 0.5 as the radar's projection keeps it).
/// 0 for no range (0, negative or not a number).
/// </summary>
public static float RadiusPx(double yards, float zoom)
{
if (!(yards > 0) || !double.IsFinite(yards)) return 0f;
float z = float.IsFinite(zoom) ? MathF.Max(0.5f, zoom) : 0.5f;
return (float)yards * z;
}
/// <summary>
/// Whether any of a ring of <paramref name="radius"/> round <paramref name="centre"/> (the player)
/// shows on the picture: not too small, and inside the circle for the round radar (the two share
/// a centre), or reaching no further than the farthest corner of the square one.
/// </summary>
public static bool Shows(float radius, Vector2 centre, Vector2 min, Vector2 max, RoundMask? round)
{
if (!(radius >= MinRadiusPx)) return false;
if (round is { } circle) return radius <= circle.Radius;
float fx = MathF.Max(centre.X - min.X, max.X - centre.X);
float fy = MathF.Max(centre.Y - min.Y, max.Y - centre.Y);
return radius * radius <= fx * fx + fy * fy;
}
}