Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Brio/Game/Posing/ModelTransformService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SetPositionDelegate> _setPositionHook = null!;
public readonly Hook<SetPositionDelegate> _setPositionHook = null!;

private readonly EntityManager _entityManager;
private readonly GPoseService _gPoseService;
Expand Down
9 changes: 5 additions & 4 deletions Brio/Game/Posing/SkeletonService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UpdateBonePhysicsDelegate> _updateBonePhysicsHook = null!;
public delegate nint UpdateBonePhysicsDelegate(nint a1);

private delegate void FinalizeSkeletonsDelegate(nint a1);
private readonly Hook<FinalizeSkeletonsDelegate> _finalizeSkeletonsHook = null!;
public readonly Hook<UpdateBonePhysicsDelegate> _updateBonePhysicsHook = null!;

public delegate void FinalizeSkeletonsDelegate(nint a1);
public readonly Hook<FinalizeSkeletonsDelegate> _finalizeSkeletonsHook = null!;

private readonly EntityManager _entityManager;
private readonly ObjectMonitorService _monitorService;
Expand Down
22 changes: 21 additions & 1 deletion Brio/IPC/KtisisService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Brio.Config;
using Brio.Game.Posing;

using Dalamud.Plugin;
using Dalamud.Plugin.Ipc;

Expand Down Expand Up @@ -34,6 +36,7 @@ public override IDalamudPluginInterface GetPluginInterface()

private readonly ICallGateSubscriber<bool>? _ktisisRefreshActors;
private readonly ICallGateSubscriber<bool>? _ktisisIsPosing;
private readonly ICallGateSubscriber<bool, bool>? _ktisisPosingChanged;


public KtisisService(IDalamudPluginInterface pluginInterface, ConfigurationService configurationService)
Expand All @@ -44,7 +47,10 @@ public KtisisService(IDalamudPluginInterface pluginInterface, ConfigurationServi
_ktisisApiVersion = _pluginInterface.GetIpcSubscriber<(int, int)>("Ktisis.ApiVersion");
_ktisisRefreshActors = _pluginInterface.GetIpcSubscriber<bool>("Ktisis.RefreshActors");
_ktisisIsPosing = _pluginInterface.GetIpcSubscriber<bool>("Ktisis.IsPosing");
}

_ktisisPosingChanged = _pluginInterface.GetIpcSubscriber<bool, bool>("Ktisis.PosingChanged");
_ktisisPosingChanged.Subscribe(this.PosingChanged);
}

public bool IsPosing => ((_ktisisIsPosing?.HasFunction ?? false) && (_ktisisIsPosing?.InvokeFunc() ?? false));

Expand All @@ -56,6 +62,20 @@ public void RefreshActors()
}
}

private void PosingChanged(bool isPosing) {
Brio.TryGetService<SkeletonService>(out var skeletonService);
Brio.TryGetService<ModelTransformService>(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()
{

Expand Down