diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 3013c4a..ec362ae 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -237,7 +237,7 @@ public class AutoDesignApplier : IDisposable CustomizeFlag totalCustomizeFlags = 0; byte totalMetaFlags = 0; if (set.BaseState == AutoDesignSet.Base.Game) - _state.ResetState(state, StateChanged.Source.Fixed); + _state.ResetStateFixed(state); else if (!respectManual) state.RemoveFixedDesignSources(); foreach (var design in set.Designs) diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 65cde61..994bfa2 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -378,7 +378,7 @@ public class StateManager : IReadOnlyDictionary if (design.DoApplyVisorToggle()) _editor.ChangeMetaState(state, ActorState.MetaIndex.VisorState, design.DesignData.IsVisorToggled(), source, out _, key); - var flags = state.AllowsRedraw ? design.ApplyCustomize : design.ApplyCustomize & ~CustomizeFlagExtensions.RedrawRequired; + var flags = state.AllowsRedraw ? design.ApplyCustomize : design.ApplyCustomize & ~CustomizeFlagExtensions.RedrawRequired; _editor.ChangeHumanCustomize(state, design.DesignData.Customize, flags, source, out _, out var applied, key); redraw |= applied.RequiresRedraw(); @@ -433,6 +433,7 @@ public class StateManager : IReadOnlyDictionary state.ModelData = state.BaseData; foreach (var index in Enum.GetValues()) state[index] = StateChanged.Source.Game; + foreach (var slot in EquipSlotExtensions.FullSlots) { state[slot, true] = StateChanged.Source.Game; @@ -450,6 +451,57 @@ public class StateManager : IReadOnlyDictionary _event.Invoke(StateChanged.Type.Reset, StateChanged.Source.Manual, state, actors, null); } + public void ResetStateFixed(ActorState state, uint key = 0) + { + if (!state.Unlock(key)) + return; + + foreach (var index in Enum.GetValues().Where(i => state[i] is StateChanged.Source.Fixed)) + { + state[index] = StateChanged.Source.Game; + state.ModelData.Customize[index] = state.BaseData.Customize[index]; + } + + foreach (var slot in EquipSlotExtensions.FullSlots) + { + if (state[slot, true] is StateChanged.Source.Fixed) + { + state[slot, true] = StateChanged.Source.Game; + state.ModelData.SetStain(slot, state.BaseData.Stain(slot)); + } + + if (state[slot, false] is StateChanged.Source.Fixed) + { + state[slot, false] = StateChanged.Source.Game; + state.ModelData.SetItem(slot, state.BaseData.Item(slot)); + } + } + + if (state[ActorState.MetaIndex.HatState] is StateChanged.Source.Fixed) + { + state[ActorState.MetaIndex.HatState] = StateChanged.Source.Game; + state.ModelData.SetHatVisible(state.BaseData.IsHatVisible()); + } + + if (state[ActorState.MetaIndex.VisorState] is StateChanged.Source.Fixed) + { + state[ActorState.MetaIndex.VisorState] = StateChanged.Source.Game; + state.ModelData.SetVisor(state.BaseData.IsVisorToggled()); + } + + if (state[ActorState.MetaIndex.WeaponState] is StateChanged.Source.Fixed) + { + state[ActorState.MetaIndex.WeaponState] = StateChanged.Source.Game; + state.ModelData.SetWeaponVisible(state.BaseData.IsWeaponVisible()); + } + + if (state[ActorState.MetaIndex.Wetness] is StateChanged.Source.Fixed) + { + state[ActorState.MetaIndex.Wetness] = StateChanged.Source.Game; + state.ModelData.SetIsWet(state.BaseData.IsWet()); + } + } + public void ReapplyState(Actor actor) { if (!GetOrCreate(actor, out var state))