Maybe fix problem with Mare syncing wrong with Restricted Gear protection enabled.

This commit is contained in:
Ottermandias 2023-09-27 01:16:22 +02:00
parent ad577c7005
commit 2e9a30427d
3 changed files with 25 additions and 9 deletions

View file

@ -1,5 +1,6 @@
using System.Linq;
using Glamourer.Customization;
using Glamourer.Events;
using Glamourer.Interop;
using Glamourer.Interop.Penumbra;
using Glamourer.Interop.Structs;
@ -91,7 +92,7 @@ public class StateApplier
/// This uses the current customization of the model to potentially prevent restricted gear types from appearing.
/// This never requires redrawing.
/// </summary>
public void ChangeArmor(ActorData data, EquipSlot slot, CharacterArmor armor, bool isHatVisible = true)
public void ChangeArmor(ActorData data, EquipSlot slot, CharacterArmor armor, bool checkRestrictions, bool isHatVisible = true)
{
if (slot is EquipSlot.Head && !isHatVisible)
return;
@ -102,18 +103,26 @@ public class StateApplier
if (!mdl.IsHuman)
continue;
var customize = mdl.GetCustomize();
var (_, resolvedItem) = _items.ResolveRestrictedGear(armor, slot, customize.Race, customize.Gender);
_updateSlot.UpdateSlot(actor.Model, slot, resolvedItem);
if (checkRestrictions)
{
var customize = mdl.GetCustomize();
var (_, resolvedItem) = _items.ResolveRestrictedGear(armor, slot, customize.Race, customize.Gender);
_updateSlot.UpdateSlot(actor.Model, slot, resolvedItem);
}
else
{
_updateSlot.UpdateSlot(actor.Model, slot, armor);
}
}
}
/// <inheritdoc cref="ChangeArmor(ActorData,EquipSlot,CharacterArmor,bool)"/>
/// <inheritdoc cref="ChangeArmor(ActorData,EquipSlot,CharacterArmor,bool,bool)"/>
public ActorData ChangeArmor(ActorState state, EquipSlot slot, bool apply)
{
// If the source is not IPC we do not want to apply restrictions.
var data = GetData(state);
if (apply)
ChangeArmor(data, slot, state.ModelData.Armor(slot), state.ModelData.IsHatVisible());
ChangeArmor(data, slot, state.ModelData.Armor(slot), state[slot, false] is not StateChanged.Source.Ipc, state.ModelData.IsHatVisible());
return data;
}

View file

@ -225,12 +225,19 @@ public class StateListener : IDisposable
if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)
return;
// If the model comes from IPC it is probably from Mare,
// then we do not want to use our restricted gear protection
// since we assume the player has that gear modded to availability.
var locked = false;
if (actor.Identifier(_actors.AwaitedService, out var identifier)
&& _manager.TryGetValue(identifier, out var state))
{
HandleEquipSlot(actor, state, slot, ref armor.Value);
locked = state[slot, false] is StateChanged.Source.Ipc;
}
_funModule.ApplyFun(actor, ref armor.Value, slot);
if (!_config.UseRestrictedGearProtection)
if (!_config.UseRestrictedGearProtection || locked)
return;
var customize = model.GetCustomize();
@ -263,7 +270,7 @@ public class StateListener : IDisposable
_applier.ChangeWeapon(objects, slot, currentItem, stain);
break;
default:
_applier.ChangeArmor(objects, slot, current.ToArmor(), state.ModelData.IsHatVisible());
_applier.ChangeArmor(objects, slot, current.ToArmor(), state[slot, false] is not StateChanged.Source.Ipc, state.ModelData.IsHatVisible());
break;
}
}

View file

@ -408,7 +408,7 @@ public class StateManager : IReadOnlyDictionary<ActorIdentifier, ActorState>
{
_applier.ChangeCustomize(actors, state.ModelData.Customize);
foreach (var slot in EquipSlotExtensions.EqdpSlots)
_applier.ChangeArmor(actors, slot, state.ModelData.Armor(slot), state.ModelData.IsHatVisible());
_applier.ChangeArmor(actors, slot, state.ModelData.Armor(slot), state[slot, false] is not StateChanged.Source.Ipc, state.ModelData.IsHatVisible());
var mainhandActors = state.ModelData.MainhandType != state.BaseData.MainhandType ? actors.OnlyGPose() : actors;
_applier.ChangeMainhand(mainhandActors, state.ModelData.Item(EquipSlot.MainHand), state.ModelData.Stain(EquipSlot.MainHand));
var offhandActors = state.ModelData.OffhandType != state.BaseData.OffhandType ? actors.OnlyGPose() : actors;