diff --git a/Brio/Game/Posing/ModelTransformService.cs b/Brio/Game/Posing/ModelTransformService.cs index b4b8727a..b688106a 100644 --- a/Brio/Game/Posing/ModelTransformService.cs +++ b/Brio/Game/Posing/ModelTransformService.cs @@ -16,7 +16,7 @@ namespace Brio.Game.Posing; public unsafe class ModelTransformService : IDisposable { public delegate void SetPositionDelegate(StructsGameObject* gameObject, float x, float y, float z); - private readonly Hook _setPositionHook = null!; + public readonly Hook _setPositionHook = null!; private readonly EntityManager _entityManager; private readonly GPoseService _gPoseService; diff --git a/Brio/Game/Posing/SkeletonService.cs b/Brio/Game/Posing/SkeletonService.cs index b920de1d..fb8963f8 100644 --- a/Brio/Game/Posing/SkeletonService.cs +++ b/Brio/Game/Posing/SkeletonService.cs @@ -27,11 +27,12 @@ public unsafe class SkeletonService : IDisposable public event SkeletonUpdateEvent? SkeletonUpdateStart; public event SkeletonUpdateEvent? SkeletonUpdateEnd; - private delegate nint UpdateBonePhysicsDelegate(nint a1); - private readonly Hook _updateBonePhysicsHook = null!; + public delegate nint UpdateBonePhysicsDelegate(nint a1); - private delegate void FinalizeSkeletonsDelegate(nint a1); - private readonly Hook _finalizeSkeletonsHook = null!; + public readonly Hook _updateBonePhysicsHook = null!; + + public delegate void FinalizeSkeletonsDelegate(nint a1); + public readonly Hook _finalizeSkeletonsHook = null!; private readonly EntityManager _entityManager; private readonly ObjectMonitorService _monitorService; diff --git a/Brio/IPC/KtisisService.cs b/Brio/IPC/KtisisService.cs index b3871c61..ef4d9f95 100644 --- a/Brio/IPC/KtisisService.cs +++ b/Brio/IPC/KtisisService.cs @@ -1,4 +1,6 @@ using Brio.Config; +using Brio.Game.Posing; + using Dalamud.Plugin; using Dalamud.Plugin.Ipc; @@ -34,6 +36,7 @@ public override IDalamudPluginInterface GetPluginInterface() private readonly ICallGateSubscriber? _ktisisRefreshActors; private readonly ICallGateSubscriber? _ktisisIsPosing; + private readonly ICallGateSubscriber? _ktisisPosingChanged; public KtisisService(IDalamudPluginInterface pluginInterface, ConfigurationService configurationService) @@ -44,7 +47,10 @@ public KtisisService(IDalamudPluginInterface pluginInterface, ConfigurationServi _ktisisApiVersion = _pluginInterface.GetIpcSubscriber<(int, int)>("Ktisis.ApiVersion"); _ktisisRefreshActors = _pluginInterface.GetIpcSubscriber("Ktisis.RefreshActors"); _ktisisIsPosing = _pluginInterface.GetIpcSubscriber("Ktisis.IsPosing"); - } + + _ktisisPosingChanged = _pluginInterface.GetIpcSubscriber("Ktisis.PosingChanged"); + _ktisisPosingChanged.Subscribe(this.PosingChanged); + } public bool IsPosing => ((_ktisisIsPosing?.HasFunction ?? false) && (_ktisisIsPosing?.InvokeFunc() ?? false)); @@ -56,6 +62,20 @@ public void RefreshActors() } } + private void PosingChanged(bool isPosing) { + Brio.TryGetService(out var skeletonService); + Brio.TryGetService(out var modelTransformService); + if (isPosing) { + skeletonService._updateBonePhysicsHook.Disable(); + skeletonService._finalizeSkeletonsHook.Disable(); + modelTransformService._setPositionHook.Disable(); + } else { + skeletonService._updateBonePhysicsHook.Enable(); + skeletonService._finalizeSkeletonsHook.Enable(); + modelTransformService._setPositionHook.Enable(); + } + } + public override void Dispose() {