Append SetMetaState with object index.

This commit is contained in:
Cordelia Mist 2025-01-24 11:35:53 -08:00
parent 091aadd4a6
commit 439849edfa

View file

@ -6,6 +6,7 @@ using Glamourer.State;
using OtterGui.Services; using OtterGui.Services;
using Penumbra.GameData.Enums; using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs; using Penumbra.GameData.Structs;
using static OtterGui.ItemSelector<T>;
namespace Glamourer.Api; namespace Glamourer.Api;
@ -127,6 +128,29 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
return ApiHelpers.Return(GlamourerApiEc.Success, args); return ApiHelpers.Return(GlamourerApiEc.Success, args);
} }
public GlamourerApiEc SetMetaState(int objectIndex, bool newValue, uint key, SetMetaFlag metaFlags)
{
var args = ApiHelpers.Args("Index", objectIndex, "Value", newValue, "Key", key, "Flags", metaFlags);
if (metaFlags == 0)
return ApiHelpers.Return(GlamourerApiEc.InvalidState, args);
if (helpers.FindState(objectIndex) is not { } state)
return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args);
if (!state.ModelData.IsHuman)
return ApiHelpers.Return(GlamourerApiEc.ActorNotHuman, args);
if (!state.CanUnlock(key))
return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args);
// Grab MetaIndices from attached flags, and update the states.
var indices = metaFlags.ToIndices();
foreach (var index in indices)
stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual);
return GlamourerApiEc.Success;
}
private bool ResolveItem(ApiEquipSlot apiSlot, ulong itemId, out EquipItem item) private bool ResolveItem(ApiEquipSlot apiSlot, ulong itemId, out EquipItem item)
{ {
var id = (CustomItemId)itemId; var id = (CustomItemId)itemId;