muffin v7.38.8

This commit is contained in:
alydev 2025-11-30 10:36:46 +10:00
parent 5e2d8f648b
commit 3e10cbbbf2
51 changed files with 2585 additions and 1972 deletions

View file

@ -11,12 +11,18 @@ namespace Questionable.External;
internal sealed class NavmeshIpc
{
private readonly IDalamudPluginInterface _pluginInterface;
private readonly ILogger<NavmeshIpc> _logger;
private readonly ICallGateSubscriber<bool> _isNavReady;
private readonly ICallGateSubscriber<Vector3, Vector3, bool, CancellationToken, Task<List<Vector3>>> _navPathfind;
private readonly ICallGateSubscriber<bool> _navPathfindInProgress;
private readonly ICallGateSubscriber<int> _navNumQueuedRequests;
private readonly ICallGateSubscriber<List<Vector3>, bool, object> _pathMoveTo;
private readonly ICallGateSubscriber<object> _pathStop;
@ -29,6 +35,8 @@ internal sealed class NavmeshIpc
private readonly ICallGateSubscriber<Vector3, bool, float, Vector3?> _queryPointOnFloor;
private readonly ICallGateSubscriber<Vector3, float, float, Vector3?> _queryNearestPoint;
private readonly ICallGateSubscriber<float> _buildProgress;
public bool IsReady
@ -61,17 +69,51 @@ internal sealed class NavmeshIpc
}
}
public bool IsPathfindInProgress
{
get
{
try
{
return _navPathfindInProgress.InvokeFunc();
}
catch (IpcError)
{
return false;
}
}
}
public int NumQueuedPathfindRequests
{
get
{
try
{
return _navNumQueuedRequests.InvokeFunc();
}
catch (IpcError)
{
return 0;
}
}
}
public NavmeshIpc(IDalamudPluginInterface pluginInterface, ILogger<NavmeshIpc> logger)
{
_pluginInterface = pluginInterface;
_logger = logger;
_isNavReady = pluginInterface.GetIpcSubscriber<bool>("vnavmesh.Nav.IsReady");
_navPathfind = pluginInterface.GetIpcSubscriber<Vector3, Vector3, bool, CancellationToken, Task<List<Vector3>>>("vnavmesh.Nav.PathfindCancelable");
_navPathfindInProgress = pluginInterface.GetIpcSubscriber<bool>("vnavmesh.Nav.PathfindInProgress");
_navNumQueuedRequests = pluginInterface.GetIpcSubscriber<int>("vnavmesh.Nav.PathfindNumQueued");
_pathMoveTo = pluginInterface.GetIpcSubscriber<List<Vector3>, bool, object>("vnavmesh.Path.MoveTo");
_pathStop = pluginInterface.GetIpcSubscriber<object>("vnavmesh.Path.Stop");
_pathIsRunning = pluginInterface.GetIpcSubscriber<bool>("vnavmesh.Path.IsRunning");
_pathListWaypoints = pluginInterface.GetIpcSubscriber<List<Vector3>>("vnavmesh.Path.ListWaypoints");
_pathSetTolerance = pluginInterface.GetIpcSubscriber<float, object>("vnavmesh.Path.SetTolerance");
_queryPointOnFloor = pluginInterface.GetIpcSubscriber<Vector3, bool, float, Vector3?>("vnavmesh.Query.Mesh.PointOnFloor");
_queryNearestPoint = pluginInterface.GetIpcSubscriber<Vector3, float, float, Vector3?>("vnavmesh.Query.Mesh.NearestPoint");
_buildProgress = pluginInterface.GetIpcSubscriber<float>("vnavmesh.Nav.BuildProgress");
}
@ -101,6 +143,20 @@ internal sealed class NavmeshIpc
}
}
public Task<List<Vector3>> PathfindWithTolerance(Vector3 localPlayerPosition, Vector3 targetPosition, bool fly, float tolerance, CancellationToken cancellationToken)
{
try
{
_pathSetTolerance.InvokeAction(0.25f);
return _pluginInterface.GetIpcSubscriber<Vector3, Vector3, bool, float, CancellationToken, Task<List<Vector3>>>("vnavmesh.Nav.PathfindWithTolerance").InvokeFunc(localPlayerPosition, targetPosition, fly, tolerance, cancellationToken);
}
catch (IpcError exception)
{
_logger.LogWarning(exception, "Could not pathfind with tolerance via navmesh");
return Task.FromException<List<Vector3>>(exception);
}
}
public void MoveTo(List<Vector3> position, bool fly)
{
Stop();
@ -126,6 +182,30 @@ internal sealed class NavmeshIpc
}
}
public Vector3? GetPointOnFloor(Vector3 position, bool unlandable, float halfExtentXZ)
{
try
{
return _queryPointOnFloor.InvokeFunc(position, unlandable, halfExtentXZ);
}
catch (IpcError)
{
return null;
}
}
public Vector3? FindNearestMeshPoint(Vector3 position, float halfExtentXZ, float halfExtentY)
{
try
{
return _queryNearestPoint.InvokeFunc(position, halfExtentXZ, halfExtentY);
}
catch (IpcError)
{
return null;
}
}
public List<Vector3> GetWaypoints()
{
if (IsPathRunning)