mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Fix owned NPCs not working with automation and some NPC customizations not working with automation.
This commit is contained in:
parent
662ec617dc
commit
01431381c5
2 changed files with 58 additions and 26 deletions
|
|
@ -85,7 +85,7 @@ public class AutoDesignApplier : IDisposable
|
||||||
_state.ReapplyState(actor);
|
_state.ReapplyState(actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_objects.TryGetValueAllWorld(id, out data))
|
else if (_objects.TryGetValueAllWorld(id, out data) || _objects.TryGetValueNonOwned(id, out data))
|
||||||
{
|
{
|
||||||
foreach (var actor in data.Objects)
|
foreach (var actor in data.Objects)
|
||||||
{
|
{
|
||||||
|
|
@ -210,7 +210,7 @@ public class AutoDesignApplier : IDisposable
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var (equipFlags, customizeFlags, applyHat, applyVisor, applyWeapon, applyWet) = design.ApplyWhat();
|
var (equipFlags, customizeFlags, applyHat, applyVisor, applyWeapon, applyWet) = design.ApplyWhat();
|
||||||
Reduce(state, data, applyHat, applyVisor, applyWeapon, applyWet, ref totalMetaFlags, respectManual, source);
|
Reduce(state, data, applyHat, applyVisor, applyWeapon, applyWet, ref totalMetaFlags, respectManual, source);
|
||||||
Reduce(state, data, customizeFlags, ref totalCustomizeFlags, respectManual, source);
|
Reduce(state, data, customizeFlags, ref totalCustomizeFlags, respectManual, source);
|
||||||
Reduce(state, data, equipFlags, ref totalEquipFlags, respectManual, source);
|
Reduce(state, data, equipFlags, ref totalEquipFlags, respectManual, source);
|
||||||
}
|
}
|
||||||
|
|
@ -219,17 +219,28 @@ public class AutoDesignApplier : IDisposable
|
||||||
/// <summary> Get world-specific first and all-world afterwards. </summary>
|
/// <summary> Get world-specific first and all-world afterwards. </summary>
|
||||||
private bool GetPlayerSet(ActorIdentifier identifier, [NotNullWhen(true)] out AutoDesignSet? set)
|
private bool GetPlayerSet(ActorIdentifier identifier, [NotNullWhen(true)] out AutoDesignSet? set)
|
||||||
{
|
{
|
||||||
if (identifier.Type is not IdentifierType.Player)
|
switch (identifier.Type)
|
||||||
return _manager.EnabledSets.TryGetValue(identifier, out set);
|
{
|
||||||
|
case IdentifierType.Player:
|
||||||
|
if (_manager.EnabledSets.TryGetValue(identifier, out set))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (_manager.EnabledSets.TryGetValue(identifier, out set))
|
identifier = _actors.AwaitedService.CreatePlayer(identifier.PlayerName, ushort.MaxValue);
|
||||||
return true;
|
return _manager.EnabledSets.TryGetValue(identifier, out set);
|
||||||
|
case IdentifierType.Retainer:
|
||||||
identifier = _actors.AwaitedService.CreatePlayer(identifier.PlayerName, ushort.MaxValue);
|
case IdentifierType.Special:
|
||||||
return _manager.EnabledSets.TryGetValue(identifier, out set);
|
return _manager.EnabledSets.TryGetValue(identifier, out set);
|
||||||
|
case IdentifierType.Owned:
|
||||||
|
identifier = _actors.AwaitedService.CreateNpc(identifier.Kind, identifier.DataId);
|
||||||
|
return _manager.EnabledSets.TryGetValue(identifier, out set);
|
||||||
|
default:
|
||||||
|
set = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Reduce(ActorState state, in DesignData design, EquipFlag equipFlags, ref EquipFlag totalEquipFlags, bool respectManual, StateChanged.Source source)
|
private void Reduce(ActorState state, in DesignData design, EquipFlag equipFlags, ref EquipFlag totalEquipFlags, bool respectManual,
|
||||||
|
StateChanged.Source source)
|
||||||
{
|
{
|
||||||
equipFlags &= ~totalEquipFlags;
|
equipFlags &= ~totalEquipFlags;
|
||||||
if (equipFlags == 0)
|
if (equipFlags == 0)
|
||||||
|
|
@ -347,9 +358,11 @@ public class AutoDesignApplier : IDisposable
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var value = design.Customize[index];
|
var value = design.Customize[index];
|
||||||
if (CustomizationService.IsCustomizationValid(set, face, index, value, out var data)
|
if (CustomizationService.IsCustomizationValid(set, face, index, value, out var data))
|
||||||
&& (data.HasValue && (!_config.UnlockedItemMode || _customizeUnlocks.IsUnlocked(data.Value, out _))))
|
|
||||||
{
|
{
|
||||||
|
if (data.HasValue && _config.UnlockedItemMode && !_customizeUnlocks.IsUnlocked(data.Value, out _))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!respectManual || state[index] is not StateChanged.Source.Manual)
|
if (!respectManual || state[index] is not StateChanged.Source.Manual)
|
||||||
_state.ChangeCustomize(state, index, value, source);
|
_state.ChangeCustomize(state, index, value, source);
|
||||||
totalCustomizeFlags |= flag;
|
totalCustomizeFlags |= flag;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using Dalamud.Game.ClientState.Objects;
|
||||||
using Glamourer.Interop.Structs;
|
using Glamourer.Interop.Structs;
|
||||||
using Glamourer.Services;
|
using Glamourer.Services;
|
||||||
using Penumbra.GameData.Actors;
|
using Penumbra.GameData.Actors;
|
||||||
|
using Penumbra.String;
|
||||||
|
|
||||||
namespace Glamourer.Interop;
|
namespace Glamourer.Interop;
|
||||||
|
|
||||||
|
|
@ -34,6 +35,7 @@ public class ObjectManager : IReadOnlyDictionary<ActorIdentifier, ActorData>
|
||||||
|
|
||||||
private readonly Dictionary<ActorIdentifier, ActorData> _identifiers = new(200);
|
private readonly Dictionary<ActorIdentifier, ActorData> _identifiers = new(200);
|
||||||
private readonly Dictionary<ActorIdentifier, ActorData> _allWorldIdentifiers = new(200);
|
private readonly Dictionary<ActorIdentifier, ActorData> _allWorldIdentifiers = new(200);
|
||||||
|
private readonly Dictionary<ActorIdentifier, ActorData> _nonOwnedIdentifiers = new(200);
|
||||||
|
|
||||||
public IReadOnlyDictionary<ActorIdentifier, ActorData> Identifiers
|
public IReadOnlyDictionary<ActorIdentifier, ActorData> Identifiers
|
||||||
=> _identifiers;
|
=> _identifiers;
|
||||||
|
|
@ -110,21 +112,35 @@ public class ObjectManager : IReadOnlyDictionary<ActorIdentifier, ActorData>
|
||||||
data.Objects.Add(character);
|
data.Objects.Add(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (identifier.Type is not (IdentifierType.Player or IdentifierType.Owned))
|
if (identifier.Type is IdentifierType.Player or IdentifierType.Owned)
|
||||||
return;
|
|
||||||
|
|
||||||
var allWorld = _actors.AwaitedService.CreateIndividualUnchecked(identifier.Type, identifier.PlayerName, ushort.MaxValue,
|
|
||||||
identifier.Kind,
|
|
||||||
identifier.DataId);
|
|
||||||
|
|
||||||
if (!_allWorldIdentifiers.TryGetValue(allWorld, out var allWorldData))
|
|
||||||
{
|
{
|
||||||
allWorldData = new ActorData(character, allWorld.ToString());
|
var allWorld = _actors.AwaitedService.CreateIndividualUnchecked(identifier.Type, identifier.PlayerName, ushort.MaxValue,
|
||||||
_allWorldIdentifiers[allWorld] = allWorldData;
|
identifier.Kind,
|
||||||
|
identifier.DataId);
|
||||||
|
|
||||||
|
if (!_allWorldIdentifiers.TryGetValue(allWorld, out var allWorldData))
|
||||||
|
{
|
||||||
|
allWorldData = new ActorData(character, allWorld.ToString());
|
||||||
|
_allWorldIdentifiers[allWorld] = allWorldData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
allWorldData.Objects.Add(character);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (identifier.Type is IdentifierType.Owned)
|
||||||
{
|
{
|
||||||
allWorldData.Objects.Add(character);
|
var nonOwned = _actors.AwaitedService.CreateNpc(identifier.Kind, identifier.DataId);
|
||||||
|
if (!_nonOwnedIdentifiers.TryGetValue(nonOwned, out var allWorldData))
|
||||||
|
{
|
||||||
|
allWorldData = new ActorData(character, nonOwned.ToString());
|
||||||
|
_allWorldIdentifiers[nonOwned] = allWorldData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
allWorldData.Objects.Add(character);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,9 +190,9 @@ public class ObjectManager : IReadOnlyDictionary<ActorIdentifier, ActorData>
|
||||||
public int Count
|
public int Count
|
||||||
=> Identifiers.Count;
|
=> Identifiers.Count;
|
||||||
|
|
||||||
/// <summary> Also handles All Worlds players. </summary>
|
/// <summary> Also handles All Worlds players and non-owned NPCs. </summary>
|
||||||
public bool ContainsKey(ActorIdentifier key)
|
public bool ContainsKey(ActorIdentifier key)
|
||||||
=> Identifiers.ContainsKey(key) || _allWorldIdentifiers.ContainsKey(key);
|
=> Identifiers.ContainsKey(key) || _allWorldIdentifiers.ContainsKey(key) || _nonOwnedIdentifiers.ContainsKey(key);
|
||||||
|
|
||||||
public bool TryGetValue(ActorIdentifier key, out ActorData value)
|
public bool TryGetValue(ActorIdentifier key, out ActorData value)
|
||||||
=> Identifiers.TryGetValue(key, out value);
|
=> Identifiers.TryGetValue(key, out value);
|
||||||
|
|
@ -184,6 +200,9 @@ public class ObjectManager : IReadOnlyDictionary<ActorIdentifier, ActorData>
|
||||||
public bool TryGetValueAllWorld(ActorIdentifier key, out ActorData value)
|
public bool TryGetValueAllWorld(ActorIdentifier key, out ActorData value)
|
||||||
=> _allWorldIdentifiers.TryGetValue(key, out value);
|
=> _allWorldIdentifiers.TryGetValue(key, out value);
|
||||||
|
|
||||||
|
public bool TryGetValueNonOwned(ActorIdentifier key, out ActorData value)
|
||||||
|
=> _nonOwnedIdentifiers.TryGetValue(key, out value);
|
||||||
|
|
||||||
public ActorData this[ActorIdentifier key]
|
public ActorData this[ActorIdentifier key]
|
||||||
=> Identifiers[key];
|
=> Identifiers[key];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue