diff --git a/Penumbra.Api b/Penumbra.Api index 1fa1839a..3567cf22 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 1fa1839aef7ddd4a90f53e9642403f950579c2eb +Subproject commit 3567cf225b469dd5bb5f723e96e2abaaa4d16a1c diff --git a/Penumbra/Api/PenumbraApi.cs b/Penumbra/Api/PenumbraApi.cs index 1e79099c..8974e823 100644 --- a/Penumbra/Api/PenumbraApi.cs +++ b/Penumbra/Api/PenumbraApi.cs @@ -1075,7 +1075,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi return resDictionaries.AsReadOnly(); } - public IEnumerable?[] GetGameObjectResourceTrees(bool withUIData, params ushort[] gameObjects) + public Ipc.ResourceTree?[] GetGameObjectResourceTrees(bool withUIData, params ushort[] gameObjects) { var characters = gameObjects.Select(index => _dalamud.Objects[index]).OfType(); var resourceTrees = _resourceTreeFactory.FromCharacters(characters, withUIData ? ResourceTreeFactory.Flags.WithUiData : 0); @@ -1084,7 +1084,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi return Array.ConvertAll(gameObjects, obj => resDictionary.TryGetValue(obj, out var nodes) ? nodes : null); } - public IReadOnlyDictionary> GetPlayerResourceTrees(bool withUIData) + public IReadOnlyDictionary GetPlayerResourceTrees(bool withUIData) { var resourceTrees = _resourceTreeFactory.FromObjectTable(ResourceTreeFactory.Flags.LocalPlayerRelatedOnly | (withUIData ? ResourceTreeFactory.Flags.WithUiData : 0)); diff --git a/Penumbra/Api/PenumbraIpcProviders.cs b/Penumbra/Api/PenumbraIpcProviders.cs index 9f1e79b9..10980f98 100644 --- a/Penumbra/Api/PenumbraIpcProviders.cs +++ b/Penumbra/Api/PenumbraIpcProviders.cs @@ -130,8 +130,8 @@ public class PenumbraIpcProviders : IDisposable FuncProvider>> GetPlayerResourcesOfType; - internal readonly FuncProvider?[]> GetGameObjectResourceTrees; - internal readonly FuncProvider>> GetPlayerResourceTrees; + internal readonly FuncProvider GetGameObjectResourceTrees; + internal readonly FuncProvider> GetPlayerResourceTrees; public PenumbraIpcProviders(DalamudServices dalamud, IPenumbraApi api, ModManager modManager, CollectionManager collections, TempModManager tempMods, TempCollectionManager tempCollections, SaveService saveService, Configuration config) diff --git a/Penumbra/Interop/ResourceTree/ResourceTreeApiHelper.cs b/Penumbra/Interop/ResourceTree/ResourceTreeApiHelper.cs index 02e0f380..df34c51a 100644 --- a/Penumbra/Interop/ResourceTree/ResourceTreeApiHelper.cs +++ b/Penumbra/Interop/ResourceTree/ResourceTreeApiHelper.cs @@ -74,7 +74,7 @@ internal static class ResourceTreeApiHelper pair => (IReadOnlyDictionary)pair.Value.AsReadOnly()); } - public static Dictionary> EncapsulateResourceTrees(IEnumerable<(Character, ResourceTree)> resourceTrees) + public static Dictionary EncapsulateResourceTrees(IEnumerable<(Character, ResourceTree)> resourceTrees) { static Ipc.ResourceNode GetIpcNode(ResourceNode node) => new() @@ -89,16 +89,21 @@ internal static class ResourceTreeApiHelper Children = node.Children.Select(GetIpcNode).ToArray(), }; - static IEnumerable GetIpcNodes(ResourceTree tree) => - tree.Nodes.Select(GetIpcNode).ToArray(); + static Ipc.ResourceTree GetIpcTree(ResourceTree tree) => + new() + { + Name = tree.Name, + RaceCode = (ushort)tree.RaceCode, + Nodes = tree.Nodes.Select(GetIpcNode).ToArray(), + }; - var resDictionary = new Dictionary>(4); + var resDictionary = new Dictionary(4); foreach (var (gameObject, resourceTree) in resourceTrees) { if (resDictionary.ContainsKey(gameObject.ObjectIndex)) continue; - resDictionary.Add(gameObject.ObjectIndex, GetIpcNodes(resourceTree)); + resDictionary.Add(gameObject.ObjectIndex, GetIpcTree(resourceTree)); } return resDictionary;