From 4ac062fdc5c8f5f67ea6dc34259b661f76455323 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 26 Jul 2023 18:17:09 +0200 Subject: [PATCH] Fix gpose weapon type when redrawing is necessary. --- Glamourer/Interop/Structs/Actor.cs | 3 +++ Glamourer/Interop/Structs/ActorData.cs | 2 +- Glamourer/State/StateListener.cs | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Glamourer/Interop/Structs/Actor.cs b/Glamourer/Interop/Structs/Actor.cs index 5694f90..58668f4 100644 --- a/Glamourer/Interop/Structs/Actor.cs +++ b/Glamourer/Interop/Structs/Actor.cs @@ -42,6 +42,9 @@ public readonly unsafe struct Actor : IEquatable public static implicit operator nint(Actor actor) => actor.Address; + public bool IsGPoseOrCutscene + => Index is >= (int)ScreenActor.CutsceneStart and < (int)ScreenActor.CutsceneEnd; + public ActorIdentifier GetIdentifier(ActorManager actors) => actors.FromObject(AsObject, out _, true, true, false); diff --git a/Glamourer/Interop/Structs/ActorData.cs b/Glamourer/Interop/Structs/ActorData.cs index a6df40c..ce11e34 100644 --- a/Glamourer/Interop/Structs/ActorData.cs +++ b/Glamourer/Interop/Structs/ActorData.cs @@ -45,5 +45,5 @@ public readonly struct ActorData } public ActorData OnlyGPose() - => new(Objects.Where(o => o.Index is >= (int)ScreenActor.GPosePlayer and < (int)ScreenActor.CutsceneEnd).ToList(), Label); + => new(Objects.Where(o => o.IsGPoseOrCutscene).ToList(), Label); } diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index cf4f8f7..86bed2e 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -37,6 +37,7 @@ public class StateListener : IDisposable private readonly FunModule _funModule; private readonly HumanModelList _humans; private readonly MovedEquipment _movedEquipment; + private readonly GPoseService _gpose; private ActorIdentifier _creatingIdentifier = ActorIdentifier.Invalid; private ActorState? _creatingState; @@ -51,7 +52,7 @@ public class StateListener : IDisposable public StateListener(StateManager manager, ItemManager items, PenumbraService penumbra, ActorService actors, Configuration config, SlotUpdating slotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, WeaponVisibilityChanged weaponVisibility, HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, FunModule funModule, HumanModelList humans, - StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects) + StateApplier applier, MovedEquipment movedEquipment, ObjectManager objects, GPoseService gpose) { _manager = manager; _items = items; @@ -69,6 +70,7 @@ public class StateListener : IDisposable _applier = applier; _movedEquipment = movedEquipment; _objects = objects; + _gpose = gpose; if (Enabled) Subscribe(); @@ -248,7 +250,7 @@ public class StateListener : IDisposable { // Only allow overwriting identical weapons var newWeapon = state.ModelData.Weapon(slot); - if (baseType is FullEquipType.Unknown || baseType == state.ModelData.Item(slot).Type) + if (baseType is FullEquipType.Unknown || baseType == state.ModelData.Item(slot).Type || _gpose.InGPose && actor.IsGPoseOrCutscene) actorWeapon = newWeapon; else if (actorWeapon.Set.Value != 0) actorWeapon = actorWeapon.With(newWeapon.Stain);