Touch up CanUnlock.

This commit is contained in:
Ottermandias 2025-12-19 13:56:36 +01:00
parent 5656d88c94
commit 643c83a6f3

View file

@ -228,12 +228,12 @@ public sealed class StateApi : IGlamourerApiState, IApiService, IDisposable
public GlamourerApiEc CanUnlock(int objectIndex, uint key, out bool isLocked, out bool canUnlock) public GlamourerApiEc CanUnlock(int objectIndex, uint key, out bool isLocked, out bool canUnlock)
{ {
var args = ApiHelpers.Args("Index", objectIndex, "Key", key); var args = ApiHelpers.Args("Index", objectIndex, "Key", key);
isLocked = false; // These seem like reasonable defaults. isLocked = false;
canUnlock = false; canUnlock = true;
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.InvalidState, args); // Possibly, the error type could be changed. I just looked at what was available. return ApiHelpers.Return(GlamourerApiEc.Success, args);
isLocked = state.IsLocked; isLocked = state.IsLocked;
canUnlock = state.CanUnlock(key); canUnlock = state.CanUnlock(key);
return ApiHelpers.Return(GlamourerApiEc.Success, args); return ApiHelpers.Return(GlamourerApiEc.Success, args);