mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-18 06:34:19 +01:00
Add ResourceTree ipc structure
This commit is contained in:
parent
0f03e0484c
commit
d647a62e82
4 changed files with 15 additions and 10 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1fa1839aef7ddd4a90f53e9642403f950579c2eb
|
Subproject commit 3567cf225b469dd5bb5f723e96e2abaaa4d16a1c
|
||||||
|
|
@ -1075,7 +1075,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
return resDictionaries.AsReadOnly();
|
return resDictionaries.AsReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Ipc.ResourceNode>?[] GetGameObjectResourceTrees(bool withUIData, params ushort[] gameObjects)
|
public Ipc.ResourceTree?[] GetGameObjectResourceTrees(bool withUIData, params ushort[] gameObjects)
|
||||||
{
|
{
|
||||||
var characters = gameObjects.Select(index => _dalamud.Objects[index]).OfType<Character>();
|
var characters = gameObjects.Select(index => _dalamud.Objects[index]).OfType<Character>();
|
||||||
var resourceTrees = _resourceTreeFactory.FromCharacters(characters, withUIData ? ResourceTreeFactory.Flags.WithUiData : 0);
|
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);
|
return Array.ConvertAll(gameObjects, obj => resDictionary.TryGetValue(obj, out var nodes) ? nodes : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IReadOnlyDictionary<ushort, IEnumerable<Ipc.ResourceNode>> GetPlayerResourceTrees(bool withUIData)
|
public IReadOnlyDictionary<ushort, Ipc.ResourceTree> GetPlayerResourceTrees(bool withUIData)
|
||||||
{
|
{
|
||||||
var resourceTrees = _resourceTreeFactory.FromObjectTable(ResourceTreeFactory.Flags.LocalPlayerRelatedOnly
|
var resourceTrees = _resourceTreeFactory.FromObjectTable(ResourceTreeFactory.Flags.LocalPlayerRelatedOnly
|
||||||
| (withUIData ? ResourceTreeFactory.Flags.WithUiData : 0));
|
| (withUIData ? ResourceTreeFactory.Flags.WithUiData : 0));
|
||||||
|
|
|
||||||
|
|
@ -130,8 +130,8 @@ public class PenumbraIpcProviders : IDisposable
|
||||||
FuncProvider<ResourceType, bool, IReadOnlyDictionary<ushort, IReadOnlyDictionary<nint, (string, string, ChangedItemIcon)>>>
|
FuncProvider<ResourceType, bool, IReadOnlyDictionary<ushort, IReadOnlyDictionary<nint, (string, string, ChangedItemIcon)>>>
|
||||||
GetPlayerResourcesOfType;
|
GetPlayerResourcesOfType;
|
||||||
|
|
||||||
internal readonly FuncProvider<bool, ushort[], IEnumerable<Ipc.ResourceNode>?[]> GetGameObjectResourceTrees;
|
internal readonly FuncProvider<bool, ushort[], Ipc.ResourceTree?[]> GetGameObjectResourceTrees;
|
||||||
internal readonly FuncProvider<bool, IReadOnlyDictionary<ushort, IEnumerable<Ipc.ResourceNode>>> GetPlayerResourceTrees;
|
internal readonly FuncProvider<bool, IReadOnlyDictionary<ushort, Ipc.ResourceTree>> GetPlayerResourceTrees;
|
||||||
|
|
||||||
public PenumbraIpcProviders(DalamudServices dalamud, IPenumbraApi api, ModManager modManager, CollectionManager collections,
|
public PenumbraIpcProviders(DalamudServices dalamud, IPenumbraApi api, ModManager modManager, CollectionManager collections,
|
||||||
TempModManager tempMods, TempCollectionManager tempCollections, SaveService saveService, Configuration config)
|
TempModManager tempMods, TempCollectionManager tempCollections, SaveService saveService, Configuration config)
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ internal static class ResourceTreeApiHelper
|
||||||
pair => (IReadOnlyDictionary<nint, (string, string, ChangedItemIcon)>)pair.Value.AsReadOnly());
|
pair => (IReadOnlyDictionary<nint, (string, string, ChangedItemIcon)>)pair.Value.AsReadOnly());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<ushort, IEnumerable<Ipc.ResourceNode>> EncapsulateResourceTrees(IEnumerable<(Character, ResourceTree)> resourceTrees)
|
public static Dictionary<ushort, Ipc.ResourceTree> EncapsulateResourceTrees(IEnumerable<(Character, ResourceTree)> resourceTrees)
|
||||||
{
|
{
|
||||||
static Ipc.ResourceNode GetIpcNode(ResourceNode node) =>
|
static Ipc.ResourceNode GetIpcNode(ResourceNode node) =>
|
||||||
new()
|
new()
|
||||||
|
|
@ -89,16 +89,21 @@ internal static class ResourceTreeApiHelper
|
||||||
Children = node.Children.Select(GetIpcNode).ToArray(),
|
Children = node.Children.Select(GetIpcNode).ToArray(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static IEnumerable<Ipc.ResourceNode> GetIpcNodes(ResourceTree tree) =>
|
static Ipc.ResourceTree GetIpcTree(ResourceTree tree) =>
|
||||||
tree.Nodes.Select(GetIpcNode).ToArray();
|
new()
|
||||||
|
{
|
||||||
|
Name = tree.Name,
|
||||||
|
RaceCode = (ushort)tree.RaceCode,
|
||||||
|
Nodes = tree.Nodes.Select(GetIpcNode).ToArray(),
|
||||||
|
};
|
||||||
|
|
||||||
var resDictionary = new Dictionary<ushort, IEnumerable<Ipc.ResourceNode>>(4);
|
var resDictionary = new Dictionary<ushort, Ipc.ResourceTree>(4);
|
||||||
foreach (var (gameObject, resourceTree) in resourceTrees)
|
foreach (var (gameObject, resourceTree) in resourceTrees)
|
||||||
{
|
{
|
||||||
if (resDictionary.ContainsKey(gameObject.ObjectIndex))
|
if (resDictionary.ContainsKey(gameObject.ObjectIndex))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
resDictionary.Add(gameObject.ObjectIndex, GetIpcNodes(resourceTree));
|
resDictionary.Add(gameObject.ObjectIndex, GetIpcTree(resourceTree));
|
||||||
}
|
}
|
||||||
|
|
||||||
return resDictionary;
|
return resDictionary;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue