Squash of test/main-merge-2026-10-25 onto aelrynth main 2026.11.19.1 for the standing sk PR. Includes Trade Shop, Oracle wiki/ILT tracker, quest runs, loot checklist, RynthNav, VTank import. HandWrittenVersion remains 0.5.0-legacy-ui. See Changelog/2026-11-22-sk-backlog-test-merge.md.
80 lines
3.6 KiB
C#
80 lines
3.6 KiB
C#
using System;
|
|
using RynthCore.Plugin.Shared;
|
|
using RynthCore.Plugin.RynthInventory.Data;
|
|
using RynthCore.Plugin.Shared;
|
|
using RynthCore.PluginSdk;
|
|
|
|
namespace RynthCore.Plugin.RynthInventory;
|
|
|
|
/// <summary>What the window reads and the actions it can take. Plugin pump thread only.</summary>
|
|
internal sealed class InventoryContext
|
|
{
|
|
public RynthCoreHost Host;
|
|
public readonly InventorySettings Settings = new();
|
|
public InventoryStore Store = new();
|
|
|
|
/// <summary>The merged view of every file (and this client's live snapshot); null until first built.</summary>
|
|
public InventoryIndex? Index;
|
|
/// <summary>Bumped whenever <see cref="Index"/> is replaced.</summary>
|
|
public int IndexRevision;
|
|
public int BrokenFiles;
|
|
public bool Loading;
|
|
|
|
public bool InWorld;
|
|
public uint Player;
|
|
public string Server = string.Empty;
|
|
public string Account = string.Empty;
|
|
public string Character = string.Empty;
|
|
/// <summary>This character's latest snapshot (never changed once published; a change makes a new one).</summary>
|
|
public CharacterSnapshot? Live;
|
|
public DateTime LastSavedUtc;
|
|
public string LastSaveError = string.Empty;
|
|
/// <summary>The storage container open right now, if it is being recorded (0 none).</summary>
|
|
public uint OpenStorage;
|
|
public string OpenStorageLabel = string.Empty;
|
|
|
|
/// <summary>The engine draws icons in script windows (op level 2).</summary>
|
|
public bool IconsAvailable;
|
|
public DateTime UtcNow;
|
|
|
|
public Action RequestRescan = () => { };
|
|
public Action RequestReload = () => { };
|
|
/// <summary>Forgets a character (moves its file aside). Returns a message for the player.</summary>
|
|
public Func<CharacterInfo, string> Forget = _ => string.Empty;
|
|
|
|
// ── Trade ────────────────────────────────────────────────────────────
|
|
/// <summary>The active trade list (null when none). Pump thread only.</summary>
|
|
public TradeList? Trade;
|
|
/// <summary>Action for trade commands from the trade view ("start", "cancel", "clear", "new").</summary>
|
|
public Action<string>? TradeCommand;
|
|
|
|
/// <summary>
|
|
/// RynthCore's active server is Infinite Leaftide (EngineServerState.IltId): the Banking page
|
|
/// (RynthILT's bank) shows and is read only then. Re-read every couple of seconds.
|
|
/// </summary>
|
|
public bool Ilt;
|
|
/// <summary>RynthILT's data interface (the bank).</summary>
|
|
public readonly RynthIltDataClient IltData = new();
|
|
/// <summary>The bank as RynthILT last reported it (None off Infinite Leaftide or before the first read).</summary>
|
|
public IltBankView Bank = IltBankView.None;
|
|
/// <summary>A Banking page action: a verb line for RynthILT (refresh, deposit, withdraw, transfer).</summary>
|
|
public Func<string, bool> BankCommand = _ => false;
|
|
|
|
/// <summary>
|
|
/// The plugin's chat lines, queued and written by the tick (Plugins/Shared/CommandReply.cs: the host
|
|
/// drops a line within 100 ms of another plugin's). Null before Initialize.
|
|
/// </summary>
|
|
public CommandReply? Reply;
|
|
|
|
public void Print(string text) => Print(text, ok: true);
|
|
|
|
/// <summary>A line saying a command didn't work (the failure colour).</summary>
|
|
public void PrintFail(string text) => Print(text, ok: false);
|
|
|
|
private void Print(string text, bool ok)
|
|
{
|
|
if (Reply != null) { Reply.Say(ok, text); return; }
|
|
if (!Host.WriteToChat("[RynthInventory] " + text, ok ? CommandReply.OkChatType : CommandReply.FailChatType))
|
|
Host.Log("[RynthInventory] " + text);
|
|
}
|
|
}
|