Fix issues with Visor and Aesthetician

This commit is contained in:
Ottermandias 2023-08-30 18:04:28 +02:00
parent 937e385cbc
commit 5417013bc3
3 changed files with 23 additions and 55 deletions

View file

@ -1,46 +0,0 @@
using Glamourer.Customization;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Glamourer.Designs;
public interface IDesign
{
public uint GetModelId();
public bool SetModelId(uint modelId);
public EquipItem GetEquipItem(EquipSlot slot);
public bool SetEquipItem(EquipItem item);
public StainId GetStain(EquipSlot slot);
public bool SetStain(EquipSlot slot, StainId stain);
public CustomizeValue GetCustomizeValue(CustomizeIndex type);
public bool SetCustomizeValue(CustomizeIndex type);
public bool DoApplyEquip(EquipSlot slot);
public bool DoApplyStain(EquipSlot slot);
public bool DoApplyCustomize(CustomizeIndex index);
public bool SetApplyEquip(EquipSlot slot, bool value);
public bool SetApplyStain(EquipSlot slot, bool value);
public bool SetApplyCustomize(CustomizeIndex slot, bool value);
public bool IsWet();
public bool SetIsWet(bool value);
public bool IsHatVisible();
public bool DoApplyHatVisible();
public bool SetHatVisible(bool value);
public bool SetApplyHatVisible(bool value);
public bool IsVisorToggled();
public bool DoApplyVisorToggle();
public bool SetVisorToggle(bool value);
public bool SetApplyVisorToggle(bool value);
public bool IsWeaponVisible();
public bool DoApplyWeaponVisible();
public bool SetWeaponVisible(bool value);
public bool SetApplyWeaponVisible(bool value);
}

View file

@ -1,4 +1,5 @@
using System;
using System.Threading;
using Dalamud.Hooking;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
@ -19,6 +20,9 @@ public unsafe class ChangeCustomizeService : EventWrapper<Action<Model, Ref<Cust
{
private readonly PenumbraReloaded _penumbraReloaded;
/// <summary> Check whether we in a manual customize update, in which case we need to not toggle certain flags. </summary>
public static readonly ThreadLocal<bool> InUpdate = new(() => false);
public enum Priority
{
/// <seealso cref="State.StateListener.OnCustomizeChange"/>
@ -62,9 +66,12 @@ public unsafe class ChangeCustomizeService : EventWrapper<Action<Model, Ref<Cust
{
if (!model.IsHuman)
return false;
Glamourer.Log.Verbose($"[ChangeCustomize] Invoked on 0x{model.Address:X} with {customize}.");
return _changeCustomizeHook.Original(model.AsHuman, customize.Data, 1);
InUpdate.Value = true;
var ret = _changeCustomizeHook.Original(model.AsHuman, customize.Data, 1);
InUpdate.Value = false;
return ret;
}
public bool UpdateCustomize(Actor actor, CustomizeData customize)

View file

@ -160,10 +160,13 @@ public class StateListener : IDisposable
private unsafe void OnCustomizeChange(Model model, Ref<Customize> customize)
{
if (_condition[ConditionFlag.CreatingCharacter] || !model.IsHuman)
if (!model.IsHuman)
return;
var actor = _penumbra.GameObjectFromDrawObject(model);
if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)
return;
if (!actor.Identifier(_actors.AwaitedService, out var identifier)
|| !_manager.TryGetValue(identifier, out var state))
return;
@ -218,10 +221,10 @@ public class StateListener : IDisposable
/// </summary>
private void OnSlotUpdating(Model model, EquipSlot slot, Ref<CharacterArmor> armor, Ref<ulong> returnValue)
{
if (_condition[ConditionFlag.CreatingCharacter])
var actor = _penumbra.GameObjectFromDrawObject(model);
if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)
return;
var actor = _penumbra.GameObjectFromDrawObject(model);
if (actor.Identifier(_actors.AwaitedService, out var identifier)
&& _manager.TryGetValue(identifier, out var state))
HandleEquipSlot(actor, state, slot, ref armor.Value);
@ -274,7 +277,7 @@ public class StateListener : IDisposable
/// </summary>
private void OnWeaponLoading(Actor actor, EquipSlot slot, Ref<CharacterWeapon> weapon)
{
if (_condition[ConditionFlag.CreatingCharacter])
if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)
return;
// Fist weapon gauntlet hack.
@ -466,13 +469,17 @@ public class StateListener : IDisposable
/// <summary> Handle visor state changes made by the game. </summary>
private void OnVisorChange(Model model, Ref<bool> value)
{
if (_condition[ConditionFlag.CreatingCharacter])
// Skip updates when in customize update.
if (ChangeCustomizeService.InUpdate.IsValueCreated && ChangeCustomizeService.InUpdate.Value)
return;
// Find appropriate actor and state.
// We do not need to handle fixed designs,
// since a fixed design would already have established state-tracking.
var actor = _penumbra.GameObjectFromDrawObject(model);
if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)
return;
if (!actor.Identifier(_actors.AwaitedService, out var identifier))
return;
@ -499,7 +506,7 @@ public class StateListener : IDisposable
/// <summary> Handle Hat Visibility changes. These act on the game object. </summary>
private void OnHeadGearVisibilityChange(Actor actor, Ref<bool> value)
{
if (_condition[ConditionFlag.CreatingCharacter])
if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)
return;
// Find appropriate state.
@ -532,7 +539,7 @@ public class StateListener : IDisposable
/// <summary> Handle Weapon Visibility changes. These act on the game object. </summary>
private void OnWeaponVisibilityChange(Actor actor, Ref<bool> value)
{
if (_condition[ConditionFlag.CreatingCharacter])
if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart)
return;
// Find appropriate state.