Skip to content

Commit

Permalink
IPC func/action disambiguation - setters now have no return type.
Browse files Browse the repository at this point in the history
  • Loading branch information
awgil committed Mar 4, 2024
1 parent e46ad76 commit 4eb1d57
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions vnavmesh/IPCProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@ class IPCProvider : IDisposable

public IPCProvider(NavmeshManager navmeshManager, FollowPath followPath, AsyncMoveRequest move, MainWindow mainWindow)
{
Register("Nav.IsReady", () => navmeshManager.Navmesh != null);
Register("Nav.BuildProgress", () => navmeshManager.LoadTaskProgress);
Register("Nav.Reload", () => navmeshManager.Reload(true));
Register("Nav.Rebuild", () => navmeshManager.Reload(false));
Register("Nav.Pathfind", (Vector3 from, Vector3 to, bool fly) => navmeshManager.QueryPath(from, to, fly));
Register("Nav.IsAutoLoad", () => navmeshManager.AutoLoad);
Register("Nav.SetAutoLoad", (bool v) => navmeshManager.AutoLoad = v);
RegisterFunc("Nav.IsReady", () => navmeshManager.Navmesh != null);
RegisterFunc("Nav.BuildProgress", () => navmeshManager.LoadTaskProgress);
RegisterFunc("Nav.Reload", () => navmeshManager.Reload(true));
RegisterFunc("Nav.Rebuild", () => navmeshManager.Reload(false));
RegisterFunc("Nav.Pathfind", (Vector3 from, Vector3 to, bool fly) => navmeshManager.QueryPath(from, to, fly));
RegisterFunc("Nav.IsAutoLoad", () => navmeshManager.AutoLoad);
RegisterAction("Nav.SetAutoLoad", (bool v) => navmeshManager.AutoLoad = v);

Register("Query.Mesh.NearestPoint", (Vector3 p, float halfExtentXZ, float halfExtentY) => navmeshManager.Query?.FindNearestPointOnMesh(p, halfExtentXZ, halfExtentY));
Register("Query.Mesh.PointOnFloor", (Vector3 p, float halfExtentXZ) => navmeshManager.Query?.FindPointOnFloor(p, halfExtentXZ));
RegisterFunc("Query.Mesh.NearestPoint", (Vector3 p, float halfExtentXZ, float halfExtentY) => navmeshManager.Query?.FindNearestPointOnMesh(p, halfExtentXZ, halfExtentY));
RegisterFunc("Query.Mesh.PointOnFloor", (Vector3 p, float halfExtentXZ) => navmeshManager.Query?.FindPointOnFloor(p, halfExtentXZ));

Register("Path.MoveTo", (List<Vector3> waypoints, bool fly) => followPath.Move(waypoints, !fly));
Register("Path.Stop", followPath.Stop);
Register("Path.IsRunning", () => followPath.Waypoints.Count > 0);
Register("Path.NumWaypoints", () => followPath.Waypoints.Count);
Register("Path.GetMovementAllowed", () => followPath.MovementAllowed);
Register("Path.SetMovementAllowed", (bool v) => followPath.MovementAllowed = v);
Register("Path.GetAlignCamera", () => followPath.AlignCamera);
Register("Path.SetAlignCamera", (bool v) => followPath.AlignCamera = v);
Register("Path.GetTolerance", () => followPath.Tolerance);
Register("Path.SetTolerance", (float v) => followPath.Tolerance = v);
RegisterAction("Path.MoveTo", (List<Vector3> waypoints, bool fly) => followPath.Move(waypoints, !fly));
RegisterAction("Path.Stop", followPath.Stop);
RegisterFunc("Path.IsRunning", () => followPath.Waypoints.Count > 0);
RegisterFunc("Path.NumWaypoints", () => followPath.Waypoints.Count);
RegisterFunc("Path.GetMovementAllowed", () => followPath.MovementAllowed);
RegisterAction("Path.SetMovementAllowed", (bool v) => followPath.MovementAllowed = v);
RegisterFunc("Path.GetAlignCamera", () => followPath.AlignCamera);
RegisterAction("Path.SetAlignCamera", (bool v) => followPath.AlignCamera = v);
RegisterFunc("Path.GetTolerance", () => followPath.Tolerance);
RegisterAction("Path.SetTolerance", (float v) => followPath.Tolerance = v);

Register("SimpleMove.PathfindAndMoveTo", (Vector3 dest, bool fly) => move.MoveTo(dest, fly));
Register("SimpleMove.PathfindInProgress", () => move.TaskInProgress);
RegisterFunc("SimpleMove.PathfindAndMoveTo", (Vector3 dest, bool fly) => move.MoveTo(dest, fly));
RegisterFunc("SimpleMove.PathfindInProgress", () => move.TaskInProgress);

Register("Window.IsOpen", () => mainWindow.IsOpen);
Register("Window.SetOpen", (bool v) => mainWindow.IsOpen = v);
RegisterFunc("Window.IsOpen", () => mainWindow.IsOpen);
RegisterAction("Window.SetOpen", (bool v) => mainWindow.IsOpen = v);
}

public void Dispose()
Expand All @@ -46,49 +46,49 @@ public void Dispose()
a();
}

private void Register<TRet>(string name, Func<TRet> func)
private void RegisterFunc<TRet>(string name, Func<TRet> func)
{
var p = Service.PluginInterface.GetIpcProvider<TRet>("vnavmesh." + name);
p.RegisterFunc(func);
_disposeActions.Add(p.UnregisterFunc);
}

private void Register<TRet, T1>(string name, Func<T1, TRet> func)
private void RegisterFunc<TRet, T1>(string name, Func<T1, TRet> func)
{
var p = Service.PluginInterface.GetIpcProvider<T1, TRet>("vnavmesh." + name);
p.RegisterFunc(func);
_disposeActions.Add(p.UnregisterFunc);
}

private void Register<TRet, T1, T2>(string name, Func<T1, T2, TRet> func)
private void RegisterFunc<TRet, T1, T2>(string name, Func<T1, T2, TRet> func)
{
var p = Service.PluginInterface.GetIpcProvider<T1, T2, TRet>("vnavmesh." + name);
p.RegisterFunc(func);
_disposeActions.Add(p.UnregisterFunc);
}

private void Register<TRet, T1, T2, T3>(string name, Func<T1, T2, T3, TRet> func)
private void RegisterFunc<TRet, T1, T2, T3>(string name, Func<T1, T2, T3, TRet> func)
{
var p = Service.PluginInterface.GetIpcProvider<T1, T2, T3, TRet>("vnavmesh." + name);
p.RegisterFunc(func);
_disposeActions.Add(p.UnregisterFunc);
}

private void Register(string name, Action func)
private void RegisterAction(string name, Action func)
{
var p = Service.PluginInterface.GetIpcProvider<object>("vnavmesh." + name);
p.RegisterAction(func);
_disposeActions.Add(p.UnregisterAction);
}

private void Register<T1>(string name, Action<T1> func)
private void RegisterAction<T1>(string name, Action<T1> func)
{
var p = Service.PluginInterface.GetIpcProvider<T1, object>("vnavmesh." + name);
p.RegisterAction(func);
_disposeActions.Add(p.UnregisterAction);
}

private void Register<T1, T2>(string name, Action<T1, T2> func)
private void RegisterAction<T1, T2>(string name, Action<T1, T2> func)
{
var p = Service.PluginInterface.GetIpcProvider<T1, T2, object>("vnavmesh." + name);
p.RegisterAction(func);
Expand Down

0 comments on commit 4eb1d57

Please sign in to comment.