Update some Dalamud Services.

This commit is contained in:
Ottermandias 2023-08-10 18:10:26 +02:00
parent 09ca32f33d
commit af536b3423
24 changed files with 78 additions and 91 deletions

View file

@ -1,10 +1,9 @@
using System;
using System.Threading;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Hooking;
using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game.Event;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Penumbra.Collections;
using Penumbra.GameData;
@ -20,7 +19,7 @@ namespace Penumbra.Interop.PathResolving;
public unsafe class AnimationHookService : IDisposable
{
private readonly PerformanceTracker _performance;
private readonly ObjectTable _objects;
private readonly IObjectTable _objects;
private readonly CollectionResolver _collectionResolver;
private readonly DrawObjectState _drawObjectState;
private readonly CollectionResolver _resolver;
@ -29,7 +28,7 @@ public unsafe class AnimationHookService : IDisposable
private readonly ThreadLocal<ResolveData> _animationLoadData = new(() => ResolveData.Invalid, true);
private readonly ThreadLocal<ResolveData> _characterSoundData = new(() => ResolveData.Invalid, true);
public AnimationHookService(PerformanceTracker performance, ObjectTable objects, CollectionResolver collectionResolver,
public AnimationHookService(PerformanceTracker performance, IObjectTable objects, CollectionResolver collectionResolver,
DrawObjectState drawObjectState, CollectionResolver resolver, Condition conditions)
{
_performance = performance;

View file

@ -1,6 +1,5 @@
using System;
using Dalamud.Game.ClientState;
using Dalamud.Game.Gui;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Penumbra.Collections;
using Penumbra.Collections.Manager;
@ -21,8 +20,8 @@ public unsafe class CollectionResolver
private readonly IdentifiedCollectionCache _cache;
private readonly HumanModelList _humanModels;
private readonly ClientState _clientState;
private readonly GameGui _gameGui;
private readonly IClientState _clientState;
private readonly IGameGui _gameGui;
private readonly ActorService _actors;
private readonly CutsceneService _cutscenes;
@ -31,7 +30,7 @@ public unsafe class CollectionResolver
private readonly TempCollectionManager _tempCollections;
private readonly DrawObjectState _drawObjectState;
public CollectionResolver(PerformanceTracker performance, IdentifiedCollectionCache cache, ClientState clientState, GameGui gameGui,
public CollectionResolver(PerformanceTracker performance, IdentifiedCollectionCache cache, IClientState clientState, IGameGui gameGui,
ActorService actors, CutsceneService cutscenes, Configuration config, CollectionManager collectionManager,
TempCollectionManager tempCollections, DrawObjectState drawObjectState, HumanModelList humanModels)
{

View file

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using Penumbra.GameData.Actors;
using Penumbra.Interop.Services;
@ -16,7 +16,7 @@ public class CutsceneService : IDisposable
public const int CutsceneSlots = CutsceneEndIdx - CutsceneStartIdx;
private readonly GameEventManager _events;
private readonly ObjectTable _objects;
private readonly IObjectTable _objects;
private readonly short[] _copiedCharacters = Enumerable.Repeat((short)-1, CutsceneSlots).ToArray();
public IEnumerable<KeyValuePair<int, Dalamud.Game.ClientState.Objects.Types.GameObject>> Actors
@ -24,7 +24,7 @@ public class CutsceneService : IDisposable
.Where(i => _objects[i] != null)
.Select(i => KeyValuePair.Create(i, this[i] ?? _objects[i]!));
public unsafe CutsceneService(ObjectTable objects, GameEventManager events)
public unsafe CutsceneService(IObjectTable objects, GameEventManager events)
{
_objects = objects;
_events = events;

View file

@ -4,7 +4,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using Penumbra.GameData;
using Penumbra.Interop.Services;
@ -14,7 +14,7 @@ namespace Penumbra.Interop.PathResolving;
public class DrawObjectState : IDisposable, IReadOnlyDictionary<nint, (nint, bool)>
{
private readonly ObjectTable _objects;
private readonly IObjectTable _objects;
private readonly GameEventManager _gameEvents;
private readonly Dictionary<nint, (nint GameObject, bool IsChild)> _drawObjectToGameObject = new();
@ -24,7 +24,7 @@ public class DrawObjectState : IDisposable, IReadOnlyDictionary<nint, (nint, boo
public nint LastGameObject
=> _lastGameObject.IsValueCreated && _lastGameObject.Value!.Count > 0 ? _lastGameObject.Value.Peek() : nint.Zero;
public DrawObjectState(ObjectTable objects, GameEventManager gameEvents)
public DrawObjectState(IObjectTable objects, GameEventManager gameEvents)
{
SignatureHelper.Initialise(this);
_enableDrawHook.Enable();

View file

@ -1,7 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Dalamud.Game.ClientState;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using Penumbra.Collections;
@ -17,11 +17,11 @@ public unsafe class IdentifiedCollectionCache : IDisposable, IEnumerable<(nint A
{
private readonly CommunicatorService _communicator;
private readonly GameEventManager _events;
private readonly ClientState _clientState;
private readonly IClientState _clientState;
private readonly Dictionary<nint, (ActorIdentifier, ModCollection)> _cache = new(317);
private bool _dirty;
public IdentifiedCollectionCache(ClientState clientState, CommunicatorService communicator, GameEventManager events)
public IdentifiedCollectionCache(IClientState clientState, CommunicatorService communicator, GameEventManager events)
{
_clientState = clientState;
_communicator = communicator;

View file

@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Dalamud.Data;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using Penumbra.GameData.Actors;
@ -12,14 +11,14 @@ namespace Penumbra.Interop.ResourceTree;
public class ResourceTreeFactory
{
private readonly DataManager _gameData;
private readonly ObjectTable _objects;
private readonly IDataManager _gameData;
private readonly IObjectTable _objects;
private readonly CollectionResolver _collectionResolver;
private readonly IdentifierService _identifier;
private readonly Configuration _config;
private readonly ActorService _actors;
public ResourceTreeFactory(DataManager gameData, ObjectTable objects, CollectionResolver resolver, IdentifierService identifier,
public ResourceTreeFactory(IDataManager gameData, IObjectTable objects, CollectionResolver resolver, IdentifierService identifier,
Configuration config, ActorService actors)
{
_gameData = gameData;

View file

@ -2,9 +2,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Dalamud.Data;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Plugin.Services;
using Penumbra.GameData.Files;
using Penumbra.String.Classes;
@ -12,13 +11,13 @@ namespace Penumbra.Interop.ResourceTree;
internal class TreeBuildCache
{
private readonly DataManager _dataManager;
private readonly IDataManager _dataManager;
private readonly Dictionary<FullPath, MtrlFile?> _materials = new();
private readonly Dictionary<FullPath, ShpkFile?> _shaderPackages = new();
public readonly List<Character> Characters;
public readonly Dictionary<uint, Character> CharactersById;
public TreeBuildCache(ObjectTable objects, DataManager dataManager)
public TreeBuildCache(IObjectTable objects, IDataManager dataManager)
{
_dataManager = dataManager;
Characters = objects.Where(c => c is Character ch && ch.IsValid()).Cast<Character>().ToList();
@ -36,7 +35,7 @@ internal class TreeBuildCache
public ShpkFile? ReadShaderPackage(FullPath path)
=> ReadFile(_dataManager, path, _shaderPackages, bytes => new ShpkFile(bytes));
private static T? ReadFile<T>(DataManager dataManager, FullPath path, Dictionary<FullPath, T?> cache, Func<byte[], T> parseFile)
private static T? ReadFile<T>(IDataManager dataManager, FullPath path, Dictionary<FullPath, T?> cache, Func<byte[], T> parseFile)
where T : class
{
if (path.FullName.Length == 0)

View file

@ -7,12 +7,12 @@ using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Plugin.Services;
using Penumbra.Api;
using Penumbra.Api.Enums;
using Penumbra.GameData;
using Penumbra.GameData.Actors;
using Penumbra.Interop.Structs;
using Penumbra.Services;
namespace Penumbra.Interop.Services;
@ -104,8 +104,8 @@ public unsafe partial class RedrawService
public sealed unsafe partial class RedrawService : IDisposable
{
private readonly Framework _framework;
private readonly ObjectTable _objects;
private readonly TargetManager _targets;
private readonly IObjectTable _objects;
private readonly ITargetManager _targets;
private readonly Condition _conditions;
private readonly List<int> _queue = new(100);
@ -114,7 +114,7 @@ public sealed unsafe partial class RedrawService : IDisposable
public event GameObjectRedrawnDelegate? GameObjectRedrawn;
public RedrawService(Framework framework, ObjectTable objects, TargetManager targets, Condition conditions)
public RedrawService(Framework framework, IObjectTable objects, ITargetManager targets, Condition conditions)
{
_framework = framework;
_objects = objects;