mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-13 12:14:18 +01:00
Handle state reapplication on temporary mod changes.
This commit is contained in:
parent
cdaabc05e9
commit
d6575e6e68
2 changed files with 32 additions and 6 deletions
|
|
@ -1,9 +1,10 @@
|
|||
using Glamourer.State;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Api.Enums;
|
||||
|
||||
namespace Glamourer.Interop.Penumbra;
|
||||
|
||||
public class PenumbraAutoRedraw : IDisposable
|
||||
public class PenumbraAutoRedraw : IDisposable, IRequiredService
|
||||
{
|
||||
private readonly Configuration _config;
|
||||
private readonly PenumbraService _penumbra;
|
||||
|
|
@ -24,11 +25,29 @@ public class PenumbraAutoRedraw : IDisposable
|
|||
|
||||
private void OnModSettingChange(ModSettingChange type, string name, string mod, bool inherited)
|
||||
{
|
||||
if (!_config.AutoRedrawEquipOnChanges && type is not ModSettingChange.TemporaryMod)
|
||||
return;
|
||||
if (type is ModSettingChange.TemporaryMod)
|
||||
{
|
||||
_objects.Update();
|
||||
foreach (var (id, state) in _state)
|
||||
{
|
||||
if (!_objects.TryGetValue(id, out var actors) || !actors.Valid)
|
||||
continue;
|
||||
|
||||
var playerName = _penumbra.GetCurrentPlayerCollection();
|
||||
if (playerName == name)
|
||||
_state.ReapplyState(_objects.Player, StateSource.IpcManual);
|
||||
var collection = _penumbra.GetActorCollection(actors.Objects[0]);
|
||||
if (collection != name)
|
||||
continue;
|
||||
|
||||
foreach (var actor in actors.Objects)
|
||||
_state.ReapplyState(actor, state, StateSource.IpcManual);
|
||||
Glamourer.Log.Debug($"Automatically applied mod settings of type {type} to {id.Incognito(null)}.");
|
||||
}
|
||||
}
|
||||
else if (_config.AutoRedrawEquipOnChanges)
|
||||
{
|
||||
var playerName = _penumbra.GetCurrentPlayerCollection();
|
||||
if (playerName == name)
|
||||
_state.ReapplyState(_objects.Player, StateSource.IpcManual);
|
||||
Glamourer.Log.Debug($"Automatically applied mod settings of type {type} to {_objects.PlayerData.Identifier.Incognito(null)} (Local Player).");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -344,6 +344,13 @@ public sealed class StateManager(
|
|||
StateChanged.Invoke(StateChanged.Type.Reapply, source, state, data, null);
|
||||
}
|
||||
|
||||
public void ReapplyState(Actor actor, ActorState state, StateSource source)
|
||||
{
|
||||
var data = Applier.ApplyAll(state,
|
||||
!actor.Model.IsHuman || CustomizeArray.Compare(actor.Model.GetCustomize(), state.ModelData.Customize).RequiresRedraw(), false);
|
||||
StateChanged.Invoke(StateChanged.Type.Reapply, source, state, data, null);
|
||||
}
|
||||
|
||||
public void DeleteState(ActorIdentifier identifier)
|
||||
=> _states.Remove(identifier);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue