Maybe fix weapon behavior with multiple restricted designs with identical weapon types.

This commit is contained in:
Ottermandias 2024-03-28 15:23:19 +01:00
parent 71d6a658d6
commit 3d421881f6
12 changed files with 104 additions and 38 deletions

View file

@ -1,18 +1,21 @@
using OtterGui.Services;
using Glamourer.Designs.Links;
using OtterGui.Services;
using Penumbra.GameData.Actors;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Glamourer.State;
public sealed class JobChangeState : Dictionary<FullEquipType, (EquipItem, StateSource)>, IService
public sealed class JobChangeState : IService
{
private readonly WeaponList _weaponList = new();
public ActorState? State { get; private set; }
public void Reset()
{
State = null;
Clear();
_weaponList.Clear();
}
public bool HasState
@ -21,10 +24,13 @@ public sealed class JobChangeState : Dictionary<FullEquipType, (EquipItem, State
public ActorIdentifier Identifier
=> State?.Identifier ?? ActorIdentifier.Invalid;
public void Set(ActorState state, IEnumerable<(EquipItem, StateSource)> items)
public bool TryGetValue(FullEquipType slot, JobId jobId, out (EquipItem, StateSource) data)
=> _weaponList.TryGet(slot, jobId, out data);
public void Set(ActorState state, IEnumerable<(EquipItem, StateSource, JobFlag)> items)
{
foreach (var (item, source) in items.Where(p => p.Item1.Valid))
TryAdd(item.Type, (item, source));
foreach (var (item, source, flags) in items.Where(p => p.Item1.Valid))
_weaponList.TryAdd(item.Type, item, source, flags);
State = state;
}
}

View file

@ -298,7 +298,7 @@ public class StateEditor(
}
var currentType = state.BaseData.Item(weaponSlot).Type;
if (mergedDesign.Weapons.TryGetValue(currentType, out var weapon))
if (mergedDesign.Weapons.TryGet(currentType, state.LastJob, out var weapon))
{
var source = settings.UseSingleSource ? settings.Source :
weapon.Item2 is StateSource.Game ? StateSource.Game : settings.Source;
@ -311,7 +311,7 @@ public class StateEditor(
if (settings.FromJobChange)
jobChange.Set(state, mergedDesign.Weapons.Values.Select(m =>
(m.Item1, settings.UseSingleSource ? settings.Source :
m.Item2 is StateSource.Game ? StateSource.Game : settings.Source)));
m.Item2 is StateSource.Game ? StateSource.Game : settings.Source, m.Item3)));
foreach (var meta in MetaExtensions.AllRelevant.Where(mergedDesign.Design.DoApplyMeta))
{