Fix an issue with game-base automation not respecting manual changes on pure redraws.

This commit is contained in:
Ottermandias 2023-08-30 00:46:20 +02:00
parent 68e85a640c
commit 937e385cbc
2 changed files with 54 additions and 2 deletions

View file

@ -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)

View file

@ -378,7 +378,7 @@ public class StateManager : IReadOnlyDictionary<ActorIdentifier, ActorState>
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<ActorIdentifier, ActorState>
state.ModelData = state.BaseData;
foreach (var index in Enum.GetValues<CustomizeIndex>())
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<ActorIdentifier, ActorState>
_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<CustomizeIndex>().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))