mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Append SetMetaState with object index.
This commit is contained in:
parent
091aadd4a6
commit
439849edfa
1 changed files with 27 additions and 3 deletions
|
|
@ -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;
|
||||||
|
|
||||||
|
|
@ -96,9 +97,9 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
|
||||||
if (!ResolveBonusItem(slot, bonusItemId, out var item))
|
if (!ResolveBonusItem(slot, bonusItemId, out var item))
|
||||||
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
|
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
|
||||||
|
|
||||||
var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key);
|
var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key);
|
||||||
var anyHuman = false;
|
var anyHuman = false;
|
||||||
var anyFound = false;
|
var anyFound = false;
|
||||||
var anyUnlocked = false;
|
var anyUnlocked = false;
|
||||||
foreach (var state in helpers.FindStates(playerName))
|
foreach (var state in helpers.FindStates(playerName))
|
||||||
{
|
{
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue