diff --git a/Glamourer/Designs/IDesign.cs b/Glamourer/Designs/IDesign.cs deleted file mode 100644 index 8544e69..0000000 --- a/Glamourer/Designs/IDesign.cs +++ /dev/null @@ -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); -} diff --git a/Glamourer/Interop/ChangeCustomizeService.cs b/Glamourer/Interop/ChangeCustomizeService.cs index 674cae0..f3ca2b5 100644 --- a/Glamourer/Interop/ChangeCustomizeService.cs +++ b/Glamourer/Interop/ChangeCustomizeService.cs @@ -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 Check whether we in a manual customize update, in which case we need to not toggle certain flags. + public static readonly ThreadLocal InUpdate = new(() => false); + public enum Priority { /// @@ -62,9 +66,12 @@ public unsafe class ChangeCustomizeService : EventWrapper 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 /// private void OnSlotUpdating(Model model, EquipSlot slot, Ref armor, Ref 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 /// private void OnWeaponLoading(Actor actor, EquipSlot slot, Ref 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 /// Handle visor state changes made by the game. private void OnVisorChange(Model model, Ref 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 /// Handle Hat Visibility changes. These act on the game object. private void OnHeadGearVisibilityChange(Actor actor, Ref 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 /// Handle Weapon Visibility changes. These act on the game object. private void OnWeaponVisibilityChange(Actor actor, Ref value) { - if (_condition[ConditionFlag.CreatingCharacter]) + if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart) return; // Find appropriate state.