namespace Aeshnidae.SkillMastery;
///
/// The skills panel for the HUD feed.
///
/// The feed itself - the /hud switch, who is listening, the wire contract - is
/// Aeshnidae.Hud; this mod is one provider. HudFeed.cs is the verbatim copy of that
/// mod's Feed.cs (cross-mod types are unsafe, ACE's are not), and /hud-skills is the
/// command the Hud mod invokes when a session turns the feed on or asks for a sync.
///
public static class Hud
{
/// Re-send every panel this mod owns, if the session is listening.
public static void Refresh(Player? player)
{
try
{
if (player?.Session is null || !HudFeed.IsOn(player))
return;
HudFeed.Send(player.Session, SkillsPanel(player));
}
catch (Exception ex)
{
ModManager.Log($"[{Mod.Name}] hud refresh failed: {ex}", ModManager.LogLevel.Warn);
}
}
///
/// Ask Aeshnidae.Hud to re-send every provider's panel - ours and the bank's, since a
/// raise changes both. Goes through ACE's command registry because the Hud mod's
/// types are out of reach; if that mod is not loaded, falls back to our own panel.
///
public static void RefreshAll(Session session)
{
if (session.Player is null || !HudFeed.IsOn(session.Player))
return;
var hud = CommandManager.GetCommandByName("hud").FirstOrDefault();
if (hud is null)
{
Refresh(session.Player);
return;
}
try
{
((CommandHandler)hud.Handler)(session, "sync");
}
catch (Exception ex)
{
ModManager.Log($"[{Mod.Name}] hud sync failed: {ex}", ModManager.LogLevel.Warn);
}
}
///
/// The skills panel: every trained or specialized skill with what the client
/// already shows (base, current) beside what it cannot know - the Radiance points
/// bought into it and what the next one costs. Rows the balance can afford are
/// coloured, so the answer to "what can I raise right now" is visible at a glance.
///
public static object SkillsPanel(Player player)
{
var balance = player.Account is null ? 0 : MasteryDb.RadianceBalance(player.Account.AccountId);
var rows = new List