// ============================================================================
// RynthSuite - Plugins/Shared/RynthIltHubApi.cs
// The "RynthILT.Hub" interface: RynthILT's Infinite Leaftide features as RynthAi's
// Mini Remote shows them. The Mini Remote stays RynthAi's (its window, tab bar,
// Remote tab, Quests and Pets tabs); RynthILT supplies the ILT tabs (Character,
// Banking, Gear, Charms, Games), a few ILT sections drawn inside RynthAi's
// surfaces, the server's ILT feature bits and the "/ra hub ..." ILT verbs.
// Compiled into both plugins (linked source), so the layout can't drift.
//
// Rules (as the RynthAi.* interfaces, Shared/RynthAiScriptApi.cs):
// - Append-only: new functions go at the end, and Version goes up.
// - Strings are UTF-8, NUL-terminated.
// - Threads: each function says where it may be called. The render-thread ones
// draw into the caller's current ImGui window and context (the engine's cimgui,
// shared by both plugins).
// - Every function returns safely (no exception crosses the boundary), and returns
// 0 / "unknown" once RynthILT has shut down.
// - The table is allocated once per loaded copy of RynthILT and never freed: its
// functions stay callable from the render thread while plugins shut down (a
// plugin DLL is never unloaded, see the engine's PluginManager.PluginsUnloaded).
// Shutdown sets Version to 0; a caller re-queries (host GetPluginInterface)
// when it sees that, after a plugin reload, or every few seconds.
// ============================================================================
using System.Runtime.InteropServices;
namespace RynthCore.Plugin.Shared;
/// Constants of the "RynthILT.Hub" interface.
public static class RynthIltHub
{
/// The providing plugin's display name.
public const string PluginName = "RynthILT";
/// Tab flag: the Mini Remote shows this tab now (an ILT world, or forced, and the tab is usable).
public const uint TabShown = 1;
/// Tab flag: the server reports the tab's feature on (Character is always available).
public const uint TabAvailable = 2;
// Sections RynthAi draws through RenderSection (each draws nothing off ILT).
/// Remote tab, Bank section: the ILT bank balances.
public const string SectionRemoteBank = "remote-bank";
/// Remote tab, Guardian line: the Temple guardian's last answer.
public const string SectionRemoteGuardian = "remote-guardian";
/// Quests tab: the "Quest bonus (/qb)" list.
public const string SectionQuestBonus = "quests-qb";
/// Pets tab: the /pets and /shinies logs.
public const string SectionPetLogs = "pets-logs";
/// Pets tab, Breeding sub-tab: the pet breeding tracker (RynthILT 0.2.7+; older copies draw nothing).
public const string SectionPetBreeding = "pets-breeding";
/// Mini Remote menu, under Infinite Leaftide: why no ILT feature is on, the Force-ILT override, Refresh.
public const string SectionIltStatus = "ilt-status";
/// Mini Remote menu without RynthCore's server list: RynthILT's own Infinite Leaftide items.
public const string SectionServerMenu = "server-menu";
/// Feature keys RynthAi reads (GetFeature).
public const string FeatureQuests = "quests";
public const string FeaturePetRefill = "pet_refill";
public const string FeatureUniversalMastery = "universal_mastery";
/// ACECustom siphon lenses (monster capture into a pet essence).
public const string FeatureMonsterCapture = "monster_capture";
public const string FeatureRequireComps = "require_spell_comps";
/// Pet breeding (the Pets tab's Breeding sub-tab is hidden while the server reports it off).
public const string FeaturePetBreeding = "pet_breeding";
}
/// One ILT tab as GetTabs hands it out. Blittable.
[StructLayout(LayoutKind.Sequential)]
public unsafe struct IltTabV1
{
/// The tab id (UTF-8, NUL-terminated): saved as the Mini Remote's tab, "/ra hub open <id>".
public fixed byte Id[24];
/// The tab bar label (UTF-8, NUL-terminated).
public fixed byte Label[32];
/// The size of the tab body (the child it draws in).
public float Width;
public float Height;
/// RynthIltHub.Tab* bits.
public uint Flags;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct RynthIltHubApiV1
{
public const string InterfaceName = "RynthILT.Hub";
public const uint InterfaceVersion = 1;
public uint Version; // InterfaceVersion of the table RynthILT filled; 0 once it has shut down
public uint StructSize; // sizeof(RynthIltHubApiV1) as RynthILT built it
/// IsIltWorld(): 1 when this world is Infinite Leaftide / ACECustom (or forced). Any thread.
public delegate* unmanaged[Cdecl] IsIltWorld;
/// GetFeature(key): the server's bit for a feature, -1 unknown, 0 off, 1 on (-1 off ILT). Any thread.
public delegate* unmanaged[Cdecl] GetFeature;
/// GetRates(coinsPerHour, pyrealsPerHour): ILT session rates; 0 (nothing written) off ILT. Any thread.
public delegate* unmanaged[Cdecl] GetRates;
/// GetForceIlt(): this character's "Treat this world as ILT" override (1 on). Any thread.
public delegate* unmanaged[Cdecl] GetForceIlt;
/// SetForceIlt(on): sets that override. Any thread (applied and saved on RynthILT's next tick).
public delegate* unmanaged[Cdecl] SetForceIlt;
///
/// GetTabs(tabs, capacity): every ILT tab in tab-bar order with its flags. Writes up to
/// capacity, returns how many there are (tabs null: just the count). Render thread.
///
public delegate* unmanaged[Cdecl] GetTabs;
/// RenderTab(id): draws that tab's body into the current (child) window; 1 = drawn. Render thread.
public delegate* unmanaged[Cdecl] RenderTab;
/// RenderSection(id): draws a RynthIltHub.Section* into the current window; 1 = drawn. Render thread.
public delegate* unmanaged[Cdecl] RenderSection;
///
/// Command(text): one of the ILT "/ra" verbs, as typed after "/ra" ("hub bank", "hub attr run",
/// "guardian handin", "bounty show", "rates reset"). RynthILT answers in chat itself.
/// 1 = handled, 0 = not an ILT verb. Pump thread.
///
public delegate* unmanaged[Cdecl] Command;
}