mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Added setMetaState by name
This commit is contained in:
parent
0ed4603ba5
commit
611200d311
1 changed files with 38 additions and 0 deletions
|
|
@ -150,6 +150,44 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
|
|||
return GlamourerApiEc.Success;
|
||||
}
|
||||
|
||||
public GlamourerApiEc SetMetaStateName(string playerName, SetMetaFlag metaStates, bool newValue, uint key, ApplyFlag flags)
|
||||
{
|
||||
var args = ApiHelpers.Args("Name", playerName, "MetaStates", metaStates, "NewValue", newValue, "Key", key, "ApplyFlags", flags);
|
||||
if (metaStates == 0)
|
||||
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
|
||||
|
||||
var indices = metaStates.ToIndices();
|
||||
var anyHuman = false;
|
||||
var anyFound = false;
|
||||
var anyUnlocked = false;
|
||||
foreach (var state in helpers.FindStates(playerName))
|
||||
{
|
||||
anyFound = true;
|
||||
if (!state.ModelData.IsHuman)
|
||||
continue;
|
||||
|
||||
anyHuman = true;
|
||||
if (!state.CanUnlock(key))
|
||||
continue;
|
||||
|
||||
anyUnlocked = true;
|
||||
// update all MetaStates for this ActorState
|
||||
foreach (var index in indices)
|
||||
stateManager.ChangeMetaState(state, index, newValue, ApplySettings.Manual);
|
||||
}
|
||||
|
||||
if (!anyFound)
|
||||
return ApiHelpers.Return(GlamourerApiEc.ActorNotFound, args);
|
||||
|
||||
if (!anyHuman)
|
||||
return ApiHelpers.Return(GlamourerApiEc.ActorNotHuman, args);
|
||||
|
||||
if (!anyUnlocked)
|
||||
return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args);
|
||||
|
||||
return ApiHelpers.Return(GlamourerApiEc.Success, args);
|
||||
}
|
||||
|
||||
private bool ResolveItem(ApiEquipSlot apiSlot, ulong itemId, out EquipItem item)
|
||||
{
|
||||
var id = (CustomItemId)itemId;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue