RynthServers/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubState.cs

364 lines
19 KiB
C#

// IltHubState.cs — Persisted per-character state for the ILT Hub (Infinite Leaftide tools).
// Originally SilentKelpie's ILT Hub state in RynthAi; moved to RynthILT 2026-10-13.
//
// Lives in %APPDATA%\RynthCore\RynthILT\<world>\<char>\hub.json (IltHubStore). The first
// login with RynthILT copies RynthAi's <charFolder>\ilt-hub.json there (IltMigration), so the
// shape stays compatible with that file: the parts that stayed with RynthAi's universal Mini
// Remote tabs (the Pets tab's settings, the quest tracker's filter and favorites, the VTank
// import path) are simply not read here any more. Serialized with the NativeAOT source-generated
// IltHubJsonContext (IncludeFields = true), so plain public fields are used throughout.
using System;
using System.Collections.Generic;
namespace RynthCore.Plugin.RynthILT.Hub;
/// <summary>Root of everything the Hub remembers between sessions.</summary>
public sealed class IltHubState
{
/// <summary>Bumped when the shape changes in a way that needs a migration.</summary>
public int SchemaVersion = 1;
// ── Window / shell ──────────────────────────────────────────────────────
/// <summary>
/// Hub UI on screen: the Mini Remote or any ILT section window (IltHubController.Tick keeps it
/// current). Bank auto-refresh and the gear / split-arrow scans run only while it is true.
/// </summary>
public bool WindowVisible;
/// <summary>Unused since the tabbed Hub window was retired; kept so old files still load.</summary>
public int SelectedTab;
public bool GamesHudVisible = true;
/// <summary>
/// "This world is an ACECustom/ILT shard even though its name isn't InfiniteLeaftide."
/// World-identity override ONLY: it makes the Hub ask the server for its options, it
/// never turns a feature on by itself.
/// </summary>
public bool ForceLeaftideFeatures;
/// <summary>True once the one-time UtilityBelt sidecar import has run for this character.</summary>
public bool UbSidecarsImported;
/// <summary>
/// True once the RynthAi settings that moved to RynthILT on 2026-10-20 (the Pets tab's ACECustom
/// options, ...) were copied from this character's RynthAi files (IltMigration.ImportRynthAiSettings).
/// </summary>
public bool RynthAiSettingsImported;
/// <summary>Last-seen server feature bits. Cache only — overwritten by every login refresh.</summary>
public IltServerOptionsSnapshot ServerOptions = new();
public IltBankState Bank = new();
public IltPetState Pet = new();
public IltCharacterState Character = new();
public IltGearState Gear = new();
public IltGamesState Games = new();
public IltGuardianState Guardian = new();
/// <summary>Infinite Leaftide combat helpers (moved from RynthAi's profile 2026-10-20).</summary>
public IltCombatState Combat = new();
/// <summary>
/// The Vaulted Dungeons keeper's master switch (off by default): while off it does nothing (no
/// recalls, no /rc quit, no tab). RynthAi's "Vaulted Dungeons" setting until 2026-10-20 (copied once);
/// set in the ILT settings ("/ilt settings") or the engine's Settings > Navigation row (RynthAi
/// mirrors it through RynthILT.Hub GetSetting / SetSetting).
/// </summary>
public bool VaultedDungeonsEnabled;
/// <summary>ACECustom T11 gear (IltT11): the item-aug override (moved from RynthAi's profile 2026-10-20).</summary>
public IltT11State T11 = new();
/// <summary>The ILT sections of RynthAi's Remote tab (moved from RynthAi's huds.json 2026-10-20).</summary>
public IltRemoteState Remote = new();
}
// ── RynthAi's Remote tab ────────────────────────────────────────────────────
public sealed class IltRemoteState
{
/// <summary>The Remote tab's Bank section (ILT bank balances). Was RynthAi's MiniShowBank.</summary>
public bool ShowBank = true;
/// <summary>The Remote tab's Guardian line (the last Temple guardian answer). Was RynthAi's MiniShowGuardian.</summary>
public bool ShowGuardian = true;
}
// ── T11 ─────────────────────────────────────────────────────────────────────
public sealed class IltT11State
{
/// <summary>
/// The item augmentation count T11 wield gates use ("T11: Can Wield" in RynthAi's loot rules) instead
/// of the "/aug" reply's; -1 = automatic (read from /aug). "/ilt t11 augs &lt;n|auto&gt;". Was RynthAi's
/// T11ItemAugsOverride.
/// </summary>
public int ItemAugsOverride = -1;
}
// ── Combat ──────────────────────────────────────────────────────────────────
public sealed class IltCombatState
{
/// <summary>
/// When the Empyrean Handler channels its lethal ring and the character is inside it, have RynthAi
/// back-jump away and re-engage (IltRingEvade; RynthAi acts only while its macro runs with combat
/// on). On by default because it is gated that way. Was RynthAi's HandlerRingEvade.
/// </summary>
public bool HandlerRingEvade = true;
}
/// <summary>Cached result of the server-options check (see IltServerOptions).</summary>
public sealed class IltServerOptionsSnapshot
{
public string WorldName = string.Empty;
/// <summary>"probe" (the login probe) or "" (never refreshed).</summary>
public string Source = string.Empty;
public DateTime LastRefreshUtc = DateTime.MinValue;
/// <summary>Feature key → -1 unknown, 0 off, 1 on.</summary>
public Dictionary<string, int> Bits = new(StringComparer.OrdinalIgnoreCase);
}
// ── Banking ─────────────────────────────────────────────────────────────────
public sealed class IltBankState
{
public long Pyreals;
public long Luminance;
public long LegendaryKeys;
public long MythicalKeys;
public long EnlightenedCoins;
public long WeaklyEnlightenedCoins;
/// <summary>Bound to the character: deposit and withdraw only, never transferred.</summary>
public long PrestigeCoins;
public DateTime LastUpdated = DateTime.MinValue;
/// <summary>Last transfer recipient typed into the transfer form.</summary>
public string TransferTarget = string.Empty;
public int TransferCurrencyIndex;
/// <summary>Transfer form's trade-note denomination (IltBankCommands.NoteDenominations; 9 = MMD).</summary>
public int TransferNoteIndex = 9;
/// <summary>Deposit / withdraw form choices (IltBankCommands.Deposits / Withdrawals / NoteDenominations).</summary>
public int DepositIndex;
public int WithdrawIndex;
public int WithdrawNoteIndex = 9;
/// <summary>Re-issue /bank every N seconds while the Hub is open (0 = manual only).</summary>
public int AutoRefreshSeconds = 120;
}
/// <summary>One "Transferred …" / "Received …" bank line seen in chat.</summary>
public sealed class IltBankTransaction
{
public DateTime Timestamp;
/// <summary>"Sent" or "Received".</summary>
public string Type = string.Empty;
public string Currency = string.Empty;
public long Amount;
public string OtherPlayer = string.Empty;
public string Description = string.Empty;
}
// ── Pet ─────────────────────────────────────────────────────────────────────
public sealed class IltPetState
{
/// <summary>Last captured /pets and /shinies rosters (display only; the Pets tab's logs).</summary>
public List<string> PetLog = new();
public List<string> ShinyLog = new();
/// <summary>The breeding tracker: rules this server showed, growth stage names, recent events (IltPetBreeding).</summary>
public IltBreedingState Breeding = new();
// ACECustom's parts of the Pets tab (IltPetAutomation, moved from RynthAi 2026-10-20; copied once
// from RynthAi's miniremote.json by IltMigration.ImportRynthAiSettings). New names on purpose: an
// old ilt-hub.json copy still carries RynthAi's UsePyrealRefillPath / AutoCaptureEnabled /
// CaptureLensIndex from before 2026-10-13, and those stale values must not be read back.
/// <summary>
/// Summon from an EMPTY essence while the Summon Essence Refill charm is on (the server refills it
/// from banked pyreals). Still needs the server to confirm the feature (RynthAi.Hub's PetManager
/// asks AllowSummonOnEmpty).
/// </summary>
public bool RefillFromEmpty;
/// <summary>Use the chosen siphon lens on the nearest creature once it is weak enough (off by default).</summary>
public bool AutoCapture;
/// <summary>Index into PetCaptureRules.Lenses (Flawed to Asheron's).</summary>
public int CaptureLens;
// The Pets tab's own settings (roster, healing / cosmetic pets) are RynthAi's (its miniremote.json).
}
// ── Character ───────────────────────────────────────────────────────────────
public sealed class IltCharacterState
{
/// <summary>Item → coin conversion table used by the session-rates strip.</summary>
public List<IltItemConversion> ItemConversions = new()
{
new IltItemConversion { ItemName = "Strawberry Jam Jar", ItemsPerConversion = 100, CoinsPerConversion = 10 },
new IltItemConversion { ItemName = "Ancient Pyreal", ItemsPerConversion = 100, CoinsPerConversion = 37 },
};
/// <summary>Augmentation planner targets, keyed by aug type (lowercase).</summary>
public Dictionary<string, int> AugTargets = new(StringComparer.OrdinalIgnoreCase);
/// <summary>Luminance price of one Enlightened Coin (planner math only; 0 = don't price coins).</summary>
public long LumPerEnlightenedCoin;
/// <summary>Enlightenment planner target level (0 = current + 5).</summary>
public int EnlTargetLevel;
public int EnlightenedCoinsPerToken = 20;
/// <summary>
/// Auto-enlighten preference. Even when true it stays DISARMED each session until the
/// player confirms in the Hub, and the server's own Yes/No dialog is never auto-clicked.
/// </summary>
public bool AutoEnlightenEnabled;
public int AutoEnlightenCheckSeconds = 30;
/// <summary>Spend unassigned XP with /attr before sending /enl (enlightening wipes unspent XP).</summary>
public bool AutoEnlightenSpendXpFirst;
// ── Attribute raiser (IltAttributeRaiser; Skills panel > Progression) ──
/// <summary>Spend unassigned XP on the ticked attributes/vitals every AttrAutoRaiseMinutes.</summary>
public bool AttrAutoRaise;
public int AttrAutoRaiseMinutes = 5;
/// <summary>IltAttributeRaiser.Mode: 0 priority (top of the order first), 1 round robin, 2 cheapest first.</summary>
public int AttrRaiseMode;
/// <summary>Unassigned XP the raiser never spends.</summary>
public long AttrKeepXp;
/// <summary>/attr abbreviations in raise-priority order (all nine; repaired on load).</summary>
public List<string> AttrOrder = new(IltAttributeRaiser.DefaultOrder);
/// <summary>/attr abbreviations the raiser may spend on ("Raise now" and auto-raise).</summary>
public List<string> AttrRaiseStats = new();
/// <summary>Quest bonus (/qb) list filter. (The /myquests tracker's filter and favorites are RynthAi's.)</summary>
public string QbFilter = string.Empty;
// The ILT sections are Mini Remote tabs now (HudState.MiniRemoteTab); the old per-section
// "window open" flags in older files are ignored on load.
/// <summary>
/// Registry charms this character has carried, keyed by charm name. Lets the Charms Tracking
/// tab report "acquired" for charms that are now in storage (the client only sees carried items).
/// </summary>
public Dictionary<string, IltCharmSeen> CharmsSeen = new(StringComparer.OrdinalIgnoreCase);
}
/// <summary>Last time a charm was seen in the character's possession, with its best tier.</summary>
public sealed class IltCharmSeen
{
public int Tier;
public int MaxTier;
public DateTime LastSeenUtc;
}
public sealed class IltItemConversion
{
public string ItemName = string.Empty;
public int ItemsPerConversion = 100;
public int CoinsPerConversion;
}
// ── Gear ────────────────────────────────────────────────────────────────────
public sealed class IltGearState
{
// Dispel (Rune of Dispel on harmful debuffs)
public bool AutoDispel;
public int DispelCooldownSeconds = 10;
/// <summary>Spell-name substrings that are ALWAYS dispelled.</summary>
public List<string> DispelInclusions = new();
/// <summary>Spell-name substrings that are NEVER dispelled.</summary>
public List<string> DispelExclusions = new();
// Surging Strength (Empowered Volcanic Ember keeper)
public bool SurgingStrength;
public int SurgingCooldownSeconds = 15;
// Aetheria / corrupted-weapon chunking
public bool AutoChunkAetheria;
public bool AutoChunkCorrupted;
public bool ChunkInCombat;
public int ChunkIntervalMs = 2000;
/// <summary>
/// Only chunk aetheria whose max level is below this (Coalesced Aetheria too). Infinite Leaftide
/// aetheria goes up to level <see cref="IltInventory.AetheriaMaxLevel"/>, so the cap runs to one past it.
/// </summary>
public int ChunkAetheriaUnderLevel = 4;
/// <summary>Never chunk aetheria carrying a Crit rating (C, GearCrit 372; ILT tier-10 sigils of level 6+).</summary>
public bool KeepAetheriaWithCrit = true;
/// <summary>Never chunk aetheria carrying a Crit Damage rating (CD, GearCritDamage 374).</summary>
public bool KeepAetheriaWithCritDamage = true;
/// <summary>Never chunk aetheria carrying a Crit Damage Resist rating (CDR, GearCritDamageResist 375).</summary>
public bool KeepAetheriaWithCritDamageResist = true;
/// <summary>
/// Rating level for the C / CD / CDR keep switches: a rating at or above this keeps the piece,
/// a lower one does not protect it (it chunks if the other rules allow). 1 = any rating keeps.
/// </summary>
public int KeepAetheriaRatingAtLeast = 1;
// Corrupted-weapon keep rules (ub-IT IdleActs > Corr Chunk). All off by default, as in ub-IT:
// the hard rules (unmodified, workmanship, cleaving, never-chunk) always apply on top.
/// <summary>Never chunk a corrupted weapon with Crushing Blow (CriticalFrequency float 147 &gt; 0).</summary>
public bool KeepCorruptedCrushingBlow;
/// <summary>Never chunk a corrupted weapon with Biting Strike (CriticalMultiplier float 136 &gt; 0).</summary>
public bool KeepCorruptedBitingStrike;
/// <summary>Never chunk a corrupted weapon with Armor Cleaving (IgnoreArmor float 155 &gt; 0).</summary>
public bool KeepCorruptedArmorCleaving;
/// <summary>Never chunk a corrupted weapon with any slayer (SlayerCreatureType int 166 &gt; 0).</summary>
public bool KeepCorruptedAnySlayer;
/// <summary>Never chunk a multi-strike corrupted weapon (AttackType int 47 = 160 / 166 / 486).</summary>
public bool KeepCorruptedMultiStrike;
/// <summary>Never chunk a corrupted weapon with an elemental damage bonus (int 204 &gt; 0).</summary>
public bool KeepCorruptedElementalBonus;
/// <summary>Never chunk a corrupted weapon with any spell on it.</summary>
public bool KeepCorruptedAnySpell;
/// <summary>Never chunk a corrupted weapon whose max damage (int 44) is at least this. 0 = off.</summary>
public int KeepCorruptedMaxDamageAtLeast;
/// <summary>Spell ids (comma / space separated): never chunk a corrupted weapon carrying any of them.</summary>
public string KeepCorruptedSpellIds = "";
// Auto-clap (/clap all)
public bool AutoClap;
public int ClapIntervalMinutes = 30;
// Guardian Hand charm (WCID unpublished — name match until set)
public uint GuardianHandWcid;
public string GuardianHandName = "Guardian Hand";
// Split arrows (White Quartz imbue on missile weapons)
public int SplitArrowTarget = 3;
public bool SplitIgnoreImbued = true;
// Equipment profiles (.utl suits). (The VTank .usd import path is RynthAi's: the importer stayed there.)
public string LastEquipProfile = string.Empty;
// Rings inscription chain (IltRingChainRunner; SilentKelpie's, moved from RynthAi's Crafting tab)
/// <summary>Recipe id (IltRingChain.Recipes) to how many times to craft it. Pump thread only.</summary>
public Dictionary<string, int> RingRuns = new(StringComparer.OrdinalIgnoreCase);
/// <summary>Answer the server's craft dialog Yes for the queued combines (engine API v85).</summary>
public bool RingAnswerCraftDialog = true;
/// <summary>Craft and inscribe in combat mode too (servers with combat-mode crafting).</summary>
public bool RingAllowInCombat;
}
// ── Games ───────────────────────────────────────────────────────────────────
public sealed class IltGamesState
{
public long BlackjackBet = 1_000_000;
public long FellowshipBlackjackBet = 1_000_000;
public int PowerballQuantity = 1;
}
// ── Guardian (Temple of Enlightenment) ──────────────────────────────────────
public sealed class IltGuardianState
{
/// <summary>Translate incoming guardian tells and show the answer (Guardian window + Mini Remote).</summary>
public bool AutoDetectFromChat = true;
/// <summary>After a chat answer, give the item to the guardian automatically.</summary>
public bool AutoHandIn;
/// <summary>Temple guardian only: buy one of the item from the nearest vendor when none is carried.</summary>
public bool BuyMissingFromVendor = true;
/// <summary>Assumed attribute turn-in cooldown when only /qb wait stamps are known (hours).</summary>
public int CooldownHoursAssumed = 20;
/// <summary>Turn-ins counted from /qb wait-stamp transitions, keyed by attribute (fallback when /myquests lacks the flag).</summary>
public Dictionary<string, int> TurnInCounts = new(StringComparer.OrdinalIgnoreCase);
/// <summary>Estimated end of each attribute's cooldown (UTC), keyed by attribute (same fallback).</summary>
public Dictionary<string, DateTime> CooldownUntilUtc = new(StringComparer.OrdinalIgnoreCase);
}