Snapshot for release 2026.10.20.1 (internal 7116fab)
This commit is contained in:
parent
2a20c7acd6
commit
bfcd48950d
215 changed files with 16200 additions and 2838 deletions
214
Plugins/RynthCore.Plugin.RynthOracle/Views/DynamicStampsTab.cs
Normal file
214
Plugins/RynthCore.Plugin.RynthOracle/Views/DynamicStampsTab.cs
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.RynthOracle.Data;
|
||||
using RynthCore.Plugin.RynthOracle.Ui;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Views;
|
||||
|
||||
/// <summary>
|
||||
/// Dynamic Stamps (Infinite Leaftide only): the NPC hand-ins that put a "Dynamic_N_..." flag on
|
||||
/// the character, read from /myquests. They are rows of the Quests tab's merged list (QuestsTab.cs:
|
||||
/// DYN rows, the Show filter's area picker). What is here is the opened stamp's box (RynthNav, the
|
||||
/// Parchment hand-in, chat), the read after a hand-in, and the RynthNav sender every row kind
|
||||
/// shares. The list follows the players' "ExtraDyn" sheet (dynstamps.csv).
|
||||
///
|
||||
/// Give Parchment sends RynthAi's "/ub give 1 <parchment> to <npc>". That verb belongs to
|
||||
/// RynthAi, so the button is disabled (with a tooltip saying why) when RynthAi isn't loaded or has
|
||||
/// answered "Unrecognized /ub command" to it.
|
||||
/// </summary>
|
||||
internal sealed partial class OracleView
|
||||
{
|
||||
// The stamp clicked last: the box below the list offers RynthNav's auto nav to it.
|
||||
private DynamicStamp? _dynNav;
|
||||
private bool _dynNavDone;
|
||||
private string _dynNavStatus = "";
|
||||
// The Parchment waiting for Yes: handing it over is the one thing here that can't be taken back.
|
||||
private string _giveConfirm = "";
|
||||
|
||||
/// <summary>
|
||||
/// The destination box (the click's pop-up): the stamp, where RynthNav will take you, and Go (plan
|
||||
/// and walk the route: portals, recalls and dungeon entrances included), Arrow, Chat and Close.
|
||||
/// </summary>
|
||||
private void DrawDynamicNavBox(UiWindow w)
|
||||
{
|
||||
DynamicStamp? s = _dynNav;
|
||||
if (s == null) return;
|
||||
List<string> targets = s.NavCandidates();
|
||||
w.SeparatorText("Navigate to " + Cut(s.Label, 40));
|
||||
w.TextDisabled(targets.Count == 0
|
||||
? "No place, coordinates or area to go to for this stamp."
|
||||
: "Where: " + Cut(string.Join(" or ", targets), 90));
|
||||
if (targets.Count > 0)
|
||||
{
|
||||
w.Button("Go (auto nav)", "dy.nav.go", () => SendNav("go", s));
|
||||
w.Tooltip("RynthNav plans the route (walking, portals, recalls, the dungeon's entrance) and walks it.");
|
||||
w.SameLine();
|
||||
w.Button("Arrow", "dy.nav.arrow", () => SendNav("arrow", s));
|
||||
w.Tooltip("Only point RynthNav's arrow at it.");
|
||||
w.SameLine();
|
||||
}
|
||||
w.Button("Chat", "dy.nav.chat", () => PrintStamp(s, _dynNavDone));
|
||||
w.SameLine();
|
||||
w.Button("Close", "dy.nav.close", () => { _dynNav = null; _dynNavStatus = ""; _selKey = ""; _giveConfirm = ""; });
|
||||
|
||||
// The hand-in: a Parchment from your packs to the stamp's NPC (RynthAi's /ub give).
|
||||
if (s.Npc.Length > 0)
|
||||
{
|
||||
string? parchment = CarriedParchment();
|
||||
if (parchment != null)
|
||||
{
|
||||
string? why = GiveUnavailableReason();
|
||||
if (why == null && _giveConfirm == parchment)
|
||||
{
|
||||
// Asked first: the Parchment leaves the pack and doesn't come back.
|
||||
w.TextColored(UiColors.Red, $"Give one {Cut(parchment, 30)} to {Cut(s.Npc, 30)}? It leaves your pack for good.");
|
||||
w.SmallButton("Yes, give it", "dy.nav.give.yes", () => { _giveConfirm = ""; GiveParchment(s, parchment); });
|
||||
w.SameLine();
|
||||
w.SmallButton("Cancel", "dy.nav.give.no", () => _giveConfirm = "");
|
||||
}
|
||||
else if (why == null)
|
||||
{
|
||||
w.Button("Give " + Cut(parchment, 24), "dy.nav.give", () => _giveConfirm = parchment);
|
||||
w.Tooltip($"Hands one {parchment} to {s.Npc} (it asks first). Stand near them (or Go first): AC walks you the last bit.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Greyed text in place of the button, so it can't be clicked into a command nobody answers.
|
||||
w.TextDisabled("[Give " + Cut(parchment, 24) + "]");
|
||||
w.Tooltip(why);
|
||||
}
|
||||
}
|
||||
else
|
||||
w.TextDisabled("No Parchment in your packs to give " + Cut(s.Npc, 30) + ".");
|
||||
}
|
||||
if (_dynNavStatus.Length > 0) w.TextDisabled(_dynNavStatus);
|
||||
}
|
||||
|
||||
// A /myquests read this long after a Parchment hand-in (the walk there and the NPC's answer), so
|
||||
// the new stamp shows as had; 0 = none due.
|
||||
private const long HandInRefreshMs = 8000;
|
||||
private long _dynRefreshAt;
|
||||
|
||||
/// <summary>The read after a hand-in, when it is due: now, or when the server's once-a-minute wait ends.</summary>
|
||||
private void RefreshAfterHandIn(QuestFlagStore flags)
|
||||
{
|
||||
if (_dynRefreshAt == 0 || _c.NowMs < _dynRefreshAt) return;
|
||||
if (flags.Loading) return;
|
||||
int wait = flags.ThrottleSecondsLeft(_c.NowMs);
|
||||
if (wait > 0) { _dynRefreshAt = _c.NowMs + wait * 1000L; return; }
|
||||
_dynRefreshAt = 0;
|
||||
_c.RequestQuests();
|
||||
}
|
||||
|
||||
// Packs scanned for a Parchment at most this often (the box draws every frame).
|
||||
private const long ParchmentScanMs = 1500;
|
||||
private long _parchmentScanAt;
|
||||
private string? _parchmentName;
|
||||
|
||||
/// <summary>
|
||||
/// The name of a Parchment you carry (the main pack and its side packs), or null. Any item
|
||||
/// whose name has "Parchment" in it; read again every <see cref="ParchmentScanMs"/>.
|
||||
/// </summary>
|
||||
private string? CarriedParchment()
|
||||
{
|
||||
if (_c.ParchmentFinder != null) return _c.ParchmentFinder();
|
||||
if (_c.NowMs - _parchmentScanAt < ParchmentScanMs && _parchmentScanAt != 0) return _parchmentName;
|
||||
_parchmentScanAt = _c.NowMs == 0 ? 1 : _c.NowMs;
|
||||
_parchmentName = null;
|
||||
RynthCore.PluginSdk.RynthCoreHost host = _c.Host; // a struct: an empty one (the offline tests) reports nothing carried
|
||||
uint me = _c.Character.PlayerId;
|
||||
if (!_c.InWorld || me == 0 || !host.HasGetContainerContents) return null;
|
||||
var buf = new uint[512];
|
||||
var packs = new List<uint> { me };
|
||||
for (int p = 0; p < packs.Count && p < 16; p++)
|
||||
{
|
||||
int n = Math.Min(host.GetContainerContents(packs[p], buf), buf.Length);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
uint id = buf[i];
|
||||
if (!host.TryGetObjectName(id, out string name)) continue;
|
||||
if (name.IndexOf("Parchment", StringComparison.OrdinalIgnoreCase) >= 0) { _parchmentName = name; return name; }
|
||||
// A side pack in the main pack: look inside it too (only one level deep, as AC packs go).
|
||||
if (p == 0) packs.Add(id);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Why Give Parchment can't be used now (for its tooltip); null when it can.</summary>
|
||||
private string? GiveUnavailableReason()
|
||||
{
|
||||
if (_c.UbGiveMissing)
|
||||
return "The loaded RynthAi has no \"/ub give\" (it answered \"Unrecognized /ub command\"). Update RynthAi, or hand the Parchment over yourself.";
|
||||
if (!_c.UbGiveAvailable())
|
||||
return "Needs RynthAi: the hand-in is RynthAi's \"/ub give\". It isn't loaded (or you aren't logged in), so give the Parchment to the NPC yourself.";
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>A name made safe to put inside a chat command: no control characters.</summary>
|
||||
private static string ForCommand(string name)
|
||||
{
|
||||
var sb = new System.Text.StringBuilder(name.Length);
|
||||
foreach (char ch in name) if (ch >= ' ' && ch != '\u007f') sb.Append(ch);
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
/// <summary>"/ub give 1 <parchment> to <npc>": RynthAi finds the NPC by name and hands it over.</summary>
|
||||
private void GiveParchment(DynamicStamp s, string parchment)
|
||||
{
|
||||
if (!_c.InWorld) { _dynNavStatus = "Log in first."; return; }
|
||||
string? why = GiveUnavailableReason();
|
||||
if (why != null) { _dynNavStatus = why; return; }
|
||||
_c.UbGiveSentMs = _c.NowMs; // a "Unrecognized /ub command" in the next moments turns the button off
|
||||
bool sent = _c.RunCommand($"/ub give 1 {ForCommand(parchment)} to {ForCommand(s.Npc)}");
|
||||
_parchmentScanAt = 0; // read the packs again after the give
|
||||
// The stamp is a quest flag: read /myquests again once the NPC has had time to answer.
|
||||
if (sent) _dynRefreshAt = _c.NowMs + HandInRefreshMs;
|
||||
_dynNavStatus = sent
|
||||
? $"Giving {parchment} to {s.Npc} (RynthAi does the give; it says so in chat if {s.Npc} isn't in sight)."
|
||||
: "Could not send the give.";
|
||||
}
|
||||
|
||||
/// <summary>Clicking a row: select it and ask RynthNav for the route (shown in chat and its overlay).</summary>
|
||||
private void SelectDynamicStamp(DynamicStamp s, bool done)
|
||||
{
|
||||
_dynNav = s;
|
||||
_dynNavDone = done;
|
||||
_dynNavStatus = "";
|
||||
_giveConfirm = "";
|
||||
if (s.NavCandidates().Count > 0) SendNav("route", s);
|
||||
}
|
||||
|
||||
/// <summary>"/rnav <verb> a || b || c" to RynthNav (it takes the first candidate on its map).</summary>
|
||||
private void SendNav(string verb, DynamicStamp s)
|
||||
{
|
||||
List<string> targets = s.NavCandidates();
|
||||
if (targets.Count == 0) return;
|
||||
_dynNavStatus = SendRynthNav(verb, targets);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "/rnav <verb> a || b || c" to RynthNav (go walks the route, route plans it in chat, arrow
|
||||
/// points at it; RynthNav takes the first candidate on its map). What to tell the player.
|
||||
/// Shared by every row kind of the Quests tab.
|
||||
/// </summary>
|
||||
private string SendRynthNav(string verb, IReadOnlyList<string> targets)
|
||||
{
|
||||
if (targets.Count == 0) return "";
|
||||
if (!_c.InWorld) return "Log in first.";
|
||||
bool sent = _c.SendNav(verb + " " + string.Join(" || ", targets));
|
||||
return !sent ? "RynthNav isn't loaded (it plans and walks the route)."
|
||||
: verb == "go" ? "RynthNav is planning the route and walking it (its chat lines say how)."
|
||||
: verb == "arrow" ? "RynthNav's arrow points at it."
|
||||
: "RynthNav's route is in chat. Go walks it.";
|
||||
}
|
||||
|
||||
/// <summary>Chat: the NPC, its stamp and whether this character has it, where, the reward and
|
||||
/// any coordinates (RynthChat makes those a RynthNav arrow link).</summary>
|
||||
private void PrintStamp(DynamicStamp s, bool done)
|
||||
{
|
||||
string where = s.Place.Length > 0 ? $"{s.Area}, {s.Place}" : s.Area;
|
||||
string details = $"{where}" + (s.Reward.Length > 0 ? $" - gives {s.Reward}" : "") + (s.Note.Length > 0 ? $" - {s.Note}" : "");
|
||||
PrintEntry(s.Label, s.Stamp, done ? "have" : "missing", details, "");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue