using AcDream.Plugin.Abstractions;
namespace AcDream.Plugins.MossTank;
///
/// MossTank — a self-buffing plugin, and the first consumer of acdream's
/// plugin automation surface.
///
///
/// Named for the mosswart, and for the Virindi Tank lineage this milestone is
/// modelled on. The buff policy lives here rather than in the host on purpose:
/// the host publishes spell data and a cast primitive, the plugin decides what
/// to cast. See docs/research/2026-07-29-vtank-plugin-automation-requirements.md.
///
public sealed class MossTankPlugin : IAcDreamPlugin
{
private IPluginHost? _host;
private MossTankPanel? _panel;
private Action? _tick;
public void Initialize(IPluginHost host)
{
_host = host;
_panel = new MossTankPanel(host);
host.Log.Info("MossTank initialized");
}
public void Enable()
{
if (_host is null || _panel is null)
return;
// Markup ships beside the plugin assembly, so it is found relative to
// this DLL rather than the host's working directory -- plugins are
// loaded from their own directory and the two are not the same.
string directory =
Path.GetDirectoryName(typeof(MossTankPlugin).Assembly.Location) ?? ".";
// Two panels with complementary visible bindings stand in for a tab
// control: only one is ever on screen, and switching is just an Action.
_host.Ui.AddMarkupPanel(Path.Combine(directory, "mosstank.xml"), _panel);
_host.Ui.AddMarkupPanel(Path.Combine(directory, "mosstank-settings.xml"), _panel);
_tick = _panel.OnTick;
_host.Events.Tick += _tick;
_host.Log.Info(
_host.Automation.IsAvailable
? "MossTank enabled"
: "MossTank enabled (no live session yet; the Buff button will "
+ "report 'Not in world' until one is up)");
}
public void Disable()
{
if (_host is not null && _tick is not null)
_host.Events.Tick -= _tick;
_tick = null;
_host?.Log.Info("MossTank disabled");
}
}