Fix issues with shared weapon types.

This commit is contained in:
Ottermandias 2024-11-22 14:27:14 +01:00
parent b44a147fdd
commit 525f65e70a
6 changed files with 13 additions and 11 deletions

View file

@ -77,7 +77,7 @@ public sealed class AutoDesignApplier : IDisposable
{
case EquipSlot.MainHand:
{
if (_jobChangeState.TryGetValue(current.Type, actor.Job, out var data))
if (_jobChangeState.TryGetValue(current.Type, actor.Job, false, out var data))
{
Glamourer.Log.Verbose(
$"Changing Mainhand from {state.ModelData.Weapon(EquipSlot.MainHand)} | {state.BaseData.Weapon(EquipSlot.MainHand)} to {data.Item1} for 0x{actor.Address:X}.");
@ -89,7 +89,7 @@ public sealed class AutoDesignApplier : IDisposable
}
case EquipSlot.OffHand when current.Type == state.BaseData.MainhandType.Offhand():
{
if (_jobChangeState.TryGetValue(current.Type, actor.Job, out var data))
if (_jobChangeState.TryGetValue(current.Type, actor.Job, false, out var data))
{
Glamourer.Log.Verbose(
$"Changing Offhand from {state.ModelData.Weapon(EquipSlot.OffHand)} | {state.BaseData.Weapon(EquipSlot.OffHand)} to {data.Item1} for 0x{actor.Address:X}.");

View file

@ -1,4 +1,5 @@
using Glamourer.Automation;
using Glamourer.Designs.Special;
using Glamourer.GameData;
using Glamourer.Interop.Material;
using Glamourer.Services;
@ -23,8 +24,7 @@ public class DesignMerger(
modAssociations);
public MergedDesign Merge(IEnumerable<(IDesignStandIn, ApplicationType, JobFlag)> designs, in CustomizeArray currentCustomize,
in DesignData baseRef,
bool respectOwnership, bool modAssociations)
in DesignData baseRef, bool respectOwnership, bool modAssociations)
{
var ret = new MergedDesign(designManager);
ret.Design.SetCustomize(_customize, currentCustomize);

View file

@ -23,8 +23,8 @@ public readonly struct WeaponList
_list.Add(type, list);
}
var remainingFlags = list.Select(t => t.Item3)
.Aggregate(flags, (current, existingFlags) => current & ~existingFlags);
var existingFlags = list.Count == 0 ? 0 : list.Select(t => t.Item3).Aggregate((t, existing) => t | existing);
var remainingFlags = flags & ~existingFlags;
if (remainingFlags == 0)
return false;
@ -33,7 +33,7 @@ public readonly struct WeaponList
return true;
}
public bool TryGet(FullEquipType type, JobId id, out (EquipItem, StateSource) ret)
public bool TryGet(FullEquipType type, JobId id, bool gameStateAllowed, out (EquipItem, StateSource) ret)
{
if (!_list.TryGetValue(type, out var list))
{
@ -45,7 +45,7 @@ public readonly struct WeaponList
foreach (var (item, source, flags) in list)
{
if (flags.HasFlag(flag))
if (flags.HasFlag(flag) && (gameStateAllowed || source is not StateSource.Game))
{
ret = (item, source);
return true;

View file

@ -139,6 +139,7 @@ public class Glamourer : IDalamudPlugin
ReadOnlySpan<string> relevantPlugins =
[
"Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge",
"LoporritSync",
];
var plugins = _services.GetService<IDalamudPluginInterface>().InstalledPlugins
.GroupBy(p => p.InternalName)

View file

@ -24,11 +24,12 @@ public sealed class JobChangeState : IService
public ActorIdentifier Identifier
=> State?.Identifier ?? ActorIdentifier.Invalid;
public bool TryGetValue(FullEquipType slot, JobId jobId, out (EquipItem, StateSource) data)
=> _weaponList.TryGet(slot, jobId, out data);
public bool TryGetValue(FullEquipType slot, JobId jobId, bool gameStateAllowed, out (EquipItem, StateSource) data)
=> _weaponList.TryGet(slot, jobId, gameStateAllowed, out data);
public void Set(ActorState state, IEnumerable<(EquipItem, StateSource, JobFlag)> items)
{
Reset();
foreach (var (item, source, flags) in items.Where(p => p.Item1.Valid))
_weaponList.TryAdd(item.Type, item, source, flags);
State = state;

View file

@ -359,7 +359,7 @@ public class StateEditor(
}
var currentType = state.BaseData.Item(weaponSlot).Type;
if (mergedDesign.Weapons.TryGet(currentType, state.LastJob, out var weapon))
if (mergedDesign.Weapons.TryGet(currentType, state.LastJob, true, out var weapon))
{
var source = settings.UseSingleSource ? settings.Source :
weapon.Item2 is StateSource.Game ? StateSource.Game : settings.Source;