mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-02-21 15:07:43 +01:00
Add state editing and tracking.
This commit is contained in:
parent
5cdcb9288e
commit
fb7aac5228
10 changed files with 383 additions and 235 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using Glamourer.Designs;
|
||||
using Glamourer.GameData;
|
||||
using Glamourer.Interop;
|
||||
using Glamourer.Interop.Material;
|
||||
using Glamourer.Interop.Penumbra;
|
||||
using Glamourer.Interop.Structs;
|
||||
using Glamourer.Services;
|
||||
|
|
@ -275,6 +276,41 @@ public class StateApplier(
|
|||
return data;
|
||||
}
|
||||
|
||||
public unsafe void ChangeMaterialValue(ActorData data, MaterialValueIndex index, Vector3? value, bool force)
|
||||
{
|
||||
if (!force && !_config.UseAdvancedParameters)
|
||||
return;
|
||||
|
||||
foreach (var actor in data.Objects.Where(a => a is { IsCharacter: true, Model.IsHuman: true }))
|
||||
{
|
||||
if (!index.TryGetTexture(actor, out var texture))
|
||||
continue;
|
||||
|
||||
if (!index.TryGetColorTable(texture, out var table))
|
||||
continue;
|
||||
|
||||
Vector3 actualValue;
|
||||
if (value.HasValue)
|
||||
actualValue = value.Value;
|
||||
else if (!PrepareColorSet.TryGetColorTable(actor, index, out var baseTable)
|
||||
|| !index.DataIndex.TryGetValue(baseTable[index.RowIndex], out actualValue))
|
||||
continue;
|
||||
|
||||
if (!index.DataIndex.SetValue(ref table[index.RowIndex], actualValue))
|
||||
continue;
|
||||
|
||||
MaterialService.ReplaceColorTable(texture, table);
|
||||
}
|
||||
}
|
||||
|
||||
public ActorData ChangeMaterialValue(ActorState state, MaterialValueIndex index, bool apply)
|
||||
{
|
||||
var data = GetData(state);
|
||||
if (apply)
|
||||
ChangeMaterialValue(data, index, state.Materials.TryGetValue(index, out var v) ? v.Model : null, state.IsLocked);
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary> Apply the entire state of an actor to all relevant actors, either via immediate redraw or piecewise. </summary>
|
||||
/// <param name="state"> The state to apply. </param>
|
||||
/// <param name="redraw"> Whether a redraw should be forced. </param>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue