using System.Linq;
using Dalamud.Plugin;
using Newtonsoft.Json.Linq;
using Penumbra.Api.Api;
using Penumbra.Api.Enums;
using Penumbra.Api.Helpers;
namespace Penumbra.Api.IpcSubscribers;
///
public sealed class GetGameObjectResourcePaths(IDalamudPluginInterface pi)
: FuncSubscriber>?[]>(pi, Label)
{
/// The label.
public const string Label = $"Penumbra.{nameof(GetGameObjectResourcePaths)}.V5";
///
public new Dictionary>?[] Invoke(params ushort[] gameObjectIndices)
=> base.Invoke(gameObjectIndices);
/// Create a provider.
public static FuncProvider>?[]> Provider(IDalamudPluginInterface pi,
IPenumbraApiResourceTree api)
=> new(pi, Label, api.GetGameObjectResourcePaths);
}
///
public sealed class GetPlayerResourcePaths(IDalamudPluginInterface pi)
: FuncSubscriber>>>(pi, Label)
{
/// The label.
public const string Label = $"Penumbra.{nameof(GetPlayerResourcePaths)}.V5";
///
public new Dictionary>> Invoke()
=> base.Invoke();
/// Create a provider.
public static FuncProvider>>> Provider(IDalamudPluginInterface pi,
IPenumbraApiResourceTree api)
=> new(pi, Label, api.GetPlayerResourcePaths);
}
///
public sealed class GetGameObjectResourcesOfType(IDalamudPluginInterface pi)
: FuncSubscriber?[]>(pi, Label)
{
/// The label.
public const string Label = $"Penumbra.{nameof(GetGameObjectResourcesOfType)}.V5";
///
public IReadOnlyDictionary?[] Invoke(ResourceType type, bool withUiData = false,
params ushort[] gameObjectIndices)
=> Array.ConvertAll(Invoke((uint)type, withUiData, gameObjectIndices),
d => (IReadOnlyDictionary?)GameResourceDict.Create(d));
/// Create a provider.
public static FuncProvider?[]> Provider(IDalamudPluginInterface pi,
IPenumbraApiResourceTree api)
=> new(pi, Label,
(a, b, c) => Array.ConvertAll(api.GetGameObjectResourcesOfType((ResourceType)a, b, c), d => d?.Original));
}
///
public sealed class GetPlayerResourcesOfType(IDalamudPluginInterface pi)
: FuncSubscriber>>(pi, Label)
{
/// The label.
public const string Label = $"Penumbra.{nameof(GetPlayerResourcesOfType)}.V5";
///
public Dictionary> Invoke(ResourceType type, bool withUiData = false)
=> Invoke((uint)type, withUiData)
.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyDictionary)new GameResourceDict(kvp.Value));
/// Create a provider.
public static FuncProvider>> Provider(
IDalamudPluginInterface pi,
IPenumbraApiResourceTree api)
=> new(pi, Label,
(a, b) => api.GetPlayerResourcesOfType((ResourceType)a, b)
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Original));
}
///
public sealed class GetGameObjectResourceTrees(IDalamudPluginInterface pi)
: FuncSubscriber(pi, Label)
{
/// The label.
public const string Label = $"Penumbra.{nameof(GetGameObjectResourceTrees)}.V5";
///
public new ResourceTreeDto?[] Invoke(bool withUiData = false, params ushort[] gameObjectIndices)
=> Array.ConvertAll(base.Invoke(withUiData, gameObjectIndices), o => o?.ToObject());
/// Create a provider.
public static FuncProvider Provider(IDalamudPluginInterface pi,
IPenumbraApiResourceTree api)
=> new(pi, Label, api.GetGameObjectResourceTrees);
}
///
public sealed class GetPlayerResourceTrees(IDalamudPluginInterface pi)
: FuncSubscriber>(pi, Label)
{
/// The label.
public const string Label = $"Penumbra.{nameof(GetPlayerResourceTrees)}.V5";
///
public new Dictionary Invoke(bool withUiData = false)
=> base.Invoke(withUiData).ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToObject()!);
/// Create a provider.
public static FuncProvider> Provider(IDalamudPluginInterface pi, IPenumbraApiResourceTree api)
=> new(pi, Label, api.GetPlayerResourceTrees);
}