Skip to content

Commit

Permalink
Make the player not update too often on changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Feb 24, 2024
1 parent e4324bc commit 3e9edf3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Glamourer/Interop/Penumbra/PenumbraAutoRedraw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void Dispose()

private readonly ConcurrentQueue<(ActorState, Action, int)> _actions = [];
private readonly ConcurrentSet<ActorState> _skips = [];
private DateTime _frame;

private void OnStateChange(StateChanged.Type type, StateSource source, ActorState state, ActorData _1, object? _2)
{
Expand Down Expand Up @@ -69,6 +70,7 @@ private void OnFramework(IFramework _)
private void OnModSettingChange(ModSettingChange type, string name, string mod, bool inherited)
{
if (type is ModSettingChange.TemporaryMod)
{
_framework.RunOnFrameworkThread(() =>
{
_objects.Update();
Expand All @@ -89,7 +91,15 @@ private void OnModSettingChange(ModSettingChange type, string name, string mod,
}, WaitFrames));
}
});
}
else if (_config.AutoRedrawEquipOnChanges)
{
// Only update once per frame.
var currentFrame = _framework.LastUpdateUTC;
if (currentFrame == _frame)
return;

_frame = currentFrame;
_framework.RunOnFrameworkThread(() =>
{
var playerName = _penumbra.GetCurrentPlayerCollection();
Expand All @@ -98,5 +108,6 @@ private void OnModSettingChange(ModSettingChange type, string name, string mod,
Glamourer.Log.Debug(
$"Automatically applied mod settings of type {type} to {_objects.PlayerData.Identifier.Incognito(null)} (Local Player).");
});
}
}
}

0 comments on commit 3e9edf3

Please sign in to comment.