Minor touch up ReapplyState.

This commit is contained in:
Ottermandias 2025-12-19 14:01:51 +01:00
parent 643c83a6f3
commit 77f3912bf2

View file

@ -129,10 +129,10 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
public GlamourerApiEc ReapplyState(int objectIndex, uint key, ApplyFlag flags) public GlamourerApiEc ReapplyState(int objectIndex, uint key, ApplyFlag flags)
{ {
var args = ApiHelpers.Args("Index", objectIndex, "Key", key, "Flags", flags); var args = ApiHelpers.Args("Index", objectIndex, "Key", key, "Flags", flags);
if (_helpers.FindExistingState(objectIndex, out var state) != GlamourerApiEc.Success) if (_helpers.FindExistingState(objectIndex, out var state) is not GlamourerApiEc.Success)
return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args); return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args);
if (state == null) if (state is null)
return ApiHelpers.Return(GlamourerApiEc.NothingDone, args); return ApiHelpers.Return(GlamourerApiEc.NothingDone, args);
if (!state.CanUnlock(key)) if (!state.CanUnlock(key))
@ -359,14 +359,14 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
private void Reapply(Actor actor, ActorState state, uint key, ApplyFlag flags) private void Reapply(Actor actor, ActorState state, uint key, ApplyFlag flags)
{ {
var source = (flags & ApplyFlag.Once) != 0 ? StateSource.IpcManual : StateSource.IpcFixed; var source = flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcFixed : StateSource.IpcManual;
_stateManager.ReapplyState(actor, state, false, source, true); _stateManager.ReapplyState(actor, state, false, source, true);
ApiHelpers.Lock(state, key, flags); ApiHelpers.Lock(state, key, flags);
} }
private void Revert(ActorState state, uint key, ApplyFlag flags) private void Revert(ActorState state, uint key, ApplyFlag flags)
{ {
var source = (flags & ApplyFlag.Once) != 0 ? StateSource.IpcManual : StateSource.IpcFixed; var source = flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcFixed : StateSource.IpcManual;
switch (flags & (ApplyFlag.Equipment | ApplyFlag.Customization)) switch (flags & (ApplyFlag.Equipment | ApplyFlag.Customization))
{ {
case ApplyFlag.Equipment: _stateManager.ResetEquip(state, source, key); break; case ApplyFlag.Equipment: _stateManager.ResetEquip(state, source, key); break;