mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
.
This commit is contained in:
parent
0b22dd9760
commit
6a5242b8ab
6 changed files with 64 additions and 44 deletions
|
|
@ -205,15 +205,14 @@ public unsafe struct DesignData
|
|||
}
|
||||
|
||||
|
||||
public bool LoadNonHuman(uint modelId, Customize customize, byte* equipData)
|
||||
public bool LoadNonHuman(uint modelId, Customize customize, nint equipData)
|
||||
{
|
||||
ModelId = modelId;
|
||||
IsHuman = false;
|
||||
Customize.Load(customize);
|
||||
fixed (byte* ptr = _equipmentBytes)
|
||||
{
|
||||
MemoryUtility.MemCpyUnchecked(ptr, equipData, 40);
|
||||
MemoryUtility.MemSet(ptr + 40, 0, 8);
|
||||
MemoryUtility.MemCpyUnchecked(ptr, (byte*) equipData, 40);
|
||||
}
|
||||
|
||||
SetHatVisible(true);
|
||||
|
|
@ -221,19 +220,14 @@ public unsafe struct DesignData
|
|||
SetVisor(false);
|
||||
fixed (uint* ptr = _itemIds)
|
||||
{
|
||||
MemoryUtility.MemSet(ptr, 0, 12 * 4);
|
||||
MemoryUtility.MemSet(ptr, 0, 10 * 4);
|
||||
}
|
||||
|
||||
fixed (ushort* ptr = _iconIds)
|
||||
{
|
||||
MemoryUtility.MemSet(ptr, 0, 12 * 2);
|
||||
MemoryUtility.MemSet(ptr, 0, 10 * 2);
|
||||
}
|
||||
|
||||
_secondaryMainhand = 0;
|
||||
_secondaryOffhand = 0;
|
||||
_typeMainhand = FullEquipType.Unknown;
|
||||
_typeOffhand = FullEquipType.Unknown;
|
||||
|
||||
_nameHead = string.Empty;
|
||||
_nameBody = string.Empty;
|
||||
_nameHands = string.Empty;
|
||||
|
|
@ -244,8 +238,6 @@ public unsafe struct DesignData
|
|||
_nameWrists = string.Empty;
|
||||
_nameRFinger = string.Empty;
|
||||
_nameLFinger = string.Empty;
|
||||
_nameMainhand = string.Empty;
|
||||
_nameOffhand = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using Newtonsoft.Json.Linq;
|
|||
using OtterGui;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
using static OtterGui.Raii.ImRaii;
|
||||
|
||||
namespace Glamourer.Designs;
|
||||
|
||||
|
|
@ -259,6 +260,28 @@ public class DesignManager
|
|||
_event.Invoke(DesignChanged.Type.WriteProtection, design, value);
|
||||
}
|
||||
|
||||
public void ChangeModelId(Design design, uint modelId, Customize customize, nint equipData, bool isHuman)
|
||||
{
|
||||
var oldValue = design.DesignData.ModelId;
|
||||
|
||||
if (!isHuman)
|
||||
{
|
||||
design.DesignData.LoadNonHuman(modelId, customize, equipData);
|
||||
}
|
||||
else if (!design.DesignData.IsHuman)
|
||||
{
|
||||
design.DesignData.IsHuman = true;
|
||||
design.DesignData.ModelId = modelId;
|
||||
design.DesignData.SetDefaultEquipment(_items);
|
||||
design.DesignData.Customize = Customize.Default;
|
||||
}
|
||||
|
||||
design.LastEdit = DateTimeOffset.UtcNow;
|
||||
Glamourer.Log.Debug($"Changed model id in design {design.Identifier} from {oldValue} to {modelId}.");
|
||||
_saveService.QueueSave(design);
|
||||
_event.Invoke(DesignChanged.Type.ModelId, design, (oldValue, modelId));
|
||||
}
|
||||
|
||||
/// <summary> Change a customization value. </summary>
|
||||
public void ChangeCustomize(Design design, CustomizeIndex idx, CustomizeValue value)
|
||||
{
|
||||
|
|
@ -454,6 +477,36 @@ public class DesignManager
|
|||
/// <summary> Apply an entire design based on its appliance rules piece by piece. </summary>
|
||||
public void ApplyDesign(Design design, DesignBase other)
|
||||
{
|
||||
ChangeModelId(design, other.DesignData.ModelId, other.DesignData.Customize, other.DesignData.GetEquipmentPtr(),
|
||||
other.DesignData.IsHuman);
|
||||
|
||||
if (other.DoApplyWetness())
|
||||
design.DesignData.SetIsWet(other.DesignData.IsWet());
|
||||
if (other.DoApplyHatVisible())
|
||||
design.DesignData.SetHatVisible(other.DesignData.IsHatVisible());
|
||||
if (other.DoApplyVisorToggle())
|
||||
design.DesignData.SetVisor(other.DesignData.IsVisorToggled());
|
||||
if (other.DoApplyWeaponVisible())
|
||||
design.DesignData.SetWeaponVisible(other.DesignData.IsWeaponVisible());
|
||||
|
||||
if (design.DesignData.IsHuman)
|
||||
{
|
||||
foreach (var index in Enum.GetValues<CustomizeIndex>())
|
||||
{
|
||||
if (other.DoApplyCustomize(index))
|
||||
ChangeCustomize(design, index, other.DesignData.Customize[index]);
|
||||
}
|
||||
|
||||
foreach (var slot in EquipSlotExtensions.EqdpSlots)
|
||||
{
|
||||
if (other.DoApplyEquip(slot))
|
||||
ChangeEquip(design, slot, other.DesignData.Item(slot));
|
||||
|
||||
if (other.DoApplyStain(slot))
|
||||
ChangeStain(design, slot, other.DesignData.Stain(slot));
|
||||
}
|
||||
}
|
||||
|
||||
if (other.DoApplyEquip(EquipSlot.MainHand))
|
||||
ChangeWeapon(design, EquipSlot.MainHand, other.DesignData.Item(EquipSlot.MainHand));
|
||||
|
||||
|
|
@ -465,31 +518,6 @@ public class DesignManager
|
|||
|
||||
if (other.DoApplyStain(EquipSlot.OffHand))
|
||||
ChangeStain(design, EquipSlot.OffHand, other.DesignData.Stain(EquipSlot.OffHand));
|
||||
|
||||
|
||||
foreach (var slot in EquipSlotExtensions.EqdpSlots)
|
||||
{
|
||||
if (other.DoApplyEquip(slot))
|
||||
ChangeEquip(design, slot, other.DesignData.Item(slot));
|
||||
|
||||
if (other.DoApplyStain(slot))
|
||||
ChangeStain(design, slot, other.DesignData.Stain(slot));
|
||||
}
|
||||
|
||||
foreach (var index in Enum.GetValues<CustomizeIndex>())
|
||||
{
|
||||
if (other.DoApplyCustomize(index))
|
||||
ChangeCustomize(design, index, other.DesignData.Customize[index]);
|
||||
}
|
||||
|
||||
if (other.DoApplyHatVisible())
|
||||
design.DesignData.SetHatVisible(other.DesignData.IsHatVisible());
|
||||
if (other.DoApplyVisorToggle())
|
||||
design.DesignData.SetVisor(other.DesignData.IsVisorToggled());
|
||||
if (other.DoApplyWeaponVisible())
|
||||
design.DesignData.SetWeaponVisible(other.DesignData.IsWeaponVisible());
|
||||
if (other.DoApplyWetness())
|
||||
design.DesignData.SetIsWet(other.DesignData.IsWet());
|
||||
}
|
||||
|
||||
private void MigrateOldDesigns()
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ public sealed class DesignChanged : EventWrapper<Action<DesignChanged.Type, Desi
|
|||
/// <summary> An existing design had an existing associated mod removed. Data is the Mod and its Settings [(Mod, ModSettings)]. </summary>
|
||||
RemovedMod,
|
||||
|
||||
/// <summary> An existing design had its model id changed. This means everything else might also have changed. Data is the old value and the new value. [(uint, uint)]. </summary>
|
||||
ModelId,
|
||||
|
||||
/// <summary> An existing design had a customization changed. Data is the old value, the new value and the type [(CustomizeValue, CustomizeValue, CustomizeIndex)]. </summary>
|
||||
Customize,
|
||||
|
||||
|
|
|
|||
|
|
@ -65,11 +65,8 @@ public class StateEditor
|
|||
}
|
||||
else
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
state.ModelData.LoadNonHuman(modelId, customize, (byte*)equipData);
|
||||
state[ActorState.MetaIndex.ModelId] = source;
|
||||
}
|
||||
state.ModelData.LoadNonHuman(modelId, customize, equipData);
|
||||
state[ActorState.MetaIndex.ModelId] = source;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ public class StateListener : IDisposable
|
|||
if (isHuman)
|
||||
state.BaseData = _manager.FromActor(actor, false);
|
||||
else
|
||||
state.BaseData.LoadNonHuman(modelId, *(Customize*)customizeData, (byte*)equipData);
|
||||
state.BaseData.LoadNonHuman(modelId, *(Customize*)customizeData, equipData);
|
||||
|
||||
return UpdateState.Change;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class StateManager : IReadOnlyDictionary<ActorIdentifier, ActorState>
|
|||
if (!_humans.IsHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId))
|
||||
{
|
||||
ret.LoadNonHuman((uint)actor.AsCharacter->CharacterData.ModelCharaId, *(Customize*)&actor.AsCharacter->DrawData.CustomizeData,
|
||||
(byte*)&actor.AsCharacter->DrawData.Head);
|
||||
(nint) (&actor.AsCharacter->DrawData.Head));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue