Move some stuff to shared things, improve some filesystem rename handling.

This commit is contained in:
Ottermandias 2023-07-05 16:13:11 +02:00
parent 8ea6893fc3
commit 00bc17c57a
11 changed files with 67 additions and 136 deletions

View file

@ -1,15 +1,11 @@
using System;
using System.Collections;
using System.Linq;
using Dalamud.Data;
using Dalamud.Game.ClientState;
using Dalamud.Game.Gui;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Lumina.Excel.GeneratedSheets;
using OtterGui;
using Penumbra.Collections;
using Penumbra.Collections.Manager;
using Penumbra.Collections.Manager;
using Penumbra.GameData.Actors;
using Penumbra.GameData.Data;
using Penumbra.GameData.Enums;
using Penumbra.Services;
using Penumbra.Util;
@ -23,7 +19,7 @@ public unsafe class CollectionResolver
{
private readonly PerformanceTracker _performance;
private readonly IdentifiedCollectionCache _cache;
private readonly BitArray _validHumanModels;
private readonly HumanModelList _humanModels;
private readonly ClientState _clientState;
private readonly GameGui _gameGui;
@ -36,8 +32,8 @@ public unsafe class CollectionResolver
private readonly DrawObjectState _drawObjectState;
public CollectionResolver(PerformanceTracker performance, IdentifiedCollectionCache cache, ClientState clientState, GameGui gameGui,
DataManager gameData, ActorService actors, CutsceneService cutscenes, Configuration config, CollectionManager collectionManager,
TempCollectionManager tempCollections, DrawObjectState drawObjectState)
ActorService actors, CutsceneService cutscenes, Configuration config, CollectionManager collectionManager,
TempCollectionManager tempCollections, DrawObjectState drawObjectState, HumanModelList humanModels)
{
_performance = performance;
_cache = cache;
@ -49,7 +45,7 @@ public unsafe class CollectionResolver
_collectionManager = collectionManager;
_tempCollections = tempCollections;
_drawObjectState = drawObjectState;
_validHumanModels = GetValidHumanModels(gameData);
_humanModels = humanModels;
}
/// <summary>
@ -115,7 +111,7 @@ public unsafe class CollectionResolver
/// <summary> Return whether the given ModelChara id refers to a human-type model. </summary>
public bool IsModelHuman(uint modelCharaId)
=> modelCharaId < _validHumanModels.Length && _validHumanModels[(int)modelCharaId];
=> _humanModels.IsHuman(modelCharaId);
/// <summary> Return whether the given character has a human model. </summary>
public bool IsModelHuman(Character* character)
@ -254,17 +250,4 @@ public unsafe class CollectionResolver
return CheckYourself(id, owner)
?? CollectionByAttributes(owner, ref notYetReady);
}
/// <summary>
/// Go through all ModelChara rows and return a bitfield of those that resolve to human models.
/// </summary>
private static BitArray GetValidHumanModels(DataManager gameData)
{
var sheet = gameData.GetExcelSheet<ModelChara>()!;
var ret = new BitArray((int)sheet.RowCount, false);
foreach (var (_, idx) in sheet.WithIndex().Where(p => p.Value.Type == (byte)CharacterBase.ModelType.Human))
ret[idx] = true;
return ret;
}
}

View file

@ -4,7 +4,7 @@ using Dalamud.Data;
using Dalamud.Game.ClientState.Objects;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using Penumbra.GameData;
using OtterGui.Custom;
using Penumbra.GameData.Actors;
using Penumbra.Interop.PathResolving;
using Penumbra.Services;