using Dalamud.Plugin; using Glamourer.Api.Api; using Glamourer.Api.Enums; using Glamourer.Api.Helpers; using Newtonsoft.Json.Linq; namespace Glamourer.Api.IpcSubscribers; /// public sealed class GetState(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(GetState)}"; /// public new (GlamourerApiEc, JObject?) Invoke(int objectIndex, uint key = 0) { var (ec, data) = base.Invoke(objectIndex, key); return ((GlamourerApiEc)ec, data); } /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b) => { var (ec, data) = api.GetState(a, b); return ((int)ec, data); }); } /// public sealed class GetStateName(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(GetStateName)}"; /// public new (GlamourerApiEc, JObject?) Invoke(string objectName, uint key = 0) { var (ec, data) = base.Invoke(objectName, key); return ((GlamourerApiEc)ec, data); } /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (i, k) => { var (ec, data) = api.GetStateName(i, k); return ((int)ec, data); }); } /// public sealed class GetStateBase64(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(GetStateBase64)}"; /// public new (GlamourerApiEc, string?) Invoke(int objectIndex, uint key = 0) { var (ec, data) = base.Invoke(objectIndex, key); return ((GlamourerApiEc)ec, data); } /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b) => { var (ec, data) = api.GetStateBase64(a, b); return ((int)ec, data); }); } /// public sealed class GetStateBase64Name(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(GetStateBase64Name)}"; /// public new (GlamourerApiEc, string?) Invoke(string objectName, uint key = 0) { var (ec, data) = base.Invoke(objectName, key); return ((GlamourerApiEc)ec, data); } /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (i, k) => { var (ec, data) = api.GetStateBase64Name(i, k); return ((int)ec, data); }); } /// public sealed class ApplyState(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(ApplyState)}"; /// public GlamourerApiEc Invoke(JObject state, int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault) => (GlamourerApiEc)Invoke(state, objectIndex, key, (ulong)flags); /// public GlamourerApiEc Invoke(string base64State, int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault) => (GlamourerApiEc)Invoke(base64State, objectIndex, key, (ulong)flags); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b, c, d) => (int)api.ApplyState(a, b, c, (ApplyFlag)d)); } /// public sealed class ApplyStateName(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(ApplyStateName)}"; /// public GlamourerApiEc Invoke(JObject state, string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault) => (GlamourerApiEc)Invoke(state, objectName, key, (ulong)flags); /// public GlamourerApiEc Invoke(string base64State, string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault) => (GlamourerApiEc)Invoke(base64State, objectName, key, (ulong)flags); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b, c, d) => (int)api.ApplyStateName(a, b, c, (ApplyFlag)d)); } /// public sealed class RevertState(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(RevertState)}"; /// public GlamourerApiEc Invoke(int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault) => (GlamourerApiEc)Invoke(objectIndex, key, (ulong)flags); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b, c) => (int)api.RevertState(a, b, (ApplyFlag)c)); } /// public sealed class RevertStateName(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(RevertStateName)}"; /// public GlamourerApiEc Invoke(string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault) => (GlamourerApiEc)Invoke(objectName, key, (ulong)flags); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b, c) => (int)api.RevertStateName(a, b, (ApplyFlag)c)); } /// public sealed class UnlockState(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(UnlockState)}"; /// public new GlamourerApiEc Invoke(int objectIndex, uint key = 0) => (GlamourerApiEc)base.Invoke(objectIndex, key); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b) => (int)api.UnlockState(a, b)); } /// public sealed class UnlockStateName(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(UnlockStateName)}"; /// public new GlamourerApiEc Invoke(string objectName, uint key = 0) => (GlamourerApiEc)base.Invoke(objectName, key); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b) => (int)api.UnlockStateName(a, b)); } /// public sealed class UnlockAll(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(UnlockAll)}"; /// public new int Invoke(uint key) => base.Invoke(key); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, api.UnlockAll); } /// public sealed class RevertToAutomation(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(RevertToAutomation)}.V2"; /// public GlamourerApiEc Invoke(int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault) => (GlamourerApiEc)Invoke(objectIndex, key, (ulong)flags); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b, c) => (int)api.RevertToAutomation(a, b, (ApplyFlag)c)); } /// public sealed class RevertToAutomationName(IDalamudPluginInterface pi) : FuncSubscriber(pi, Label) { /// The label. public const string Label = $"Glamourer.{nameof(RevertToAutomationName)}"; /// public GlamourerApiEc Invoke(string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault) => (GlamourerApiEc)Invoke(objectName, key, (ulong)flags); /// Create a provider. public static FuncProvider Provider(IDalamudPluginInterface pi, IGlamourerApiState api) => new(pi, Label, (a, b, c) => (int)api.RevertToAutomationName(a, b, (ApplyFlag)c)); } /// public static class StateChanged { /// The label. public const string Label = $"Penumbra.{nameof(StateChanged)}.V2"; /// 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, IGlamourerApiState api) => new(pi, Label, (t => api.StateChanged += t, t => api.StateChanged -= t)); } /// public static class StateChangedWithType { /// The label. public const string Label = $"Penumbra.{nameof(StateChangedWithType)}"; /// 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, IGlamourerApiState api) => new(pi, Label, (t => api.StateChangedWithType += t, t => api.StateChangedWithType -= t)); } /// public static class StateFinalized { /// The label. public const string Label = $"Penumbra.{nameof(StateFinalized)}"; /// 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, IGlamourerApiState api) => new(pi, Label, (t => api.StateFinalized += t, t => api.StateFinalized -= t)); } /// public static class GPoseChanged { /// The label. public const string Label = $"Penumbra.{nameof(GPoseChanged)}"; /// 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, IGlamourerApiState api) => new(pi, Label, (t => api.GPoseChanged += t, t => api.GPoseChanged -= t)); }