Further improvements.

This commit is contained in:
Ottermandias 2024-02-16 17:48:40 +01:00
parent 5f74f4b4d9
commit 59529476eb
15 changed files with 342 additions and 161 deletions

View file

@ -222,7 +222,8 @@ public class InternalStateEditor(
}
/// <summary> Change the value of a single material color table entry. </summary>
public bool ChangeMaterialValue(ActorState state, MaterialValueIndex index, in MaterialValueState newValue, StateSource source, out ColorRow? oldValue,
public bool ChangeMaterialValue(ActorState state, MaterialValueIndex index, in MaterialValueState newValue, StateSource source,
out ColorRow? oldValue,
uint key = 0)
{
// We already have an existing value.
@ -254,6 +255,10 @@ public class InternalStateEditor(
return state.Materials.TryAddValue(index, newValue);
}
/// <summary> Reset the value of a single material color table entry. </summary>
public bool ResetMaterialValue(ActorState state, MaterialValueIndex index, uint key = 0)
=> state.CanUnlock(key) && state.Materials.RemoveValue(index);
public bool ChangeMetaState(ActorState state, MetaIndex index, bool value, StateSource source, out bool oldValue,
uint key = 0)
{

View file

@ -177,6 +177,18 @@ public class StateEditor(
StateChanged.Invoke(StateChanged.Type.MaterialValue, settings.Source, state, actors, (oldValue, newValue.Game, index));
}
public void ResetMaterialValue(object data, MaterialValueIndex index, ApplySettings settings)
{
var state = (ActorState)data;
if (!Editor.ResetMaterialValue(state, index, settings.Key))
return;
var actors = Applier.ChangeMaterialValue(state, index, true);
Glamourer.Log.Verbose(
$"Reset material value in state {state.Identifier.Incognito(null)} to game value. [Affecting {actors.ToLazyString("nothing")}.]");
StateChanged.Invoke(StateChanged.Type.MaterialValue, settings.Source, state, actors, index);
}
/// <inheritdoc/>
public void ChangeMetaState(object data, MetaIndex index, bool value, ApplySettings settings)
{