using Dalamud.Plugin;
using Penumbra.Api.Api;
using Penumbra.Api.Helpers;
namespace Penumbra.Api.IpcSubscribers;
/// Triggered when the Penumbra API is initialized and ready.
public static class Initialized
{
/// The label.
public const string Label = $"Penumbra.{nameof(Initialized)}";
/// Create a new event subscriber.
public static EventSubscriber Subscriber(IDalamudPluginInterface pi, params Action[] actions)
=> new(pi, Label, actions);
/// Create a provider.
public static EventProvider Provider(IDalamudPluginInterface pi)
=> new(pi, Label);
}
/// Triggered when the Penumbra API is fully disposed and unavailable.
public static class Disposed
{
/// The label.
public const string Label = $"Penumbra.{nameof(Disposed)}";
/// Create a new event subscriber.
public static EventSubscriber Subscriber(IDalamudPluginInterface pi, params Action[] actions)
=> new(pi, Label, actions);
/// Create a provider.
public static EventProvider Provider(IDalamudPluginInterface pi)
=> new(pi, Label);
}
///
public class ApiVersion(IDalamudPluginInterface pi)
: FuncSubscriber<(int Breaking, int Features)>(pi, Label)
{
/// The label.
public const string Label = $"Penumbra.{nameof(ApiVersion)}.V5";
///
public new (int Breaking, int Features) Invoke()
=> base.Invoke();
/// Create a provider.
public static FuncProvider<(int Breaking, int Features)> Provider(IDalamudPluginInterface pi, IPenumbraApiBase api)
=> new(pi, Label, () => api.ApiVersion);
}
///
public class GetModDirectory(IDalamudPluginInterface pi)
: FuncSubscriber(pi, Label)
{
/// The label.
public const string Label = $"Penumbra.{nameof(GetModDirectory)}";
///
public new string Invoke()
=> base.Invoke();
/// Create a provider.
public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiPluginState api)
=> new(pi, Label, api.GetModDirectory);
}
///
public class GetConfiguration(IDalamudPluginInterface pi)
: FuncSubscriber(pi, Label)
{
/// The label.
public const string Label = $"Penumbra.{nameof(GetConfiguration)}";
///
public new string Invoke()
=> base.Invoke();
/// Create a provider.
public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiPluginState api)
=> new(pi, Label, api.GetConfiguration);
}
///
public static class ModDirectoryChanged
{
/// The label.
public const string Label = $"Penumbra.{nameof(ModDirectoryChanged)}";
/// Create a new event subscriber.
public static EventSubscriber Subscriber(IDalamudPluginInterface pi, params Action[] actions)
=> new(pi, Label, actions);
/// Create a provider.
public static EventProvider Provider(IDalamudPluginInterface pi, IPenumbraApiPluginState api)
=> new(pi, Label, (t => api.ModDirectoryChanged += t, t => api.ModDirectoryChanged -= t));
}
///
public class GetEnabledState(IDalamudPluginInterface pi)
: FuncSubscriber(pi, Label)
{
public const string Label = $"Penumbra.{nameof(GetEnabledState)}";
///
public new bool Invoke()
=> base.Invoke();
/// Create a provider.
public static FuncProvider Provider(IDalamudPluginInterface pi, IPenumbraApiPluginState api)
=> new(pi, Label, api.GetEnabledState);
}
///
public static class EnabledChange
{
/// The label.
public const string Label = $"Penumbra.{nameof(EnabledChange)}";
/// Create a new event subscriber.
public static EventSubscriber Subscriber(IDalamudPluginInterface pi, params Action[] actions)
=> new(pi, Label, actions);
/// Create a provider.
public static EventProvider Provider(IDalamudPluginInterface pi, IPenumbraApiPluginState api)
=> new(pi, Label, (t => api.EnabledChange += t, t => api.EnabledChange -= t));
}