Skip to content

Commit

Permalink
Fix applying designs via weapons in gpose.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Feb 23, 2024
1 parent fdee4c4 commit ecf6008
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
28 changes: 22 additions & 6 deletions Glamourer/State/StateEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class StateEditor(
Configuration config,
ItemManager items,
DesignMerger merger,
ModSettingApplier modApplier) : IDesignEditor
ModSettingApplier modApplier,
GPoseService gPose) : IDesignEditor
{
protected readonly InternalStateEditor Editor = editor;
protected readonly StateApplier Applier = applier;
Expand Down Expand Up @@ -276,12 +277,27 @@ public void ApplyDesign(object data, MergedDesign mergedDesign, ApplySettings se
continue;

var currentType = state.ModelData.Item(weaponSlot).Type;
if (!settings.FromJobChange && mergedDesign.Weapons.TryGetValue(currentType, out var weapon))
if (!settings.FromJobChange)
{
var source = settings.UseSingleSource ? settings.Source :
weapon.Item2 is StateSource.Game ? StateSource.Game : weapon.Item2;
Editor.ChangeItem(state, weaponSlot, weapon.Item1, source, out _,
settings.Key);
if (gPose.InGPose)
{
Editor.ChangeItem(state, weaponSlot, mergedDesign.Design.DesignData.Item(weaponSlot),
settings.UseSingleSource ? settings.Source : mergedDesign.Sources[weaponSlot, false], out var old, settings.Key);
var oldSource = state.Sources[weaponSlot, false];
gPose.AddActionOnLeave(() =>
{
if (old.Type == state.BaseData.Item(weaponSlot).Type)
Editor.ChangeItem(state, weaponSlot, old, oldSource, out _, settings.Key);
});
}

if (mergedDesign.Weapons.TryGetValue(currentType, out var weapon))
{
var source = settings.UseSingleSource ? settings.Source :
weapon.Item2 is StateSource.Game ? StateSource.Game : weapon.Item2;
Editor.ChangeItem(state, weaponSlot, weapon.Item1, source, out _,
settings.Key);
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions Glamourer/State/StateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public sealed class StateManager(
Configuration config,
JobChangeState jobChange,
DesignMerger merger,
ModSettingApplier modApplier)
: StateEditor(editor, applier, @event, jobChange, config, items, merger, modApplier), IReadOnlyDictionary<ActorIdentifier, ActorState>
ModSettingApplier modApplier,
GPoseService gPose)
: StateEditor(editor, applier, @event, jobChange, config, items, merger, modApplier, gPose), IReadOnlyDictionary<ActorIdentifier, ActorState>
{
private readonly Dictionary<ActorIdentifier, ActorState> _states = [];

Expand Down

0 comments on commit ecf6008

Please sign in to comment.