RynthSuite as of 2026-11-26 (internal 1db112e): release 2026.11.26.1

This commit is contained in:
Tom Bohar 2026-11-26 22:32:31 -05:00
commit 25552fa794
175 changed files with 23428 additions and 494 deletions

View file

@ -187,6 +187,15 @@ internal static class PathMarkers
return idx;
}
/// <summary>
/// A plan (Route, not walked) is done once you stand at its goal: within <paramref name="arriveUnits"/>
/// of it (the arrow's arrival distance), on the map. A walked trip (Live) reports its own arrival; a
/// plan that ends in a dungeon's entrance goes when you walk through it (the landblock check).
/// </summary>
public static bool PlanReached(PlannedTrip trip, bool hasPos, double ns, double ew, double arriveUnits)
=> !trip.Live && hasPos && !trip.EndsInEntrance
&& NavCoords.Distance(ns, ew, trip.GoalNs, trip.GoalEw) <= arriveUnits;
/// <summary>The marker nearest the character (a plan only: where the guide line points), or -1.</summary>
public static int Nearest(MarkerSnapshot s, double px, double py)
{

View file

@ -43,6 +43,12 @@ internal sealed class RecallSpot
public string Label = "";
/// <summary>The chat command that does this recall, when it's a command (@lifestone, @house recall).</summary>
public string Command = "";
/// <summary>
/// Portal Recall only: learned from walking through a portal RynthNav's portal list doesn't know, so
/// it can't tell whether the server keeps it as your last portal (a no-recall portal isn't kept).
/// Routes don't use it until a cast of Portal Recall confirms where it lands.
/// </summary>
public bool Unconfirmed;
}
/// <summary>What a chat line tells RynthNav about recalls.</summary>
@ -149,7 +155,7 @@ internal sealed class RecallMemory
// ── recalls.txt ──────────────────────────────────────────────────────────
// # comment
// <character>\t<slot>\t<ns or ->\t<ew or ->\t<label>\t<command>
// <character>\t<slot>\t<ns or ->\t<ew or ->\t<label>\t<command>[\t? when unconfirmed]
public string Serialize()
{
@ -169,7 +175,8 @@ internal sealed class RecallMemory
sb.Append(Clean(c)).Append('\t').Append(SlotName(slot)).Append('\t')
.Append(s.OnMap ? s.Ns.ToString("F2", ci) : "-").Append('\t')
.Append(s.OnMap ? s.Ew.ToString("F2", ci) : "-").Append('\t')
.Append(Clean(s.Label)).Append('\t').Append(Clean(s.Command)).Append("\r\n");
.Append(Clean(s.Label)).Append('\t').Append(Clean(s.Command))
.Append(s.Unconfirmed ? "\t?" : "").Append("\r\n");
}
}
return sb.ToString();
@ -189,6 +196,7 @@ internal sealed class RecallMemory
{
Label = f.Length > 4 ? f[4] : "",
Command = f.Length > 5 ? f[5] : "",
Unconfirmed = f.Length > 6 && f[6] == "?",
};
s.OnMap = double.TryParse(f[2], NumberStyles.Float, CultureInfo.InvariantCulture, out s.Ns)
& double.TryParse(f[3], NumberStyles.Float, CultureInfo.InvariantCulture, out s.Ew);

View file

@ -99,12 +99,35 @@ internal static class RecallPlanner
RecallSpot? spot = memory.Get(charKey, slot);
if (spot == null) { notes?.Add(name + ": where it lands isn't known yet (" + howToLearn + ")."); return; }
if (!spot.OnMap) { notes?.Add(name + " lands " + Where(spot) + ": not used for routes."); return; }
if (spot.Unconfirmed)
{
notes?.Add(name + ": the last portal you used (" + (spot.Label.Length > 0 ? spot.Label : "unknown") + ") isn't in RynthNav's portal list, "
+ "so whether the server lets Portal Recall go back there isn't known: not used for routes until you cast " + name + " once.");
return;
}
list.Add(new RecallOption
{
Name = name, SpellId = spellId, Ns = spot.Ns, Ew = spot.Ew, CastSeconds = SpellCastSeconds, Learned = true,
});
}
/// <summary>What a portal walk does to Portal Recall's landing (RynthNavPlugin.Travel).</summary>
internal enum LastPortalUpdate { Set, SetUnconfirmed, Keep }
/// <summary>ACE's PortalBitmask.NoRecall: the server doesn't keep such a portal as your last portal.</summary>
internal const int PortalNoRecall = 0x20;
/// <summary>
/// A teleport through a portal with this PortalBitmask (null: not in the portal list). ACE keeps
/// a portal as your last portal only if it isn't NoRecall (Portal.ActOnUse), so Portal Recall then
/// still goes to the one before (R-20261126-024033-5d60, Conquest: from the Dark Isle, which can't
/// be recalled to, a goto cast Portal Recall and landed in a dungeon visited earlier).
/// </summary>
internal static LastPortalUpdate ForPortal(int? bitmask) =>
bitmask is not int b ? LastPortalUpdate.SetUnconfirmed
: (b & PortalNoRecall) != 0 ? LastPortalUpdate.Keep
: LastPortalUpdate.Set;
private static void AddLearnedCommand(List<RecallOption> list, List<string>? notes, RecallMemory memory, string charKey,
RecallSlot slot, string name, bool alwaysAvailable, string howToLearn)
{

View file

@ -13,9 +13,11 @@ namespace RynthCore.Plugin.RynthNav;
// those and a guide line from your feet to the next waypoint. The same path is what "save as nav
// route" writes (RynthNavPlugin.SaveRoute.cs).
//
// The markers go away when the trip ends (arrived, stopped), is cancelled (Stop, the d-pad), or you
// land in a landblock that isn't on it (a teleport elsewhere). Switches in rynthnav.json
// (markers, markerLabels, markerGuide); /rnav markers and the panel's Go tab change them.
// The markers go away when the trip ends (arrived, stopped), is cancelled (Stop, the d-pad), is
// cleared (the Go tab's Clear, /rnav markers clear), you land in a landblock that isn't on it (a
// teleport elsewhere), or, for a plan you aren't walking (Route, an Oracle or map pick), you walk to
// its goal yourself (2026-11-26: a plan's markers stayed on the ground until Stop). Switches in
// rynthnav.json (markers, markerLabels, markerGuide); /rnav markers and the panel's Go tab change them.
//
// Threads: everything here runs on the tick, except the path worker, which reads only the frozen
// trip (PlannedTrip), the immutable route graph and Atlas portal list, and the tile files. The
@ -205,6 +207,12 @@ public sealed partial class RynthNavPlugin
HideMarkers($"landblock 0x{lb:X4} isn't on the trip");
}
}
// A plan (Route, an Oracle or map pick) you walked to yourself: its markers go once you're there.
if (_tripShown && !trip.Live && !_gotoActive)
{
bool hasPos = PlayerMapPos(out double ns, out double ew);
if (PathMarkers.PlanReached(trip, hasPos, ns, ew, _arrow.ArriveUnits)) HideMarkers("arrived");
}
if (!_markersOn || !_tripShown || !Host.HasNav3D || !_hasPose) return;
if (!ReferenceEquals(trip, _snapTrip) || !ReferenceEquals(_tripPath, _snapPath))
@ -232,10 +240,19 @@ public sealed partial class RynthNavPlugin
// ── /rnav markers ────────────────────────────────────────────────────
/// <summary>/rnav markers [on|off | labels on|off | guide on|off]</summary>
/// <summary>/rnav markers [on|off | clear | labels on|off | guide on|off]</summary>
private void CmdMarkers(string rest)
{
string[] a = rest.ToLowerInvariant().Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (a.Length == 1 && a[0] is "clear" or "hide")
{
// This trip's markers off the ground, the switch left as it is (the panel's Clear button).
if (_trip == null || !_tripShown) { Say("path markers: no trip on the ground"); return; }
string goal = _trip.Goal;
HideMarkers("cleared");
Say($"path markers: the trip to {goal} is off the ground (the next Route or Go shows its own)");
return;
}
if (a.Length == 1 && a[0] is "on" or "off")
{
_markersOn = a[0] == "on";
@ -246,7 +263,7 @@ public sealed partial class RynthNavPlugin
{ _markerLabels = a[1] == "on"; NavDataConfig.WriteSwitch("markerLabels", _markerLabels); }
else if (a.Length == 2 && a[0] == "guide" && a[1] is "on" or "off")
{ _markerGuide = a[1] == "on"; NavDataConfig.WriteSwitch("markerGuide", _markerGuide); }
else if (a.Length > 0) { Say("/rnav markers on|off, markers labels on|off, markers guide on|off"); return; }
else if (a.Length > 0) { SayFail("/rnav markers on|off, markers clear, markers labels on|off, markers guide on|off"); return; }
Say($"path markers {(_markersOn ? "ON" : "OFF")}, labels {(_markerLabels ? "on" : "off")}, guide line {(_markerGuide ? "on" : "off")}"
+ (_trip == null ? "" : _tripShown ? $" — showing the trip to {_trip.Goal}" : $" — the trip to {_trip.Goal} isn't shown ({_markerStatus})"));
}

View file

@ -431,7 +431,7 @@ public sealed partial class RynthNavPlugin
{
// As /rnav route: the panel shows the plan and the markers its path (worked out below, once).
_shownRoute = plan.Steps ?? new List<RouteStep> { new(ns, ew, false, false, "walk") };
_shownRouteFor = name; _shownRouteEst = plan.Est; _shownRouteLive = false; _routeVersion++;
_shownRouteFor = name; SetShownRouteGoal(ns, ew); _shownRouteEst = plan.Est; _shownRouteLive = false; _routeVersion++;
trip = SetTrip(plan.Steps, name, ns, ew, recalls, "", live: false, buildPath: false);
}
else trip = NewTrip(plan.Steps, name, ns, ew, recalls, "", live: false);

View file

@ -0,0 +1,77 @@
using System;
using RynthNav.Routing;
namespace RynthCore.Plugin.RynthNav;
// One target at a time, the newest wins (11-24, a player: "It puts it into the top part of this arrow
// window. The bottom part follows the rynthnav thing though"). The arrow window showed the arrow's
// target (clicked chat coordinates) over the last route planned or walked, which was for somewhere
// else. Now a new target replaces the old one (TargetSwitch): the arrow set elsewhere drops the shown
// route and ends a walk to another place; a plan (/rnav route, Plan) points the arrow along itself;
// /rnav clear (the arrow window's x) forgets all of it. The same place again changes nothing.
// Tick thread: the commands run there (RunCommand).
public sealed partial class RynthNavPlugin
{
// Where the shown route goes (NaN: none, or unknown), for "the same place" and the status's route goal.
private double _shownRouteNs = double.NaN, _shownRouteEw = double.NaN;
private void SetShownRouteGoal(double ns, double ew) { _shownRouteNs = ns; _shownRouteEw = ew; }
/// <summary>The shown route and the trip, as TargetSwitch reads them.</summary>
private HeldTarget Held() => new(
_shownRoute != null, _shownRouteFor, _shownRouteNs, _shownRouteEw,
_gotoActive, _gotoName,
_gotoActive ? NavCoords.NsFromWorld(_finalTns) : double.NaN,
_gotoActive ? NavCoords.EwFromWorld(_finalTew) : double.NaN);
/// <summary>
/// Applies what a new target does to the old one: the walk stopped (as Stop does), the shown
/// route forgotten. Returns what was ended, for the command's reply ("" for nothing).
/// </summary>
private string ApplyTargetChange(TargetChange c, in HeldTarget held)
{
string ended = "";
if (c.StopTrip && held.Walking)
{
StopTripNow();
ended = "stopped the walk to " + (held.TripFor.Length > 0 ? held.TripFor : NavCoords.Fmt(held.TripNs, held.TripEw));
}
if (c.DropPlan && _shownRoute != null)
{
if (ended.Length == 0 && !_shownRouteLive && _shownRouteFor.Length > 0) ended = "dropped the route to " + _shownRouteFor;
_shownRoute = null;
_shownRouteFor = "";
_shownRouteLive = false;
SetShownRouteGoal(double.NaN, double.NaN);
_routeVersion++;
HideMarkers("a new target");
}
return ended;
}
/// <summary>
/// Ends the trip at once, as Stop does (ProcessRequests' cancel), but here on the tick so a plan
/// made right after keeps its markers (the cancel request would hide them later this tick).
/// </summary>
private void StopTripNow()
{
_goNote = "stopped";
_gotoActive = false; _paused = false; _route = null; _portalWait = false;
if (_recallWait) EndRecall();
ResetHub();
AutoRun.Stop();
HideMarkers("a new target");
lock (_moveGate) { _desiredRun = 0; _turnState = 0; _haltPending = true; } // ApplyMovement lets go of the keys
}
/// <summary>/rnav clear: no target at all. The walk stops, the route goes, the arrow goes off.</summary>
private void CmdClear()
{
HeldTarget held = Held();
bool hadArrow = _arrow.Active;
string ended = ApplyTargetChange(TargetSwitch.For(NewTarget.Clear, held), held);
_arrow.Clear();
if (!hadArrow && !held.HasPlan && !held.Walking) { Say("clear: no target to clear"); return; }
Note("target cleared" + (ended.Length > 0 ? ": " + ended : "") + (hadArrow ? "; arrow off" : ""));
}
}

View file

@ -342,6 +342,7 @@ public sealed partial class RynthNavPlugin
_castRecallSpell = 0;
RecallSlot? learned = spell switch
{
RecallPlanner.PortalRecall => RecallSlot.LastPortal, // a cast confirms where it goes
RecallPlanner.LifestoneRecall => RecallSlot.Lifestone,
RecallPlanner.PrimaryPortalTieRecall => RecallSlot.Tie1,
RecallPlanner.SecondaryPortalTieRecall => RecallSlot.Tie2,
@ -365,15 +366,43 @@ public sealed partial class RynthNavPlugin
// hand, or dying and waking at the lifestone) isn't a portal.
if (landing.OnMap && LandsLikeARecall(landing)) return;
string label = landing.Label;
int? bitmask = null;
if (havePre && IsOnMap(preCell))
{
AtlasLocation? p = _atlas.Nearest("Portal", NavCoords.NsFromWorld(preWy), NavCoords.EwFromWorld(preWx), PortalNearUnits);
double ns = NavCoords.NsFromWorld(preWy), ew = NavCoords.EwFromWorld(preWx);
AtlasLocation? p = _atlas.Nearest("Portal", ns, ew, PortalNearUnits);
if (p != null) label = p.Name + (landing.Label.Length > 0 ? " → " + landing.Label : "");
bitmask = PortalBitmaskNear(ns, ew);
}
landing.Label = label;
switch (RecallPlanner.ForPortal(bitmask))
{
case RecallPlanner.LastPortalUpdate.Keep:
Host.Log($"[RynthNav] {label}: a no-recall portal, so Portal Recall still goes to the last portal before it");
return;
case RecallPlanner.LastPortalUpdate.SetUnconfirmed:
landing.Unconfirmed = true;
Host.Log($"[RynthNav] {label}: not in the portal list; Portal Recall isn't used for routes until a cast confirms where it goes");
break;
}
_memory.Set(who, RecallSlot.LastPortal, landing);
}
/// <summary>The PortalBitmask of the listed portal whose entrance is nearest (within PortalNearUnits), or null.</summary>
private int? PortalBitmaskNear(double ns, double ew)
{
EnsurePortalsLoaded();
if (_portals == null) return null;
double best = PortalNearUnits;
int? mask = null;
foreach (PortalLink p in _portals)
{
double d = NavCoords.Distance(ns, ew, p.SrcNs, p.SrcEw);
if (d < best) { best = d; mask = p.Bitmask; }
}
return mask;
}
private bool LandsLikeARecall(RecallSpot s)
{
foreach (AtlasRecall r in _atlas.Recalls)
@ -701,12 +730,14 @@ public sealed partial class RynthNavPlugin
/// <summary>The Atlas place the last ResolveTarget picked (null for bare coordinates). Tick thread.</summary>
private AtlasLocation? _resolvedPlace;
private void SetArrow(string name, string type, double ns, double ew, bool announce)
/// <param name="ended">What the new target ended (ApplyTargetChange: "stopped the walk to ..."), said after it.</param>
private void SetArrow(string name, string type, double ns, double ew, bool announce, string ended = "")
{
_arrow.SetTarget(name, type, ns, ew);
_store.Touch(new SavedPlace { Name = name, Type = type, Ns = ns, Ew = ew });
_openArrowSeq++;
if (announce) Say($"Arrow: {name}{(type.Length > 0 ? " (" + type + ")" : "")} at {NavCoords.Fmt(ns, ew)}{DistanceFromHere(ns, ew)}.");
if (announce) Say($"Arrow: {name}{(type.Length > 0 ? " (" + type + ")" : "")} at {NavCoords.Fmt(ns, ew)}{DistanceFromHere(ns, ew)}"
+ (ended.Length > 0 ? $" ({ended})." : "."));
}
private string DistanceFromHere(double ns, double ew)
@ -932,6 +963,8 @@ public sealed partial class RynthNavPlugin
.Append(",\"avoidWalls\":").Append(_avoidWalls ? 1 : 0).Append(",\"avoidWallM\":").Append(_wallClearance.ToString("0.#", System.Globalization.CultureInfo.InvariantCulture))
.Append(",\"cornerM\":").Append(_cornerReach.ToString("0.#", System.Globalization.CultureInfo.InvariantCulture));
sb.Append(",\"openArrow\":").Append(_openArrowSeq);
// /rnav clear is there (from 11-26): the arrow window's x sends it (older RynthNavs get "arrow off").
sb.Append(",\"clearCmd\":1");
// Arrow
sb.Append(",\"arrow\":");
@ -956,7 +989,11 @@ public sealed partial class RynthNavPlugin
if (_shownRoute == null) sb.Append("null");
else
{
sb.Append("{\"for\":\"").Append(Esc(_shownRouteFor)).Append("\",\"est\":").Append(_shownRouteEst.ToString("F0", ci))
sb.Append("{\"for\":\"").Append(Esc(_shownRouteFor)).Append("\",\"est\":").Append(_shownRouteEst.ToString("F0", ci));
// Where it goes (from 11-26): the arrow window shows the route only under an arrow to the same place.
if (!double.IsNaN(_shownRouteNs) && !double.IsNaN(_shownRouteEw))
sb.Append(",\"gns\":").Append(_shownRouteNs.ToString("F3", ci)).Append(",\"gew\":").Append(_shownRouteEw.ToString("F3", ci));
sb
.Append(",\"active\":").Append(_gotoActive && _shownRouteLive ? 1 : 0)
.Append(",\"idx\":").Append(_gotoActive && _shownRouteLive ? (_route != null ? routeIdx : 0) : -1);
// How long the trip takes, in seconds (RynthNavPlugin.TripTime.cs; -1 = not known).
@ -1023,7 +1060,8 @@ public sealed partial class RynthNavPlugin
}
private const string HelpText =
"/rnav arrow <place|coords> | arrow off | arrow route <place> — the arrow\n" +
"/rnav arrow <place|coords> | arrow off | arrow route <place> — the arrow (one target: a new one replaces the route, and a walk elsewhere)\n" +
"/rnav clear — no target: the walk stops, the route goes, the arrow goes off\n" +
"/rnav go <place|coords> — walk there (route with portals/recalls when /rnav portals on)\n" +
"/rnav route <place|coords> — plan a route (portals and recalls), no walking\n" +
"/rnav route next — another way to the same place (switches a running goto) | route go — walk the way shown\n" +
@ -1032,7 +1070,7 @@ public sealed partial class RynthNavPlugin
"/rnav pause — stop walking, keep the trip on the map (drive by hand meanwhile) | resume — carry on\n" +
"/rnav times — how long this character's trips take (run speed, portals, recalls, portal space)\n" +
"/rnav avoid — show; avoid portals on|off|<m> | walls on|off|<m> | corners <m>\n" +
"/rnav markers on|off | markers labels on|off | markers guide on|off — the trip on the ground\n" +
"/rnav markers on|off | markers clear | markers labels on|off | markers guide on|off — the trip on the ground (clear: this trip's, now)\n" +
"/rnav mesh on|off | floor on|off | walls on|off | radius <m> | triangles <n> — draw the navmesh: green floor, red walls\n" +
"/rnav saveroute [name] [overwrite] — save the last trip as a RynthAi nav route (NavProfiles)\n" +
"/rnav makeroute <name> to <place|coords> [overwrite] — plan a trip and save it as a nav route in one go, no walking\n" +
@ -1082,6 +1120,7 @@ public sealed partial class RynthNavPlugin
break;
case "route": CmdRoute(rest); break;
case "arrow": CmdArrow(rest); break;
case "clear": CmdClear(); break; // RynthNavPlugin.Target.cs
case "atlas": CmdAtlas(rest); break;
case "fav": CmdFav(rest); break;
case "recent":
@ -1119,24 +1158,39 @@ public sealed partial class RynthNavPlugin
if (rest.Equals("off", StringComparison.OrdinalIgnoreCase) || rest.Equals("clear", StringComparison.OrdinalIgnoreCase))
{
_arrow.Clear();
Say("arrow off");
// One target: a plan goes with the arrow. A walk carries on (Stop, or /rnav clear, ends it).
string dropped = _gotoActive ? "" : ApplyTargetChange(new TargetChange(true, false, false), Held());
Say("arrow off" + (dropped.Length > 0 ? " (" + dropped + ")" : ""));
return;
}
if (rest.StartsWith("route ", StringComparison.OrdinalIgnoreCase))
{
string where = rest.Substring(6);
if (!ResolveTarget(where, out string n, out string t, out double rns, out double rew, out string err)) { Note(err); return; }
HeldTarget rheld = Held();
TargetChange rc = TargetSwitch.For(NewTarget.Plan, rheld, rns, rew);
if (rc.KeepArrow) { _openArrowSeq++; Say($"arrow route: already walking to {n}; the arrow follows the trip."); return; }
string rended = ApplyTargetChange(rc, rheld);
List<RouteStep>? steps = PlanAndShow(n, rns, rew, out int used, out double est, out string refusal);
if (refusal.Length > 0) Note("arrow route: " + refusal);
if (steps == null || used == 0) { SetArrow(n, t, rns, rew, announce: true); return; }
if (steps == null || used == 0) { SetArrow(n, t, rns, rew, announce: true, rended); return; }
_arrow.SetRoute(steps, n, t, rns, rew);
_store.Touch(new SavedPlace { Name = n, Type = t, Ns = rns, Ew = rew });
_openArrowSeq++;
Say($"arrow route to {n}: {used} teleport(s). First: {StepText(_arrow.Current!)}.");
Say($"arrow route to {n}: {used} teleport(s). First: {StepText(_arrow.Current!)}{(rended.Length > 0 ? $" ({rended})" : "")}.");
return;
}
if (!ResolveTarget(rest, out string name, out string type, out double ns, out double ew, out string error)) { Note(error); return; }
SetArrow(name, type, ns, ew, announce: true);
HeldTarget held = Held();
TargetChange c = TargetSwitch.For(NewTarget.Arrow, held, ns, ew);
if (c.KeepArrow)
{
// Walking there already: the arrow stays the trip's (along its portals and recalls).
_openArrowSeq++;
Say($"Arrow: already walking to {(held.TripFor.Length > 0 ? held.TripFor : name)}; the arrow follows the trip.");
return;
}
SetArrow(name, type, ns, ew, announce: true, ApplyTargetChange(c, held));
}
private void CmdGo(string rest)
@ -1309,6 +1363,7 @@ public sealed partial class RynthNavPlugin
used = plan.Teleports; est = plan.Est; refusal = plan.Refusal;
_shownRoute = steps ?? new List<RouteStep> { new(ns, ew, false, false, "walk") };
_shownRouteFor = name;
SetShownRouteGoal(ns, ew);
_shownRouteEst = est;
_shownRouteLive = false;
_routeVersion++;

View file

@ -393,12 +393,25 @@ public sealed partial class RynthNavPlugin
if (_wayCount > 1) Say($" {_wayCount} ways in all: /rnav route next for another, /rnav route go to walk this one");
}
/// <summary>Plans (with the way chosen) and shows the route to a place: the panel, the arrow, chat.</summary>
/// <summary>
/// Plans (with the way chosen) and shows the route to a place: the panel, the arrow, chat. The plan
/// is the target now (RynthNavPlugin.Target.cs): the arrow points along it, and a walk to somewhere
/// else ends. A walk to the same place goes on with its own arrow.
/// </summary>
private void ShowRoute(string name, string type, double ns, double ew)
{
HeldTarget held = Held();
TargetChange change = TargetSwitch.For(NewTarget.Plan, held, ns, ew);
string ended = ApplyTargetChange(change, held);
List<RouteStep>? steps = PlanAndShow(name, ns, ew, out int used, out double est, out string refusal);
_waysType = type;
if (refusal.Length > 0) { Note($"route to {name}: {refusal}"); return; }
if (refusal.Length > 0) { Note($"route to {name}: {refusal}{(ended.Length > 0 ? " (" + ended + ")" : "")}"); return; }
if (!change.KeepArrow)
{
if (steps != null && used > 0) _arrow.SetRoute(steps, name, type, ns, ew);
else _arrow.SetTarget(name, type, ns, ew);
}
if (ended.Length > 0) Say($"route to {name}: {ended}");
SayRoute(name, ns, ew, steps, used, est);
}

View file

@ -535,7 +535,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
_enterName = enter; _enterType = enterType;
if (enter.Length > 0) _route = Entrance.EndingInPortal(_route, tns, tew, enter);
_shownRoute = _route ?? new List<RouteStep> { new(tns, tew, false, false, "walk") };
_shownRouteFor = name; _shownRouteEst = est; _shownRouteLive = true; _routeVersion++;
_shownRouteFor = name; SetShownRouteGoal(tns, tew); _shownRouteEst = est; _shownRouteLive = true; _routeVersion++;
SetSubGoalToCurrentLeg();
if (_route != null && portalsUsed > 0) _arrow.SetRoute(_route, name, type, tns, tew);
else _arrow.SetTarget(name, type, tns, tew);

View file

@ -0,0 +1,57 @@
using System;
namespace RynthCore.Plugin.RynthNav;
/// <summary>What asks for a new target: the arrow (chat coords, the Atlas, /rnav arrow), a planned
/// route (/rnav route, Plan), or /rnav clear (the arrow window's x).</summary>
internal enum NewTarget { Arrow, Plan, Clear }
/// <summary>
/// What RynthNav holds when a new target comes: the route shown in the panels (a plan, or the
/// trip's own route), and the trip being walked (paused counts).
/// </summary>
internal readonly record struct HeldTarget(
bool HasPlan, string PlanFor, double PlanNs, double PlanEw,
bool Walking, string TripFor, double TripNs, double TripEw);
/// <summary>
/// What the new target does to the old one. DropPlan: forget the shown route. StopTrip: end the
/// walk. KeepArrow: leave the arrow as it is (the trip's own arrow, chained along its route).
/// </summary>
internal readonly record struct TargetChange(bool DropPlan, bool StopTrip, bool KeepArrow)
{
public static readonly TargetChange None = new(false, false, false);
}
/// <summary>
/// One target at a time, the newest wins (11-24: the arrow window showed the clicked chat
/// coordinates on top and an older route under them). A new target elsewhere replaces the shown
/// route and ends a walk to somewhere else; the same place again leaves them be. Pure: the
/// offline tests compile this file.
/// </summary>
internal static class TargetSwitch
{
/// <summary>Two targets this close are the same place (chat coordinates have one decimal: 0.05 degrees is 12 u).</summary>
public const double SamePlaceUnits = 15.0;
/// <summary>By position only: two places with one name ("Lifestone") are not the same place.</summary>
public static bool SamePlace(double nsA, double ewA, double nsB, double ewB) =>
!double.IsNaN(nsA) && !double.IsNaN(ewA) && !double.IsNaN(nsB) && !double.IsNaN(ewB)
&& NavCoords.Distance(nsA, ewA, nsB, ewB) <= SamePlaceUnits;
public static TargetChange For(NewTarget what, in HeldTarget held, double ns = double.NaN, double ew = double.NaN)
{
if (what == NewTarget.Clear) return new TargetChange(held.HasPlan, held.Walking, false);
if (held.Walking)
{
// Going there already: the trip (and its arrow, along its portals) stays.
if (SamePlace(ns, ew, held.TripNs, held.TripEw)) return new TargetChange(false, false, true);
// Somewhere else: the walk ends, its route with it (a plan makes its own).
return new TargetChange(what == NewTarget.Arrow, true, false);
}
// A plan replaces the shown route itself; the arrow drops one that is for another place.
if (what == NewTarget.Arrow && held.HasPlan && !SamePlace(ns, ew, held.PlanNs, held.PlanEw))
return new TargetChange(true, false, false);
return TargetChange.None;
}
}