add heels support
This commit is contained in:
@@ -11,6 +11,7 @@ using System.Collections.Concurrent;
|
||||
namespace MareSynchronos.Managers
|
||||
{
|
||||
public delegate void PenumbraRedrawEvent(IntPtr address, int objTblIdx);
|
||||
public delegate void HeelsOffsetChange(float change);
|
||||
public class IpcManager : IDisposable
|
||||
{
|
||||
private readonly ICallGateSubscriber<int> _glamourerApiVersion;
|
||||
@@ -33,6 +34,13 @@ namespace MareSynchronos.Managers
|
||||
private readonly ICallGateSubscriber<string, string[]>? _reverseResolvePlayer;
|
||||
private readonly ICallGateSubscriber<string, string, Dictionary<string, string>, string, int, int>
|
||||
_penumbraSetTemporaryMod;
|
||||
|
||||
private readonly ICallGateSubscriber<string> _heelsGetApiVersion;
|
||||
private readonly ICallGateSubscriber<float> _heelsGetOffset;
|
||||
private readonly ICallGateSubscriber<float, object?> _heelsOffsetUpdate;
|
||||
private readonly ICallGateSubscriber<GameObject, float, object?> _heelsRegisterPlayer;
|
||||
private readonly ICallGateSubscriber<GameObject, object?> _heelsUnregisterPlayer;
|
||||
|
||||
private readonly DalamudUtil _dalamudUtil;
|
||||
private readonly ConcurrentQueue<Action> actionQueue = new();
|
||||
|
||||
@@ -73,6 +81,15 @@ namespace MareSynchronos.Managers
|
||||
_penumbraRemoveTemporaryCollection =
|
||||
pi.GetIpcSubscriber<string, int>("Penumbra.RemoveTemporaryCollection");
|
||||
|
||||
_heelsGetApiVersion = pi.GetIpcSubscriber<string>("HeelsPlugin.ApiVersion");
|
||||
_heelsGetOffset = pi.GetIpcSubscriber<float>("HeelsPlugin.GetOffset");
|
||||
_heelsRegisterPlayer = pi.GetIpcSubscriber<GameObject, float, object?>("HeelsPlugin.RegisterPlayer");
|
||||
_heelsUnregisterPlayer = pi.GetIpcSubscriber<GameObject, object?>("HeelsPlugin.UnregisterPlayer");
|
||||
_heelsOffsetUpdate = pi.GetIpcSubscriber<float, object?>("HeelsPlugin.OffsetChanged");
|
||||
|
||||
_heelsOffsetUpdate.Subscribe(HeelsOffsetChange);
|
||||
|
||||
|
||||
if (Initialized)
|
||||
{
|
||||
PenumbraInitialized?.Invoke();
|
||||
@@ -95,6 +112,7 @@ namespace MareSynchronos.Managers
|
||||
public event VoidDelegate? PenumbraInitialized;
|
||||
public event VoidDelegate? PenumbraDisposed;
|
||||
public event PenumbraRedrawEvent? PenumbraRedrawEvent;
|
||||
public event HeelsOffsetChange? HeelsOffsetChangeEvent;
|
||||
|
||||
public bool Initialized => CheckPenumbraApi();
|
||||
public bool CheckGlamourerApi()
|
||||
@@ -121,6 +139,18 @@ namespace MareSynchronos.Managers
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckHeelsApi()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _heelsGetApiVersion.InvokeFunc() == "1.0.1";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Logger.Verbose("Disposing " + nameof(IpcManager));
|
||||
@@ -131,6 +161,41 @@ namespace MareSynchronos.Managers
|
||||
_penumbraDispose.Unsubscribe(PenumbraDispose);
|
||||
_penumbraInit.Unsubscribe(PenumbraInit);
|
||||
_penumbraObjectIsRedrawn.Unsubscribe(RedrawEvent);
|
||||
_heelsOffsetUpdate.Unsubscribe(HeelsOffsetChange);
|
||||
}
|
||||
|
||||
public float GetHeelsOffset()
|
||||
{
|
||||
if (!CheckHeelsApi()) return 0.0f;
|
||||
return _heelsGetOffset.InvokeFunc();
|
||||
}
|
||||
|
||||
public void HeelsSetOffsetForPlayer(float offset, IntPtr character)
|
||||
{
|
||||
if(!CheckHeelsApi()) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(character);
|
||||
if (gameObj != null)
|
||||
{
|
||||
Logger.Verbose("Applying Heels data to " + character.ToString("X"));
|
||||
_heelsRegisterPlayer.InvokeAction(gameObj, offset);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void HeelsRestoreOffsetForPlayer(IntPtr character)
|
||||
{
|
||||
if (!CheckHeelsApi()) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(character);
|
||||
if (gameObj != null)
|
||||
{
|
||||
Logger.Verbose("Restoring Heels data to " + character.ToString("X"));
|
||||
_heelsUnregisterPlayer.InvokeAction(gameObj);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void GlamourerApplyAll(string? customization, IntPtr obj)
|
||||
@@ -280,6 +345,11 @@ namespace MareSynchronos.Managers
|
||||
});
|
||||
}
|
||||
|
||||
private void HeelsOffsetChange(float offset)
|
||||
{
|
||||
HeelsOffsetChangeEvent?.Invoke(offset);
|
||||
}
|
||||
|
||||
private void RedrawEvent(IntPtr objectAddress, int objectTableIndex)
|
||||
{
|
||||
PenumbraRedrawEvent?.Invoke(objectAddress, objectTableIndex);
|
||||
|
||||
Reference in New Issue
Block a user