mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Get rid of last statics.
This commit is contained in:
parent
826777b7ee
commit
e66d666d4d
6 changed files with 46 additions and 44 deletions
|
|
@ -71,11 +71,11 @@ public partial class ModCollection
|
||||||
internal SingleArray<ModConflicts> Conflicts(Mod mod)
|
internal SingleArray<ModConflicts> Conflicts(Mod mod)
|
||||||
=> _cache?.Conflicts(mod) ?? new SingleArray<ModConflicts>();
|
=> _cache?.Conflicts(mod) ?? new SingleArray<ModConflicts>();
|
||||||
|
|
||||||
public void SetFiles()
|
public void SetFiles(CharacterUtility utility)
|
||||||
{
|
{
|
||||||
if (_cache == null)
|
if (_cache == null)
|
||||||
{
|
{
|
||||||
Penumbra.CharacterUtility.ResetAll();
|
utility.ResetAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -84,32 +84,32 @@ public partial class ModCollection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMetaFile(MetaIndex idx)
|
public void SetMetaFile(CharacterUtility utility, MetaIndex idx)
|
||||||
{
|
{
|
||||||
if (_cache == null)
|
if (_cache == null)
|
||||||
Penumbra.CharacterUtility.ResetResource(idx);
|
utility.ResetResource(idx);
|
||||||
else
|
else
|
||||||
_cache.Meta.SetFile(idx);
|
_cache.Meta.SetFile(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used for short periods of changed files.
|
// Used for short periods of changed files.
|
||||||
public MetaList.MetaReverter TemporarilySetEqdpFile(GenderRace genderRace, bool accessory)
|
public MetaList.MetaReverter TemporarilySetEqdpFile(CharacterUtility utility, GenderRace genderRace, bool accessory)
|
||||||
=> _cache?.Meta.TemporarilySetEqdpFile(genderRace, accessory)
|
=> _cache?.Meta.TemporarilySetEqdpFile(genderRace, accessory)
|
||||||
?? Penumbra.CharacterUtility.TemporarilyResetResource(Interop.Structs.CharacterUtilityData.EqdpIdx(genderRace, accessory));
|
?? utility.TemporarilyResetResource(Interop.Structs.CharacterUtilityData.EqdpIdx(genderRace, accessory));
|
||||||
|
|
||||||
public MetaList.MetaReverter TemporarilySetEqpFile()
|
public MetaList.MetaReverter TemporarilySetEqpFile(CharacterUtility utility)
|
||||||
=> _cache?.Meta.TemporarilySetEqpFile()
|
=> _cache?.Meta.TemporarilySetEqpFile()
|
||||||
?? Penumbra.CharacterUtility.TemporarilyResetResource(MetaIndex.Eqp);
|
?? utility.TemporarilyResetResource(MetaIndex.Eqp);
|
||||||
|
|
||||||
public MetaList.MetaReverter TemporarilySetGmpFile()
|
public MetaList.MetaReverter TemporarilySetGmpFile(CharacterUtility utility)
|
||||||
=> _cache?.Meta.TemporarilySetGmpFile()
|
=> _cache?.Meta.TemporarilySetGmpFile()
|
||||||
?? Penumbra.CharacterUtility.TemporarilyResetResource(MetaIndex.Gmp);
|
?? utility.TemporarilyResetResource(MetaIndex.Gmp);
|
||||||
|
|
||||||
public MetaList.MetaReverter TemporarilySetCmpFile()
|
public MetaList.MetaReverter TemporarilySetCmpFile(CharacterUtility utility)
|
||||||
=> _cache?.Meta.TemporarilySetCmpFile()
|
=> _cache?.Meta.TemporarilySetCmpFile()
|
||||||
?? Penumbra.CharacterUtility.TemporarilyResetResource(MetaIndex.HumanCmp);
|
?? utility.TemporarilyResetResource(MetaIndex.HumanCmp);
|
||||||
|
|
||||||
public MetaList.MetaReverter TemporarilySetEstFile(EstManipulation.EstType type)
|
public MetaList.MetaReverter TemporarilySetEstFile(CharacterUtility utility, EstManipulation.EstType type)
|
||||||
=> _cache?.Meta.TemporarilySetEstFile(type)
|
=> _cache?.Meta.TemporarilySetEstFile(type)
|
||||||
?? Penumbra.CharacterUtility.TemporarilyResetResource((MetaIndex)type);
|
?? utility.TemporarilyResetResource((MetaIndex)type);
|
||||||
}
|
}
|
||||||
|
|
@ -50,13 +50,13 @@ public unsafe class MetaState : IDisposable
|
||||||
private readonly CollectionResolver _collectionResolver;
|
private readonly CollectionResolver _collectionResolver;
|
||||||
private readonly ResourceService _resources;
|
private readonly ResourceService _resources;
|
||||||
private readonly GameEventManager _gameEventManager;
|
private readonly GameEventManager _gameEventManager;
|
||||||
private readonly Services.CharacterUtility _characterUtility;
|
private readonly CharacterUtility _characterUtility;
|
||||||
|
|
||||||
private ResolveData _lastCreatedCollection = ResolveData.Invalid;
|
private ResolveData _lastCreatedCollection = ResolveData.Invalid;
|
||||||
private DisposableContainer _characterBaseCreateMetaChanges = DisposableContainer.Empty;
|
private DisposableContainer _characterBaseCreateMetaChanges = DisposableContainer.Empty;
|
||||||
|
|
||||||
public MetaState(PerformanceTracker performance, CommunicatorService communicator, CollectionResolver collectionResolver,
|
public MetaState(PerformanceTracker performance, CommunicatorService communicator, CollectionResolver collectionResolver,
|
||||||
ResourceService resources, GameEventManager gameEventManager, Services.CharacterUtility characterUtility)
|
ResourceService resources, GameEventManager gameEventManager, CharacterUtility characterUtility)
|
||||||
{
|
{
|
||||||
_performance = performance;
|
_performance = performance;
|
||||||
_communicator = communicator;
|
_communicator = communicator;
|
||||||
|
|
@ -90,17 +90,17 @@ public unsafe class MetaState : IDisposable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DisposableContainer ResolveEqdpData(ModCollection collection, GenderRace race, bool equipment, bool accessory)
|
public DisposableContainer ResolveEqdpData(ModCollection collection, GenderRace race, bool equipment, bool accessory)
|
||||||
{
|
{
|
||||||
var races = race.Dependencies();
|
var races = race.Dependencies();
|
||||||
if (races.Length == 0)
|
if (races.Length == 0)
|
||||||
return DisposableContainer.Empty;
|
return DisposableContainer.Empty;
|
||||||
|
|
||||||
var equipmentEnumerable = equipment
|
var equipmentEnumerable = equipment
|
||||||
? races.Select(r => collection.TemporarilySetEqdpFile(r, false))
|
? races.Select(r => collection.TemporarilySetEqdpFile(_characterUtility, r, false))
|
||||||
: Array.Empty<IDisposable?>().AsEnumerable();
|
: Array.Empty<IDisposable?>().AsEnumerable();
|
||||||
var accessoryEnumerable = accessory
|
var accessoryEnumerable = accessory
|
||||||
? races.Select(r => collection.TemporarilySetEqdpFile(r, true))
|
? races.Select(r => collection.TemporarilySetEqdpFile(_characterUtility, r, true))
|
||||||
: Array.Empty<IDisposable?>().AsEnumerable();
|
: Array.Empty<IDisposable?>().AsEnumerable();
|
||||||
return new DisposableContainer(equipmentEnumerable.Concat(accessoryEnumerable));
|
return new DisposableContainer(equipmentEnumerable.Concat(accessoryEnumerable));
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +128,7 @@ public unsafe class MetaState : IDisposable
|
||||||
_lastCreatedCollection.ModCollection.Name, (nint)(&modelCharaId), customize, equipData);
|
_lastCreatedCollection.ModCollection.Name, (nint)(&modelCharaId), customize, equipData);
|
||||||
|
|
||||||
var decal = new DecalReverter(_characterUtility, _resources, _lastCreatedCollection.ModCollection, UsesDecal(modelCharaId, equipData));
|
var decal = new DecalReverter(_characterUtility, _resources, _lastCreatedCollection.ModCollection, UsesDecal(modelCharaId, equipData));
|
||||||
var cmp = _lastCreatedCollection.ModCollection.TemporarilySetCmpFile();
|
var cmp = _lastCreatedCollection.ModCollection.TemporarilySetCmpFile(_characterUtility);
|
||||||
_characterBaseCreateMetaChanges.Dispose(); // Should always be empty.
|
_characterBaseCreateMetaChanges.Dispose(); // Should always be empty.
|
||||||
_characterBaseCreateMetaChanges = new DisposableContainer(decal, cmp);
|
_characterBaseCreateMetaChanges = new DisposableContainer(decal, cmp);
|
||||||
}
|
}
|
||||||
|
|
@ -149,7 +149,7 @@ public unsafe class MetaState : IDisposable
|
||||||
private void OnModelLoadCompleteDetour(nint drawObject)
|
private void OnModelLoadCompleteDetour(nint drawObject)
|
||||||
{
|
{
|
||||||
var collection = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
var collection = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||||
using var eqp = collection.ModCollection.TemporarilySetEqpFile();
|
using var eqp = collection.ModCollection.TemporarilySetEqpFile(_characterUtility);
|
||||||
using var eqdp = ResolveEqdpData(collection.ModCollection, GetDrawObjectGenderRace(drawObject), true, true);
|
using var eqdp = ResolveEqdpData(collection.ModCollection, GetDrawObjectGenderRace(drawObject), true, true);
|
||||||
_onModelLoadCompleteHook.Original.Invoke(drawObject);
|
_onModelLoadCompleteHook.Original.Invoke(drawObject);
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +169,7 @@ public unsafe class MetaState : IDisposable
|
||||||
using var performance = _performance.Measure(PerformanceType.UpdateModels);
|
using var performance = _performance.Measure(PerformanceType.UpdateModels);
|
||||||
|
|
||||||
var collection = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
var collection = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||||
using var eqp = collection.ModCollection.TemporarilySetEqpFile();
|
using var eqp = collection.ModCollection.TemporarilySetEqpFile(_characterUtility);
|
||||||
using var eqdp = ResolveEqdpData(collection.ModCollection, GetDrawObjectGenderRace(drawObject), true, true);
|
using var eqdp = ResolveEqdpData(collection.ModCollection, GetDrawObjectGenderRace(drawObject), true, true);
|
||||||
_updateModelsHook.Original.Invoke(drawObject);
|
_updateModelsHook.Original.Invoke(drawObject);
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +198,7 @@ public unsafe class MetaState : IDisposable
|
||||||
|
|
||||||
using var performance = _performance.Measure(PerformanceType.GetEqp);
|
using var performance = _performance.Measure(PerformanceType.GetEqp);
|
||||||
var resolveData = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
var resolveData = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||||
using var eqp = resolveData.ModCollection.TemporarilySetEqpFile();
|
using var eqp = resolveData.ModCollection.TemporarilySetEqpFile(_characterUtility);
|
||||||
_getEqpIndirectHook.Original(drawObject);
|
_getEqpIndirectHook.Original(drawObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,7 +214,7 @@ public unsafe class MetaState : IDisposable
|
||||||
{
|
{
|
||||||
using var performance = _performance.Measure(PerformanceType.SetupVisor);
|
using var performance = _performance.Measure(PerformanceType.SetupVisor);
|
||||||
var resolveData = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
var resolveData = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||||
using var gmp = resolveData.ModCollection.TemporarilySetGmpFile();
|
using var gmp = resolveData.ModCollection.TemporarilySetGmpFile(_characterUtility);
|
||||||
return _setupVisorHook.Original(drawObject, modelId, visorState);
|
return _setupVisorHook.Original(drawObject, modelId, visorState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,7 +234,7 @@ public unsafe class MetaState : IDisposable
|
||||||
{
|
{
|
||||||
using var performance = _performance.Measure(PerformanceType.SetupCharacter);
|
using var performance = _performance.Measure(PerformanceType.SetupCharacter);
|
||||||
var resolveData = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
var resolveData = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||||
using var cmp = resolveData.ModCollection.TemporarilySetCmpFile();
|
using var cmp = resolveData.ModCollection.TemporarilySetCmpFile(_characterUtility);
|
||||||
_rspSetupCharacterHook.Original(drawObject, unk2, unk3, unk4, unk5);
|
_rspSetupCharacterHook.Original(drawObject, unk2, unk3, unk4, unk5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -252,7 +252,7 @@ public unsafe class MetaState : IDisposable
|
||||||
using var performance = _performance.Measure(PerformanceType.ChangeCustomize);
|
using var performance = _performance.Measure(PerformanceType.ChangeCustomize);
|
||||||
_inChangeCustomize = true;
|
_inChangeCustomize = true;
|
||||||
var resolveData = _collectionResolver.IdentifyCollection((DrawObject*)human, true);
|
var resolveData = _collectionResolver.IdentifyCollection((DrawObject*)human, true);
|
||||||
using var cmp = resolveData.ModCollection.TemporarilySetCmpFile();
|
using var cmp = resolveData.ModCollection.TemporarilySetCmpFile(_characterUtility);
|
||||||
using var decals =
|
using var decals =
|
||||||
new DecalReverter(_characterUtility, _resources, resolveData.ModCollection, UsesDecal(0, data));
|
new DecalReverter(_characterUtility, _resources, resolveData.ModCollection, UsesDecal(0, data));
|
||||||
var ret = _changeCustomize.Original(human, data, skipEquipment);
|
var ret = _changeCustomize.Original(human, data, skipEquipment);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System.Threading;
|
||||||
using Dalamud.Utility.Signatures;
|
using Dalamud.Utility.Signatures;
|
||||||
using Penumbra.Collections;
|
using Penumbra.Collections;
|
||||||
using Penumbra.GameData;
|
using Penumbra.GameData;
|
||||||
|
using Penumbra.Interop.Services;
|
||||||
using Penumbra.String;
|
using Penumbra.String;
|
||||||
|
|
||||||
namespace Penumbra.Interop.PathResolving;
|
namespace Penumbra.Interop.PathResolving;
|
||||||
|
|
@ -24,6 +25,8 @@ public unsafe class PathState : IDisposable
|
||||||
private readonly nint* _monsterVTable = null!;
|
private readonly nint* _monsterVTable = null!;
|
||||||
|
|
||||||
public readonly CollectionResolver CollectionResolver;
|
public readonly CollectionResolver CollectionResolver;
|
||||||
|
public readonly MetaState MetaState;
|
||||||
|
public readonly CharacterUtility CharacterUtility;
|
||||||
|
|
||||||
private readonly ResolvePathHooks _human;
|
private readonly ResolvePathHooks _human;
|
||||||
private readonly ResolvePathHooks _weapon;
|
private readonly ResolvePathHooks _weapon;
|
||||||
|
|
@ -35,10 +38,12 @@ public unsafe class PathState : IDisposable
|
||||||
public IList<ResolveData> CurrentData
|
public IList<ResolveData> CurrentData
|
||||||
=> _resolveData.Values;
|
=> _resolveData.Values;
|
||||||
|
|
||||||
public PathState(CollectionResolver collectionResolver)
|
public PathState(CollectionResolver collectionResolver, MetaState metaState, CharacterUtility characterUtility)
|
||||||
{
|
{
|
||||||
SignatureHelper.Initialise(this);
|
SignatureHelper.Initialise(this);
|
||||||
CollectionResolver = collectionResolver;
|
CollectionResolver = collectionResolver;
|
||||||
|
MetaState = metaState;
|
||||||
|
CharacterUtility = characterUtility;
|
||||||
_human = new ResolvePathHooks(this, _humanVTable, ResolvePathHooks.Type.Human);
|
_human = new ResolvePathHooks(this, _humanVTable, ResolvePathHooks.Type.Human);
|
||||||
_weapon = new ResolvePathHooks(this, _weaponVTable, ResolvePathHooks.Type.Weapon);
|
_weapon = new ResolvePathHooks(this, _weaponVTable, ResolvePathHooks.Type.Weapon);
|
||||||
_demiHuman = new ResolvePathHooks(this, _demiHumanVTable, ResolvePathHooks.Type.Other);
|
_demiHuman = new ResolvePathHooks(this, _demiHumanVTable, ResolvePathHooks.Type.Other);
|
||||||
|
|
@ -59,7 +64,7 @@ public unsafe class PathState : IDisposable
|
||||||
_monster.Dispose();
|
_monster.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Consume(ByteString path, out ResolveData collection)
|
public bool Consume(ByteString _, out ResolveData collection)
|
||||||
{
|
{
|
||||||
if (_resolveData.IsValueCreated)
|
if (_resolveData.IsValueCreated)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ public unsafe class ResolvePathHooks : IDisposable
|
||||||
var data = _parent.CollectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
var data = _parent.CollectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||||
using var eqdp = modelType > 9
|
using var eqdp = modelType > 9
|
||||||
? DisposableContainer.Empty
|
? DisposableContainer.Empty
|
||||||
: MetaState.ResolveEqdpData(data.ModCollection, MetaState.GetHumanGenderRace(drawObject), modelType < 5, modelType > 4);
|
: _parent.MetaState.ResolveEqdpData(data.ModCollection, MetaState.GetHumanGenderRace(drawObject), modelType < 5, modelType > 4);
|
||||||
return ResolvePath(data, _resolveMdlPathHook.Original(drawObject, path, unk3, modelType));
|
return ResolvePath(data, _resolveMdlPathHook.Original(drawObject, path, unk3, modelType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,10 +175,10 @@ public unsafe class ResolvePathHooks : IDisposable
|
||||||
private DisposableContainer GetEstChanges(nint drawObject, out ResolveData data)
|
private DisposableContainer GetEstChanges(nint drawObject, out ResolveData data)
|
||||||
{
|
{
|
||||||
data = _parent.CollectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
data = _parent.CollectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||||
return new DisposableContainer(data.ModCollection.TemporarilySetEstFile(EstManipulation.EstType.Face),
|
return new DisposableContainer(data.ModCollection.TemporarilySetEstFile(_parent.CharacterUtility, EstManipulation.EstType.Face),
|
||||||
data.ModCollection.TemporarilySetEstFile(EstManipulation.EstType.Body),
|
data.ModCollection.TemporarilySetEstFile(_parent.CharacterUtility, EstManipulation.EstType.Body),
|
||||||
data.ModCollection.TemporarilySetEstFile(EstManipulation.EstType.Hair),
|
data.ModCollection.TemporarilySetEstFile(_parent.CharacterUtility, EstManipulation.EstType.Hair),
|
||||||
data.ModCollection.TemporarilySetEstFile(EstManipulation.EstType.Head));
|
data.ModCollection.TemporarilySetEstFile(_parent.CharacterUtility, EstManipulation.EstType.Head));
|
||||||
}
|
}
|
||||||
|
|
||||||
private nint ResolveDecalWeapon(nint drawObject, nint path, nint unk3, uint unk4)
|
private nint ResolveDecalWeapon(nint drawObject, nint path, nint unk3, uint unk4)
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ public unsafe class MetaList : IDisposable
|
||||||
=> SetResourceInternal(_defaultResourceData, _defaultResourceSize);
|
=> SetResourceInternal(_defaultResourceData, _defaultResourceSize);
|
||||||
|
|
||||||
private void SetResourceToDefaultCollection()
|
private void SetResourceToDefaultCollection()
|
||||||
=> _utility.Active.Default.SetMetaFile(GlobalMetaIndex);
|
=> _utility.Active.Default.SetMetaFile(_utility, GlobalMetaIndex);
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,6 @@ public class Penumbra : IDalamudPlugin
|
||||||
public static Logger Log { get; private set; } = null!;
|
public static Logger Log { get; private set; } = null!;
|
||||||
public static ChatService ChatService { get; private set; } = null!;
|
public static ChatService ChatService { get; private set; } = null!;
|
||||||
|
|
||||||
public static CharacterUtility CharacterUtility { get; private set; } = null!;
|
|
||||||
|
|
||||||
public readonly RedrawService RedrawService;
|
public readonly RedrawService RedrawService;
|
||||||
public readonly ModFileSystem ModFileSystem;
|
public readonly ModFileSystem ModFileSystem;
|
||||||
public HttpApi HttpApi = null!;
|
public HttpApi HttpApi = null!;
|
||||||
|
|
@ -64,7 +62,6 @@ public class Penumbra : IDalamudPlugin
|
||||||
_tmp.Services.GetRequiredService<BackupService>();
|
_tmp.Services.GetRequiredService<BackupService>();
|
||||||
_config = _tmp.Services.GetRequiredService<Configuration>();
|
_config = _tmp.Services.GetRequiredService<Configuration>();
|
||||||
_characterUtility = _tmp.Services.GetRequiredService<CharacterUtility>();
|
_characterUtility = _tmp.Services.GetRequiredService<CharacterUtility>();
|
||||||
CharacterUtility = _characterUtility;
|
|
||||||
_tempMods = _tmp.Services.GetRequiredService<TempModManager>();
|
_tempMods = _tmp.Services.GetRequiredService<TempModManager>();
|
||||||
_residentResources = _tmp.Services.GetRequiredService<ResidentResourceManager>();
|
_residentResources = _tmp.Services.GetRequiredService<ResidentResourceManager>();
|
||||||
_tmp.Services.GetRequiredService<ResourceManagerService>();
|
_tmp.Services.GetRequiredService<ResourceManagerService>();
|
||||||
|
|
@ -149,7 +146,7 @@ public class Penumbra : IDalamudPlugin
|
||||||
{
|
{
|
||||||
if (_characterUtility.Ready)
|
if (_characterUtility.Ready)
|
||||||
{
|
{
|
||||||
_collectionManager.Active.Default.SetFiles();
|
_collectionManager.Active.Default.SetFiles(_characterUtility);
|
||||||
_residentResources.Reload();
|
_residentResources.Reload();
|
||||||
RedrawService.RedrawAll(RedrawType.Redraw);
|
RedrawService.RedrawAll(RedrawType.Redraw);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue