Screenie/PenumbraIpc.cs

53 lines
1.9 KiB
C#

using Penumbra.Api.Helpers;
namespace Screenie;
internal class PenumbraIpc {
private Plugin Plugin { get; }
private FuncSubscriber<string> GetModDirectorySubscriber { get; }
private ParamsFuncSubscriber<ushort, IReadOnlyDictionary<string, string[]>?[]> GetGameObjectResourcePathsSubscriber { get; }
private FuncSubscriber<IReadOnlyDictionary<ushort, IReadOnlyDictionary<string, string[]>>> GetPlayerResourcePathsSubscriber { get; }
private FuncSubscriber<IList<(string, string)>> GetModsSubscriber { get; }
internal PenumbraIpc(Plugin plugin) {
this.Plugin = plugin;
this.GetModDirectorySubscriber = Penumbra.Api.Ipc.GetModDirectory.Subscriber(this.Plugin.Interface);
this.GetGameObjectResourcePathsSubscriber = Penumbra.Api.Ipc.GetGameObjectResourcePaths.Subscriber(this.Plugin.Interface);
this.GetPlayerResourcePathsSubscriber = Penumbra.Api.Ipc.GetPlayerResourcePaths.Subscriber(this.Plugin.Interface);
this.GetModsSubscriber = Penumbra.Api.Ipc.GetMods.Subscriber(this.Plugin.Interface);
}
internal string? GetModDirectory() {
try {
return this.GetModDirectorySubscriber.Invoke();
} catch {
return null;
}
}
internal IReadOnlyDictionary<string, string[]>?[]? GetGameObjectResourcePaths(params ushort[] objects) {
try {
return this.GetGameObjectResourcePathsSubscriber.Invoke(objects);
} catch {
return null;
}
}
internal IReadOnlyDictionary<ushort, IReadOnlyDictionary<string, string[]>>? GetPlayerResourcePaths() {
try {
return this.GetPlayerResourcePathsSubscriber.Invoke();
} catch {
return null;
}
}
internal IList<(string Directory, string Name)>? GetMods() {
try {
return this.GetModsSubscriber.Invoke();
} catch {
return null;
}
}
}