From 0620cdcd85af6a105b9d4290c8d7d58a27bf3ee1 Mon Sep 17 00:00:00 2001 From: ikpil Date: Fri, 28 Apr 2023 23:22:09 +0900 Subject: [PATCH] C# style --- src/DotRecast.Detour.Crowd/Crowd.cs | 18 +- src/DotRecast.Detour.Crowd/LocalBoundary.cs | 4 +- src/DotRecast.Detour.Crowd/PathCorridor.cs | 16 +- .../Jumplink/NavMeshGroundSampler.cs | 2 +- src/DotRecast.Detour/LegacyNavMeshQuery.cs | 48 ++-- src/DotRecast.Detour/NavMesh.cs | 42 ++-- src/DotRecast.Detour/NavMeshQuery.cs | 212 +++++++++--------- src/DotRecast.Detour/PathUtils.cs | 4 +- src/DotRecast.Detour/QueryResults/Result.cs | 22 +- .../Draw/RecastDebugDraw.cs | 2 +- .../Tools/CrowdProfilingTool.cs | 14 +- src/DotRecast.Recast.Demo/Tools/CrowdTool.cs | 2 +- .../Tools/TestNavmeshTool.cs | 28 +-- .../PathCorridorTest.cs | 4 +- .../UnityAStarPathfindingImporterTest.cs | 2 +- .../FindNearestPolyTest.cs | 4 +- .../FindPolysAroundCircleTest.cs | 2 +- .../MoveAlongSurfaceTest.cs | 2 +- test/DotRecast.Detour.Test/RandomPointTest.cs | 6 +- 19 files changed, 217 insertions(+), 217 deletions(-) diff --git a/src/DotRecast.Detour.Crowd/Crowd.cs b/src/DotRecast.Detour.Crowd/Crowd.cs index 9715d87..740280d 100644 --- a/src/DotRecast.Detour.Crowd/Crowd.cs +++ b/src/DotRecast.Detour.Crowd/Crowd.cs @@ -246,8 +246,8 @@ namespace DotRecast.Detour.Crowd // Find nearest position on navmesh and place the agent there. Result nearestPoly = navQuery.findNearestPoly(pos, m_ext, m_filters[ag.option.queryFilterType]); - var nearest = nearestPoly.succeeded() ? nearestPoly.result.getNearestPos() : pos; - long refs = nearestPoly.succeeded() ? nearestPoly.result.getNearestRef() : 0L; + var nearest = nearestPoly.Succeeded() ? nearestPoly.result.getNearestPos() : pos; + long refs = nearestPoly.Succeeded() ? nearestPoly.result.getNearestRef() : 0L; ag.corridor.reset(refs, nearest); ag.boundary.reset(); ag.partial = false; @@ -463,8 +463,8 @@ namespace DotRecast.Detour.Crowd // TODO: this can snap agents, how to handle that? Result nearestPoly = navQuery.findNearestPoly(ag.npos, m_ext, m_filters[ag.option.queryFilterType]); - agentRef = nearestPoly.succeeded() ? nearestPoly.result.getNearestRef() : 0L; - if (nearestPoly.succeeded()) + agentRef = nearestPoly.Succeeded() ? nearestPoly.result.getNearestRef() : 0L; + if (nearestPoly.Succeeded()) { agentPos = nearestPoly.result.getNearestPos(); } @@ -508,8 +508,8 @@ namespace DotRecast.Detour.Crowd // Current target is not valid, try to reposition. Result fnp = navQuery.findNearestPoly(ag.targetPos, m_ext, m_filters[ag.option.queryFilterType]); - ag.targetRef = fnp.succeeded() ? fnp.result.getNearestRef() : 0L; - if (fnp.succeeded()) + ag.targetRef = fnp.Succeeded() ? fnp.result.getNearestRef() : 0L; + if (fnp.Succeeded()) { ag.targetPos = fnp.result.getNearestPos(); } @@ -607,7 +607,7 @@ namespace DotRecast.Detour.Crowd List reqPath = pathFound.result; Vector3f reqPos = new Vector3f(); - if (pathFound.succeeded() && reqPath.Count > 0) + if (pathFound.Succeeded() && reqPath.Count > 0) { // In progress or succeed. if (reqPath[reqPath.Count - 1] != ag.targetRef) @@ -616,7 +616,7 @@ namespace DotRecast.Detour.Crowd // last polygon. Result cr = navQuery.closestPointOnPoly(reqPath[reqPath.Count - 1], ag.targetPos); - if (cr.succeeded()) + if (cr.Succeeded()) { reqPos = cr.result.getClosest(); } @@ -784,7 +784,7 @@ namespace DotRecast.Detour.Crowd // Partial path, constrain target position inside // the last polygon. Result cr = navQuery.closestPointOnPoly(res[res.Count - 1], targetPos); - if (cr.succeeded()) + if (cr.Succeeded()) { targetPos = cr.result.getClosest(); } diff --git a/src/DotRecast.Detour.Crowd/LocalBoundary.cs b/src/DotRecast.Detour.Crowd/LocalBoundary.cs index 1e5d64e..27a01df 100644 --- a/src/DotRecast.Detour.Crowd/LocalBoundary.cs +++ b/src/DotRecast.Detour.Crowd/LocalBoundary.cs @@ -110,7 +110,7 @@ namespace DotRecast.Detour.Crowd // First query non-overlapping polygons. Result res = navquery.findLocalNeighbourhood(refs, pos, collisionQueryRange, filter); - if (res.succeeded()) + if (res.Succeeded()) { m_polys = res.result.getRefs(); m_segs.Clear(); @@ -118,7 +118,7 @@ namespace DotRecast.Detour.Crowd for (int j = 0; j < m_polys.Count; ++j) { Result result = navquery.getPolyWallSegments(m_polys[j], false, filter); - if (result.succeeded()) + if (result.Succeeded()) { GetPolyWallSegmentsResult gpws = result.result; for (int k = 0; k < gpws.countSegmentRefs(); ++k) diff --git a/src/DotRecast.Detour.Crowd/PathCorridor.cs b/src/DotRecast.Detour.Crowd/PathCorridor.cs index 140fab5..cfff017 100644 --- a/src/DotRecast.Detour.Crowd/PathCorridor.cs +++ b/src/DotRecast.Detour.Crowd/PathCorridor.cs @@ -238,7 +238,7 @@ namespace DotRecast.Detour.Crowd { List path = new List(); Result> result = navquery.findStraightPath(m_pos, m_target, m_path, maxCorners, 0); - if (result.succeeded()) + if (result.Succeeded()) { path = result.result; // Prune points in the beginning of the path which are too close. @@ -319,7 +319,7 @@ namespace DotRecast.Detour.Crowd Vector3f goal = vMad(m_pos, delta, pathOptimizationRange / dist); Result rc = navquery.raycast(m_path[0], m_pos, goal, filter, 0, 0); - if (rc.succeeded()) + if (rc.Succeeded()) { if (rc.result.path.Count > 1 && rc.result.t > 0.99f) { @@ -355,7 +355,7 @@ namespace DotRecast.Detour.Crowd navquery.updateSlicedFindPath(maxIterations); Result> fpr = navquery.finalizeSlicedFindPathPartial(m_path); - if (fpr.succeeded() && fpr.result.Count > 0) + if (fpr.Succeeded() && fpr.result.Count > 0) { m_path = mergeCorridorStartShortcut(m_path, fpr.result); return true; @@ -389,7 +389,7 @@ namespace DotRecast.Detour.Crowd NavMesh nav = navquery.getAttachedNavMesh(); var startEnd = nav.getOffMeshConnectionPolyEndPoints(refs[0], refs[1]); - if (startEnd.succeeded()) + if (startEnd.Succeeded()) { m_pos = startEnd.result.Item2; start = startEnd.result.Item1; @@ -427,13 +427,13 @@ namespace DotRecast.Detour.Crowd { // Move along navmesh and update new position. Result masResult = navquery.moveAlongSurface(m_path[0], m_pos, npos, filter); - if (masResult.succeeded()) + if (masResult.Succeeded()) { m_path = mergeCorridorStartMoved(m_path, masResult.result.getVisited()); // Adjust the position to stay on top of the navmesh. m_pos = masResult.result.getResultPos(); Result hr = navquery.getPolyHeight(m_path[0], masResult.result.getResultPos()); - if (hr.succeeded()) + if (hr.Succeeded()) { m_pos[1] = hr.result; } @@ -465,7 +465,7 @@ namespace DotRecast.Detour.Crowd { // Move along navmesh and update new position. Result masResult = navquery.moveAlongSurface(m_path[m_path.Count - 1], m_target, npos, filter); - if (masResult.succeeded()) + if (masResult.Succeeded()) { m_path = mergeCorridorEndMoved(m_path, masResult.result.getVisited()); // TODO: should we do that? @@ -540,7 +540,7 @@ namespace DotRecast.Detour.Crowd // Clamp target pos to last poly var result = navquery.closestPointOnPolyBoundary(m_path[m_path.Count - 1], m_target); - if (result.succeeded()) + if (result.Succeeded()) { m_target = result.result; } diff --git a/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs index 8a66ea2..f7da2a1 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs @@ -79,7 +79,7 @@ namespace DotRecast.Detour.Extras.Jumplink navMeshQuery.queryPolygons(pt, halfExtents, filter, new PolyQueryInvoker((tile, poly, refs) => { Result h = navMeshQuery.getPolyHeight(refs, pt); - if (h.succeeded()) + if (h.Succeeded()) { float y = h.result; if (y > minHeight.Get() && y < maxHeight) diff --git a/src/DotRecast.Detour/LegacyNavMeshQuery.cs b/src/DotRecast.Detour/LegacyNavMeshQuery.cs index 0b9a1a0..e794090 100644 --- a/src/DotRecast.Detour/LegacyNavMeshQuery.cs +++ b/src/DotRecast.Detour/LegacyNavMeshQuery.cs @@ -45,14 +45,14 @@ namespace DotRecast.Detour // Validate input if (!m_nav.isValidPolyRef(startRef) || !m_nav.isValidPolyRef(endRef) || !vIsFinite(startPos) || !vIsFinite(endPos) || null == filter) { - return Results.invalidParam>(); + return Results.InvalidParam>(); } if (startRef == endRef) { List singlePath = new List(1); singlePath.Add(startRef); - return Results.success(singlePath); + return Results.Success(singlePath); } m_nodePool.clear(); @@ -145,7 +145,7 @@ namespace DotRecast.Detour { var midpod = getEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile); - if (!midpod.failed()) + if (!midpod.Failed()) { neighbourNode.pos = midpod.result; } @@ -225,7 +225,7 @@ namespace DotRecast.Detour status = Status.PARTIAL_RESULT; } - return Results.of(status, path); + return Results.Of(status, path); } /** @@ -239,14 +239,14 @@ namespace DotRecast.Detour { if (!m_query.status.isInProgress()) { - return Results.of(m_query.status, 0); + return Results.Of(m_query.status, 0); } // Make sure the request is still valid. if (!m_nav.isValidPolyRef(m_query.startRef) || !m_nav.isValidPolyRef(m_query.endRef)) { m_query.status = Status.FAILURE; - return Results.of(m_query.status, 0); + return Results.Of(m_query.status, 0); } int iter = 0; @@ -264,7 +264,7 @@ namespace DotRecast.Detour { m_query.lastBestNode = bestNode; m_query.status = Status.SUCCSESS; - return Results.of(m_query.status, iter); + return Results.Of(m_query.status, iter); } // Get current poly and tile. @@ -272,11 +272,11 @@ namespace DotRecast.Detour // data. long bestRef = bestNode.id; Result> tileAndPoly = m_nav.getTileAndPolyByRef(bestRef); - if (tileAndPoly.failed()) + if (tileAndPoly.Failed()) { m_query.status = Status.FAILURE; // The polygon has disappeared during the sliced query, fail. - return Results.of(m_query.status, iter); + return Results.Of(m_query.status, iter); } MeshTile bestTile = tileAndPoly.result.Item1; @@ -300,13 +300,13 @@ namespace DotRecast.Detour { bool invalidParent = false; tileAndPoly = m_nav.getTileAndPolyByRef(parentRef); - invalidParent = tileAndPoly.failed(); + invalidParent = tileAndPoly.Failed(); if (invalidParent || (grandpaRef != 0 && !m_nav.isValidPolyRef(grandpaRef))) { // The polygon has disappeared during the sliced query, // fail. m_query.status = Status.FAILURE; - return Results.of(m_query.status, iter); + return Results.Of(m_query.status, iter); } parentTile = tileAndPoly.result.Item1; @@ -362,7 +362,7 @@ namespace DotRecast.Detour { var midpod = getEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile); - if (!midpod.failed()) + if (!midpod.Failed()) { neighbourNode.pos = midpod.result; } @@ -378,7 +378,7 @@ namespace DotRecast.Detour { Result rayHit = raycast(parentRef, parentNode.pos, neighbourNode.pos, m_query.filter, DT_RAYCAST_USE_COSTS, grandpaRef); - if (rayHit.succeeded()) + if (rayHit.Succeeded()) { foundShortCut = rayHit.result.t >= 1.0f; if (foundShortCut) @@ -467,7 +467,7 @@ namespace DotRecast.Detour m_query.status = Status.PARTIAL_RESULT; } - return Results.of(m_query.status, iter); + return Results.Of(m_query.status, iter); } /// Finalizes and returns the results of a sliced path query. @@ -481,7 +481,7 @@ namespace DotRecast.Detour { // Reset query. m_query = new QueryData(); - return Results.failure(path); + return Results.Failure(path); } if (m_query.startRef == m_query.endRef) @@ -521,7 +521,7 @@ namespace DotRecast.Detour if ((node.flags & Node.DT_NODE_PARENT_DETACHED) != 0) { Result iresult = raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0); - if (iresult.succeeded()) + if (iresult.Succeeded()) { path.AddRange(iresult.result.path); } @@ -545,7 +545,7 @@ namespace DotRecast.Detour // Reset query. m_query = new QueryData(); - return Results.of(status, path); + return Results.Of(status, path); } /// Finalizes and returns the results of an incomplete sliced path query, returning the path to the furthest @@ -560,14 +560,14 @@ namespace DotRecast.Detour List path = new List(64); if (null == existing || existing.Count <= 0) { - return Results.failure(path); + return Results.Failure(path); } if (m_query.status.isFailed()) { // Reset query. m_query = new QueryData(); - return Results.failure(path); + return Results.Failure(path); } if (m_query.startRef == m_query.endRef) @@ -618,7 +618,7 @@ namespace DotRecast.Detour if ((node.flags & Node.DT_NODE_PARENT_DETACHED) != 0) { Result iresult = raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0); - if (iresult.succeeded()) + if (iresult.Succeeded()) { path.AddRange(iresult.result.path); } @@ -642,7 +642,7 @@ namespace DotRecast.Detour // Reset query. m_query = new QueryData(); - return Results.of(status, path); + return Results.Of(status, path); } public override Result findDistanceToWall(long startRef, Vector3f centerPos, float maxRadius, QueryFilter filter) @@ -651,7 +651,7 @@ namespace DotRecast.Detour if (!m_nav.isValidPolyRef(startRef) || !vIsFinite(centerPos) || maxRadius < 0 || !float.IsFinite(maxRadius) || null == filter) { - return Results.invalidParam(); + return Results.InvalidParam(); } m_nodePool.clear(); @@ -808,7 +808,7 @@ namespace DotRecast.Detour { var midPoint = getEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile); - if (midPoint.succeeded()) + if (midPoint.Succeeded()) { neighbourNode.pos = midPoint.result; } @@ -850,7 +850,7 @@ namespace DotRecast.Detour vNormalize(ref hitNormal); } - return Results.success(new FindDistanceToWallResult((float)Math.Sqrt(radiusSqr), hitPos, hitNormal)); + return Results.Success(new FindDistanceToWallResult((float)Math.Sqrt(radiusSqr), hitPos, hitNormal)); } } } \ No newline at end of file diff --git a/src/DotRecast.Detour/NavMesh.cs b/src/DotRecast.Detour/NavMesh.cs index 1332acf..3bec4cf 100644 --- a/src/DotRecast.Detour/NavMesh.cs +++ b/src/DotRecast.Detour/NavMesh.cs @@ -225,7 +225,7 @@ namespace DotRecast.Detour { if (refs == 0) { - return Results.invalidParam>("ref = 0"); + return Results.InvalidParam>("ref = 0"); } int[] saltitip = decodePolyId(refs); @@ -234,20 +234,20 @@ namespace DotRecast.Detour int ip = saltitip[2]; if (it >= m_maxTiles) { - return Results.invalidParam>("tile > m_maxTiles"); + return Results.InvalidParam>("tile > m_maxTiles"); } if (m_tiles[it].salt != salt || m_tiles[it].data.header == null) { - return Results.invalidParam>("Invalid salt or header"); + return Results.InvalidParam>("Invalid salt or header"); } if (ip >= m_tiles[it].data.header.polyCount) { - return Results.invalidParam>("poly > polyCount"); + return Results.InvalidParam>("poly > polyCount"); } - return Results.success(Tuple.Create(m_tiles[it], m_tiles[it].data.polys[ip])); + return Results.Success(Tuple.Create(m_tiles[it], m_tiles[it].data.polys[ip])); } /// @par @@ -1523,7 +1523,7 @@ namespace DotRecast.Detour { if (polyRef == 0) { - return Results.invalidParam>("polyRef = 0"); + return Results.InvalidParam>("polyRef = 0"); } // Get current polygon @@ -1533,18 +1533,18 @@ namespace DotRecast.Detour int ip = saltitip[2]; if (it >= m_maxTiles) { - return Results.invalidParam>("Invalid tile ID > max tiles"); + return Results.InvalidParam>("Invalid tile ID > max tiles"); } if (m_tiles[it].salt != salt || m_tiles[it].data.header == null) { - return Results.invalidParam>("Invalid salt or missing tile header"); + return Results.InvalidParam>("Invalid salt or missing tile header"); } MeshTile tile = m_tiles[it]; if (ip >= tile.data.header.polyCount) { - return Results.invalidParam>("Invalid poly ID > poly count"); + return Results.InvalidParam>("Invalid poly ID > poly count"); } Poly poly = tile.data.polys[ip]; @@ -1552,7 +1552,7 @@ namespace DotRecast.Detour // Make sure that the current poly is indeed off-mesh link. if (poly.getType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION) { - return Results.invalidParam>("Invalid poly type"); + return Results.InvalidParam>("Invalid poly type"); } // Figure out which way to hand out the vertices. @@ -1577,7 +1577,7 @@ namespace DotRecast.Detour Vector3f endPos = new Vector3f(); vCopy(ref startPos, tile.data.verts, poly.verts[idx0] * 3); vCopy(ref endPos, tile.data.verts, poly.verts[idx1] * 3); - return Results.success(Tuple.Create(startPos, endPos)); + return Results.Success(Tuple.Create(startPos, endPos)); } public int getMaxVertsPerPoly() @@ -1628,7 +1628,7 @@ namespace DotRecast.Detour { if (refs == 0) { - return Results.failure(); + return Results.Failure(); } int[] saltTilePoly = decodePolyId(refs); @@ -1637,23 +1637,23 @@ namespace DotRecast.Detour int ip = saltTilePoly[2]; if (it >= m_maxTiles) { - return Results.invalidParam(); + return Results.InvalidParam(); } if (m_tiles[it].salt != salt || m_tiles[it].data == null || m_tiles[it].data.header == null) { - return Results.invalidParam(); + return Results.InvalidParam(); } MeshTile tile = m_tiles[it]; if (ip >= tile.data.header.polyCount) { - return Results.invalidParam(); + return Results.InvalidParam(); } Poly poly = tile.data.polys[ip]; - return Results.success(poly.flags); + return Results.Success(poly.flags); } public Status setPolyArea(long refs, char area) @@ -1694,7 +1694,7 @@ namespace DotRecast.Detour { if (refs == 0) { - return Results.failure(); + return Results.Failure(); } int[] saltTilePoly = decodePolyId(refs); @@ -1703,23 +1703,23 @@ namespace DotRecast.Detour int ip = saltTilePoly[2]; if (it >= m_maxTiles) { - return Results.invalidParam(); + return Results.InvalidParam(); } if (m_tiles[it].salt != salt || m_tiles[it].data == null || m_tiles[it].data.header == null) { - return Results.invalidParam(); + return Results.InvalidParam(); } MeshTile tile = m_tiles[it]; if (ip >= tile.data.header.polyCount) { - return Results.invalidParam(); + return Results.InvalidParam(); } Poly poly = tile.data.polys[ip]; - return Results.success(poly.getArea()); + return Results.Success(poly.getArea()); } /** diff --git a/src/DotRecast.Detour/NavMeshQuery.cs b/src/DotRecast.Detour/NavMeshQuery.cs index 518aeb3..c882540 100644 --- a/src/DotRecast.Detour/NavMeshQuery.cs +++ b/src/DotRecast.Detour/NavMeshQuery.cs @@ -88,7 +88,7 @@ namespace DotRecast.Detour // Randomly pick one tile. Assume that all tiles cover roughly the same area. if (null == filter || null == frand) { - return Results.invalidParam(); + return Results.InvalidParam(); } MeshTile tile = null; @@ -113,7 +113,7 @@ namespace DotRecast.Detour if (tile == null) { - return Results.invalidParam("Tile not found"); + return Results.InvalidParam("Tile not found"); } // Randomly pick one polygon weighted by polygon area. @@ -160,7 +160,7 @@ namespace DotRecast.Detour if (poly == null) { - return Results.invalidParam("Poly not found"); + return Results.InvalidParam("Poly not found"); } // Randomly pick point on polygon. @@ -177,7 +177,7 @@ namespace DotRecast.Detour var pt = randomPointInConvexPoly(verts, poly.vertCount, areas, s, t); ClosestPointOnPolyResult closest = closestPointOnPoly(polyRef, pt).result; - return Results.success(new FindRandomPointResult(polyRef, closest.getClosest())); + return Results.Success(new FindRandomPointResult(polyRef, closest.getClosest())); } /** @@ -230,7 +230,7 @@ namespace DotRecast.Detour if (!m_nav.isValidPolyRef(startRef) || !vIsFinite(centerPos) || maxRadius < 0 || !float.IsFinite(maxRadius) || null == filter || null == frand) { - return Results.invalidParam(); + return Results.InvalidParam(); } Tuple tileAndPoly = m_nav.getTileAndPolyByRefUnsafe(startRef); @@ -238,7 +238,7 @@ namespace DotRecast.Detour Poly startPoly = tileAndPoly.Item2; if (!filter.passFilter(startRef, startTile, startPoly)) { - return Results.invalidParam("Invalid start ref"); + return Results.InvalidParam("Invalid start ref"); } m_nodePool.clear(); @@ -338,7 +338,7 @@ namespace DotRecast.Detour // Find edge and calc distance to the edge. Result portalpoints = getPortalPoints(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile, 0, 0); - if (portalpoints.failed()) + if (portalpoints.Failed()) { continue; } @@ -394,7 +394,7 @@ namespace DotRecast.Detour if (randomPoly == null) { - return Results.failure(); + return Results.Failure(); } // Randomly pick point on polygon. @@ -404,7 +404,7 @@ namespace DotRecast.Detour float[] areas = new float[randomPolyVerts.Length / 3]; Vector3f pt = randomPointInConvexPoly(randomPolyVerts, randomPolyVerts.Length / 3, areas, s, t); ClosestPointOnPolyResult closest = closestPointOnPoly(randomPolyRef, pt).result; - return Results.success(new FindRandomPointResult(randomPolyRef, closest.getClosest())); + return Results.Success(new FindRandomPointResult(randomPolyRef, closest.getClosest())); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -426,10 +426,10 @@ namespace DotRecast.Detour { if (!m_nav.isValidPolyRef(refs) || !vIsFinite(pos)) { - return Results.invalidParam(); + return Results.InvalidParam(); } - return Results.success(m_nav.closestPointOnPoly(refs, pos)); + return Results.Success(m_nav.closestPointOnPoly(refs, pos)); } /// @par @@ -452,21 +452,21 @@ namespace DotRecast.Detour public Result closestPointOnPolyBoundary(long refs, Vector3f pos) { Result> tileAndPoly = m_nav.getTileAndPolyByRef(refs); - if (tileAndPoly.failed()) + if (tileAndPoly.Failed()) { - return Results.of(tileAndPoly.status, tileAndPoly.message); + return Results.Of(tileAndPoly.status, tileAndPoly.message); } MeshTile tile = tileAndPoly.result.Item1; Poly poly = tileAndPoly.result.Item2; if (tile == null) { - return Results.invalidParam("Invalid tile"); + return Results.InvalidParam("Invalid tile"); } if (!vIsFinite(pos)) { - return Results.invalidParam(); + return Results.InvalidParam(); } // Collect vertices. @@ -503,7 +503,7 @@ namespace DotRecast.Detour closest = vLerp(verts, va, vb, edget[imin]); } - return Results.success(closest); + return Results.Success(closest); } /// @par @@ -519,9 +519,9 @@ namespace DotRecast.Detour public Result getPolyHeight(long refs, Vector3f pos) { Result> tileAndPoly = m_nav.getTileAndPolyByRef(refs); - if (tileAndPoly.failed()) + if (tileAndPoly.Failed()) { - return Results.of(tileAndPoly.status, tileAndPoly.message); + return Results.Of(tileAndPoly.status, tileAndPoly.message); } MeshTile tile = tileAndPoly.result.Item1; @@ -529,7 +529,7 @@ namespace DotRecast.Detour if (!vIsFinite2D(pos)) { - return Results.invalidParam(); + return Results.InvalidParam(); } // We used to return success for offmesh connections, but the @@ -542,11 +542,11 @@ namespace DotRecast.Detour i = poly.verts[1] * 3; var v1 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] }; var dt = distancePtSegSqr2D(pos, v0, v1); - return Results.success(v0[1] + (v1[1] - v0[1]) * dt.Item2); + return Results.Success(v0[1] + (v1[1] - v0[1]) * dt.Item2); } float? height = m_nav.getPolyHeight(tile, poly, pos); - return null != height ? Results.success(height.Value) : Results.invalidParam(); + return null != height ? Results.Success(height.Value) : Results.InvalidParam(); } /** @@ -568,10 +568,10 @@ namespace DotRecast.Detour Status status = queryPolygons(center, halfExtents, filter, query); if (status.isFailed()) { - return Results.of(status, ""); + return Results.Of(status, ""); } - return Results.success(query.result()); + return Results.Success(query.result()); } // FIXME: (PP) duplicate? @@ -767,7 +767,7 @@ namespace DotRecast.Detour // Validate input if (!m_nav.isValidPolyRef(startRef) || !m_nav.isValidPolyRef(endRef) || !vIsFinite(startPos) || !vIsFinite(endPos) || null == filter) { - return Results.invalidParam>(); + return Results.InvalidParam>(); } float raycastLimitSqr = sqr(raycastLimit); @@ -786,7 +786,7 @@ namespace DotRecast.Detour { List singlePath = new List(1); singlePath.Add(startRef); - return Results.success(singlePath); + return Results.Success(singlePath); } m_nodePool.clear(); @@ -897,7 +897,7 @@ namespace DotRecast.Detour ? getEdgeIntersectionPoint(bestNode.pos, bestRef, bestPoly, bestTile, endPos, neighbourRef, neighbourPoly, neighbourTile) : getEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile); - if (!midpod.failed()) + if (!midpod.Failed()) { neighbourPos = midpod.result; } @@ -913,7 +913,7 @@ namespace DotRecast.Detour { Result rayHit = raycast(parentRef, parentNode.pos, neighbourPos, filter, DT_RAYCAST_USE_COSTS, grandpaRef); - if (rayHit.succeeded()) + if (rayHit.Succeeded()) { foundShortCut = rayHit.result.t >= 1.0f; if (foundShortCut) @@ -999,7 +999,7 @@ namespace DotRecast.Detour status = Status.PARTIAL_RESULT; } - return Results.of(status, path); + return Results.Of(status, path); } /** @@ -1101,14 +1101,14 @@ namespace DotRecast.Detour { if (!m_query.status.isInProgress()) { - return Results.of(m_query.status, 0); + return Results.Of(m_query.status, 0); } // Make sure the request is still valid. if (!m_nav.isValidPolyRef(m_query.startRef) || !m_nav.isValidPolyRef(m_query.endRef)) { m_query.status = Status.FAILURE; - return Results.of(m_query.status, 0); + return Results.Of(m_query.status, 0); } int iter = 0; @@ -1126,7 +1126,7 @@ namespace DotRecast.Detour { m_query.lastBestNode = bestNode; m_query.status = Status.SUCCSESS; - return Results.of(m_query.status, iter); + return Results.Of(m_query.status, iter); } // Get current poly and tile. @@ -1134,11 +1134,11 @@ namespace DotRecast.Detour // data. long bestRef = bestNode.id; Result> tileAndPoly = m_nav.getTileAndPolyByRef(bestRef); - if (tileAndPoly.failed()) + if (tileAndPoly.Failed()) { m_query.status = Status.FAILURE; // The polygon has disappeared during the sliced query, fail. - return Results.of(m_query.status, iter); + return Results.Of(m_query.status, iter); } MeshTile bestTile = tileAndPoly.result.Item1; @@ -1162,13 +1162,13 @@ namespace DotRecast.Detour { bool invalidParent = false; tileAndPoly = m_nav.getTileAndPolyByRef(parentRef); - invalidParent = tileAndPoly.failed(); + invalidParent = tileAndPoly.Failed(); if (invalidParent || (grandpaRef != 0 && !m_nav.isValidPolyRef(grandpaRef))) { // The polygon has disappeared during the sliced query, // fail. m_query.status = Status.FAILURE; - return Results.of(m_query.status, iter); + return Results.Of(m_query.status, iter); } parentTile = tileAndPoly.result.Item1; @@ -1226,7 +1226,7 @@ namespace DotRecast.Detour ? getEdgeIntersectionPoint(bestNode.pos, bestRef, bestPoly, bestTile, m_query.endPos, neighbourRef, neighbourPoly, neighbourTile) : getEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile); - if (!midpod.failed()) + if (!midpod.Failed()) { neighbourPos = midpod.result; } @@ -1242,7 +1242,7 @@ namespace DotRecast.Detour { Result rayHit = raycast(parentRef, parentNode.pos, neighbourPos, m_query.filter, DT_RAYCAST_USE_COSTS, grandpaRef); - if (rayHit.succeeded()) + if (rayHit.Succeeded()) { foundShortCut = rayHit.result.t >= 1.0f; if (foundShortCut) @@ -1330,7 +1330,7 @@ namespace DotRecast.Detour m_query.status = Status.PARTIAL_RESULT; } - return Results.of(m_query.status, iter); + return Results.Of(m_query.status, iter); } /// Finalizes and returns the results of a sliced path query. @@ -1344,7 +1344,7 @@ namespace DotRecast.Detour { // Reset query. m_query = new QueryData(); - return Results.failure(path); + return Results.Failure(path); } if (m_query.startRef == m_query.endRef) @@ -1367,7 +1367,7 @@ namespace DotRecast.Detour // Reset query. m_query = new QueryData(); - return Results.of(status, path); + return Results.Of(status, path); } /// Finalizes and returns the results of an incomplete sliced path query, returning the path to the furthest @@ -1382,14 +1382,14 @@ namespace DotRecast.Detour List path = new List(64); if (null == existing || existing.Count <= 0) { - return Results.failure(path); + return Results.Failure(path); } if (m_query.status.isFailed()) { // Reset query. m_query = new QueryData(); - return Results.failure(path); + return Results.Failure(path); } if (m_query.startRef == m_query.endRef) @@ -1423,7 +1423,7 @@ namespace DotRecast.Detour // Reset query. m_query = new QueryData(); - return Results.of(status, path); + return Results.Of(status, path); } protected Status appendVertex(Vector3f pos, int flags, long refs, List straightPath, @@ -1464,7 +1464,7 @@ namespace DotRecast.Detour // Calculate portal long from = path[i]; Result> tileAndPoly = m_nav.getTileAndPolyByRef(from); - if (tileAndPoly.failed()) + if (tileAndPoly.Failed()) { return Status.FAILURE; } @@ -1474,7 +1474,7 @@ namespace DotRecast.Detour long to = path[i + 1]; tileAndPoly = m_nav.getTileAndPolyByRef(to); - if (tileAndPoly.failed()) + if (tileAndPoly.Failed()) { return Status.FAILURE; } @@ -1483,7 +1483,7 @@ namespace DotRecast.Detour Poly toPoly = tileAndPoly.result.Item2; Result portals = getPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, 0, 0); - if (portals.failed()) + if (portals.Failed()) { break; } @@ -1549,21 +1549,21 @@ namespace DotRecast.Detour if (!vIsFinite(startPos) || !vIsFinite(endPos) || null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0) { - return Results.invalidParam>(); + return Results.InvalidParam>(); } // TODO: Should this be callers responsibility? Result closestStartPosRes = closestPointOnPolyBoundary(path[0], startPos); - if (closestStartPosRes.failed()) + if (closestStartPosRes.Failed()) { - return Results.invalidParam>("Cannot find start position"); + return Results.InvalidParam>("Cannot find start position"); } var closestStartPos = closestStartPosRes.result; var closestEndPosRes = closestPointOnPolyBoundary(path[path.Count - 1], endPos); - if (closestEndPosRes.failed()) + if (closestEndPosRes.Failed()) { - return Results.invalidParam>("Cannot find end position"); + return Results.InvalidParam>("Cannot find end position"); } var closestEndPos = closestEndPosRes.result; @@ -1571,7 +1571,7 @@ namespace DotRecast.Detour Status stat = appendVertex(closestStartPos, DT_STRAIGHTPATH_START, path[0], straightPath, maxStraightPath); if (!stat.isInProgress()) { - return Results.success(straightPath); + return Results.Success(straightPath); } if (path.Count > 1) @@ -1599,12 +1599,12 @@ namespace DotRecast.Detour { // Next portal. Result portalPoints = getPortalPoints(path[i], path[i + 1]); - if (portalPoints.failed()) + if (portalPoints.Failed()) { closestEndPosRes = closestPointOnPolyBoundary(path[i], endPos); - if (closestEndPosRes.failed()) + if (closestEndPosRes.Failed()) { - return Results.invalidParam>(); + return Results.InvalidParam>(); } closestEndPos = closestEndPosRes.result; @@ -1617,7 +1617,7 @@ namespace DotRecast.Detour // Ignore status return value as we're just about to return anyway. appendVertex(closestEndPos, 0, path[i], straightPath, maxStraightPath); - return Results.success(straightPath); + return Results.Success(straightPath); } left = portalPoints.result.left; @@ -1661,7 +1661,7 @@ namespace DotRecast.Detour options); if (!stat.isInProgress()) { - return Results.success(straightPath); + return Results.Success(straightPath); } } @@ -1684,7 +1684,7 @@ namespace DotRecast.Detour stat = appendVertex(portalApex, flags, refs, straightPath, maxStraightPath); if (!stat.isInProgress()) { - return Results.success(straightPath); + return Results.Success(straightPath); } portalLeft = portalApex; @@ -1718,7 +1718,7 @@ namespace DotRecast.Detour maxStraightPath, options); if (!stat.isInProgress()) { - return Results.success(straightPath); + return Results.Success(straightPath); } } @@ -1741,7 +1741,7 @@ namespace DotRecast.Detour stat = appendVertex(portalApex, flags, refs, straightPath, maxStraightPath); if (!stat.isInProgress()) { - return Results.success(straightPath); + return Results.Success(straightPath); } portalLeft = portalApex; @@ -1764,14 +1764,14 @@ namespace DotRecast.Detour options); if (!stat.isInProgress()) { - return Results.success(straightPath); + return Results.Success(straightPath); } } } // Ignore status return value as we're just about to return anyway. appendVertex(closestEndPos, DT_STRAIGHTPATH_END, 0, straightPath, maxStraightPath); - return Results.success(straightPath); + return Results.Success(straightPath); } /// @par @@ -1806,7 +1806,7 @@ namespace DotRecast.Detour if (!m_nav.isValidPolyRef(startRef) || !vIsFinite(startPos) || !vIsFinite(endPos) || null == filter) { - return Results.invalidParam(); + return Results.InvalidParam(); } NodePool tinyNodePool = new NodePool(); @@ -1972,7 +1972,7 @@ namespace DotRecast.Detour } while (node != null); } - return Results.success(new MoveAlongSurfaceResult(bestPos, visited)); + return Results.Success(new MoveAlongSurfaceResult(bestPos, visited)); } public class PortalResult @@ -1994,9 +1994,9 @@ namespace DotRecast.Detour protected Result getPortalPoints(long from, long to) { Result> tileAndPolyResult = m_nav.getTileAndPolyByRef(from); - if (tileAndPolyResult.failed()) + if (tileAndPolyResult.Failed()) { - return Results.of(tileAndPolyResult.status, tileAndPolyResult.message); + return Results.Of(tileAndPolyResult.status, tileAndPolyResult.message); } Tuple tileAndPoly = tileAndPolyResult.result; @@ -2005,9 +2005,9 @@ namespace DotRecast.Detour int fromType = fromPoly.getType(); tileAndPolyResult = m_nav.getTileAndPolyByRef(to); - if (tileAndPolyResult.failed()) + if (tileAndPolyResult.Failed()) { - return Results.of(tileAndPolyResult.status, tileAndPolyResult.message); + return Results.Of(tileAndPolyResult.status, tileAndPolyResult.message); } tileAndPoly = tileAndPolyResult.result; @@ -2037,7 +2037,7 @@ namespace DotRecast.Detour if (link == null) { - return Results.invalidParam("No link found"); + return Results.InvalidParam("No link found"); } // Handle off-mesh connections. @@ -2056,11 +2056,11 @@ namespace DotRecast.Detour right[0] = fromTile.data.verts[fromPoly.verts[v] * 3]; right[1] = fromTile.data.verts[fromPoly.verts[v] * 3 + 1]; right[2] = fromTile.data.verts[fromPoly.verts[v] * 3 + 2]; - return Results.success(new PortalResult(left, right, fromType, toType)); + return Results.Success(new PortalResult(left, right, fromType, toType)); } } - return Results.invalidParam("Invalid offmesh from connection"); + return Results.InvalidParam("Invalid offmesh from connection"); } if (toPoly.getType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION) @@ -2078,11 +2078,11 @@ namespace DotRecast.Detour right[1] = toTile.data.verts[toPoly.verts[v] * 3 + 1]; right[2] = toTile.data.verts[toPoly.verts[v] * 3 + 2]; - return Results.success(new PortalResult(left, right, fromType, toType)); + return Results.Success(new PortalResult(left, right, fromType, toType)); } } - return Results.invalidParam("Invalid offmesh to connection"); + return Results.InvalidParam("Invalid offmesh to connection"); } // Find portal vertices. @@ -2111,16 +2111,16 @@ namespace DotRecast.Detour } } - return Results.success(new PortalResult(left, right, fromType, toType)); + return Results.Success(new PortalResult(left, right, fromType, toType)); } protected Result getEdgeMidPoint(long from, Poly fromPoly, MeshTile fromTile, long to, Poly toPoly, MeshTile toTile) { Result ppoints = getPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, 0, 0); - if (ppoints.failed()) + if (ppoints.Failed()) { - return Results.of(ppoints.status, ppoints.message); + return Results.Of(ppoints.status, ppoints.message); } var left = ppoints.result.left; @@ -2129,16 +2129,16 @@ namespace DotRecast.Detour mid[0] = (left[0] + right[0]) * 0.5f; mid[1] = (left[1] + right[1]) * 0.5f; mid[2] = (left[2] + right[2]) * 0.5f; - return Results.success(mid); + return Results.Success(mid); } protected Result getEdgeIntersectionPoint(Vector3f fromPos, long from, Poly fromPoly, MeshTile fromTile, Vector3f toPos, long to, Poly toPoly, MeshTile toTile) { Result ppoints = getPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, 0, 0); - if (ppoints.failed()) + if (ppoints.Failed()) { - return Results.of(ppoints.status, ppoints.message); + return Results.Of(ppoints.status, ppoints.message); } Vector3f left = ppoints.result.left; @@ -2151,7 +2151,7 @@ namespace DotRecast.Detour } Vector3f pt = vLerp(left, right, t); - return Results.success(pt); + return Results.Success(pt); } private static float s = 1.0f / 255.0f; @@ -2215,7 +2215,7 @@ namespace DotRecast.Detour if (!m_nav.isValidPolyRef(startRef) || !vIsFinite(startPos) || !vIsFinite(endPos) || null == filter || (prevRef != 0 && !m_nav.isValidPolyRef(prevRef))) { - return Results.invalidParam(); + return Results.InvalidParam(); } RaycastHit hit = new RaycastHit(); @@ -2261,7 +2261,7 @@ namespace DotRecast.Detour if (!iresult.intersects) { // Could not hit the polygon, keep the old t and report hit. - return Results.success(hit); + return Results.Success(hit); } hit.hitEdgeIndex = iresult.segMax; @@ -2287,7 +2287,7 @@ namespace DotRecast.Detour curRef, tile, poly); } - return Results.success(hit); + return Results.Success(hit); } // Follow neighbours. @@ -2417,7 +2417,7 @@ namespace DotRecast.Detour hit.hitNormal[1] = 0; hit.hitNormal[2] = -dx; vNormalize(ref hit.hitNormal); - return Results.success(hit); + return Results.Success(hit); } // No hit, advance to neighbour polygon. @@ -2429,7 +2429,7 @@ namespace DotRecast.Detour poly = nextPoly; } - return Results.success(hit); + return Results.Success(hit); } /// @par @@ -2483,7 +2483,7 @@ namespace DotRecast.Detour if (!m_nav.isValidPolyRef(startRef) || !vIsFinite(centerPos) || radius < 0 || !float.IsFinite(radius) || null == filter) { - return Results.invalidParam(); + return Results.InvalidParam(); } List resultRef = new List(); @@ -2561,7 +2561,7 @@ namespace DotRecast.Detour // Find edge and calc distance to the edge. Result pp = getPortalPoints(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile, 0, 0); - if (pp.failed()) + if (pp.Failed()) { continue; } @@ -2616,7 +2616,7 @@ namespace DotRecast.Detour } } - return Results.success(new FindPolysAroundResult(resultRef, resultParent, resultCost)); + return Results.Success(new FindPolysAroundResult(resultRef, resultParent, resultCost)); } /// @par @@ -2660,7 +2660,7 @@ namespace DotRecast.Detour int nverts = verts.Length / 3; if (!m_nav.isValidPolyRef(startRef) || null == verts || nverts < 3 || null == filter) { - return Results.invalidParam(); + return Results.InvalidParam(); } List resultRef = new List(); @@ -2749,7 +2749,7 @@ namespace DotRecast.Detour // Find edge and calc distance to the edge. Result pp = getPortalPoints(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile, 0, 0); - if (pp.failed()) + if (pp.Failed()) { continue; } @@ -2809,7 +2809,7 @@ namespace DotRecast.Detour } } - return Results.success(new FindPolysAroundResult(resultRef, resultParent, resultCost)); + return Results.Success(new FindPolysAroundResult(resultRef, resultParent, resultCost)); } /// @par @@ -2852,7 +2852,7 @@ namespace DotRecast.Detour if (!m_nav.isValidPolyRef(startRef) || !vIsFinite(centerPos) || radius < 0 || !float.IsFinite(radius) || null == filter) { - return Results.invalidParam(); + return Results.InvalidParam(); } List resultRef = new List(); @@ -2925,7 +2925,7 @@ namespace DotRecast.Detour // Find edge and calc distance to the edge. Result pp = getPortalPoints(curRef, curPoly, curTile, neighbourRef, neighbourPoly, neighbourTile, 0, 0); - if (pp.failed()) + if (pp.Failed()) { continue; } @@ -3006,7 +3006,7 @@ namespace DotRecast.Detour } } - return Results.success(new FindLocalNeighbourhoodResult(resultRef, resultParent)); + return Results.Success(new FindLocalNeighbourhoodResult(resultRef, resultParent)); } public class SegInterval @@ -3063,14 +3063,14 @@ namespace DotRecast.Detour public Result getPolyWallSegments(long refs, bool storePortals, QueryFilter filter) { Result> tileAndPoly = m_nav.getTileAndPolyByRef(refs); - if (tileAndPoly.failed()) + if (tileAndPoly.Failed()) { - return Results.of(tileAndPoly.status, tileAndPoly.message); + return Results.Of(tileAndPoly.status, tileAndPoly.message); } if (null == filter) { - return Results.invalidParam(); + return Results.InvalidParam(); } MeshTile tile = tileAndPoly.result.Item1; @@ -3174,7 +3174,7 @@ namespace DotRecast.Detour } } - return Results.success(new GetPolyWallSegmentsResult(segmentVerts, segmentRefs)); + return Results.Success(new GetPolyWallSegmentsResult(segmentVerts, segmentRefs)); } /// @par @@ -3204,7 +3204,7 @@ namespace DotRecast.Detour if (!m_nav.isValidPolyRef(startRef) || !vIsFinite(centerPos) || maxRadius < 0 || !float.IsFinite(maxRadius) || null == filter) { - return Results.invalidParam(); + return Results.InvalidParam(); } m_nodePool.clear(); @@ -3361,7 +3361,7 @@ namespace DotRecast.Detour { var midPoint = getEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile); - if (midPoint.succeeded()) + if (midPoint.Succeeded()) { neighbourNode.pos = midPoint.result; } @@ -3403,7 +3403,7 @@ namespace DotRecast.Detour vNormalize(ref hitNormal); } - return Results.success(new FindDistanceToWallResult((float)Math.Sqrt(radiusSqr), hitPos, hitNormal)); + return Results.Success(new FindDistanceToWallResult((float)Math.Sqrt(radiusSqr), hitPos, hitNormal)); } /// Returns true if the polygon reference is valid and passes the filter restrictions. @@ -3412,7 +3412,7 @@ namespace DotRecast.Detour public bool isValidPolyRef(long refs, QueryFilter filter) { Result> tileAndPolyResult = m_nav.getTileAndPolyByRef(refs); - if (tileAndPolyResult.failed()) + if (tileAndPolyResult.Failed()) { return false; } @@ -3447,22 +3447,22 @@ namespace DotRecast.Detour { if (!m_nav.isValidPolyRef(endRef)) { - return Results.invalidParam>("Invalid end ref"); + return Results.InvalidParam>("Invalid end ref"); } List nodes = m_nodePool.findNodes(endRef); if (nodes.Count != 1) { - return Results.invalidParam>("Invalid end ref"); + return Results.InvalidParam>("Invalid end ref"); } Node endNode = nodes[0]; if ((endNode.flags & DT_NODE_CLOSED) == 0) { - return Results.invalidParam>("Invalid end ref"); + return Results.InvalidParam>("Invalid end ref"); } - return Results.success(getPathToNode(endNode)); + return Results.Success(getPathToNode(endNode)); } /** diff --git a/src/DotRecast.Detour/PathUtils.cs b/src/DotRecast.Detour/PathUtils.cs index f1c130b..19d6337 100644 --- a/src/DotRecast.Detour/PathUtils.cs +++ b/src/DotRecast.Detour/PathUtils.cs @@ -35,7 +35,7 @@ namespace DotRecast.Detour { // Find steer target. Result> result = navQuery.findStraightPath(startPos, endPos, path, MAX_STEER_POINTS, 0); - if (result.failed()) + if (result.Failed()) { return null; } @@ -154,7 +154,7 @@ namespace DotRecast.Detour List neis = new List(); Result> tileAndPoly = navQuery.getAttachedNavMesh().getTileAndPolyByRef(path[0]); - if (tileAndPoly.failed()) + if (tileAndPoly.Failed()) { return path; } diff --git a/src/DotRecast.Detour/QueryResults/Result.cs b/src/DotRecast.Detour/QueryResults/Result.cs index a38e23c..75f84b5 100644 --- a/src/DotRecast.Detour/QueryResults/Result.cs +++ b/src/DotRecast.Detour/QueryResults/Result.cs @@ -22,47 +22,47 @@ namespace DotRecast.Detour.QueryResults { public static class Results { - public static Result success(T result) + public static Result Success(T result) { return new Result(result, Status.SUCCSESS, null); } - public static Result failure() + public static Result Failure() { return new Result(default, Status.FAILURE, null); } - public static Result invalidParam() + public static Result InvalidParam() { return new Result(default, Status.FAILURE_INVALID_PARAM, null); } - public static Result failure(string message) + public static Result Failure(string message) { return new Result(default, Status.FAILURE, message); } - public static Result invalidParam(string message) + public static Result InvalidParam(string message) { return new Result(default, Status.FAILURE_INVALID_PARAM, message); } - public static Result failure(T result) + public static Result Failure(T result) { return new Result(result, Status.FAILURE, null); } - public static Result partial(T result) + public static Result Partial(T result) { return new Result(default, Status.PARTIAL_RESULT, null); } - public static Result of(Status status, string message) + public static Result Of(Status status, string message) { return new Result(default, status, message); } - public static Result of(Status status, T result) + public static Result Of(Status status, T result) { return new Result(result, status, null); } @@ -82,12 +82,12 @@ namespace DotRecast.Detour.QueryResults } - public bool failed() + public bool Failed() { return status.isFailed(); } - public bool succeeded() + public bool Succeeded() { return status.isSuccess(); } diff --git a/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs b/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs index 64a4ce6..016fef8 100644 --- a/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs +++ b/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs @@ -1282,7 +1282,7 @@ public class RecastDebugDraw : DebugDraw } Result> tileAndPolyResult = mesh.getTileAndPolyByRef(refs); - if (tileAndPolyResult.failed()) + if (tileAndPolyResult.Failed()) { return; } diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs index 33694d6..fbaa04e 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs @@ -149,7 +149,7 @@ public class CrowdProfilingTool private Vector3f? getMobPosition(NavMeshQuery navquery, QueryFilter filter) { Result result = navquery.findRandomPoint(filter, rnd); - if (result.succeeded()) + if (result.Succeeded()) { return result.result.getRandomPt(); } @@ -164,7 +164,7 @@ public class CrowdProfilingTool int zone = (int)(rnd.frand() * zones.Count); Result result = navquery.findRandomPointWithinCircle(zones[zone].getRandomRef(), zones[zone].getRandomPt(), zoneRadius, filter, rnd); - if (result.succeeded()) + if (result.Succeeded()) { return result.result.getRandomPt(); } @@ -184,7 +184,7 @@ public class CrowdProfilingTool for (int k = 0; k < 100; k++) { Result result = navquery.findRandomPoint(filter, rnd); - if (result.succeeded()) + if (result.Succeeded()) { bool valid = true; foreach (FindRandomPointResult zone in zones) @@ -281,11 +281,11 @@ public class CrowdProfilingTool { // Move somewhere Result nearestPoly = navquery.findNearestPoly(ag.npos, crowd.getQueryExtents(), filter); - if (nearestPoly.succeeded()) + if (nearestPoly.Succeeded()) { Result result = navquery.findRandomPointAroundCircle(nearestPoly.result.getNearestRef(), agentData.home, zoneRadius * 2f, filter, rnd); - if (result.succeeded()) + if (result.Succeeded()) { crowd.requestMoveTarget(ag, result.result.getRandomRef(), result.result.getRandomPt()); } @@ -296,11 +296,11 @@ public class CrowdProfilingTool { // Move somewhere close Result nearestPoly = navquery.findNearestPoly(ag.npos, crowd.getQueryExtents(), filter); - if (nearestPoly.succeeded()) + if (nearestPoly.Succeeded()) { Result result = navquery.findRandomPointAroundCircle(nearestPoly.result.getNearestRef(), agentData.home, zoneRadius * 0.2f, filter, rnd); - if (result.succeeded()) + if (result.Succeeded()) { crowd.requestMoveTarget(ag, result.result.getRandomRef(), result.result.getRandomPt()); } diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index 61236fc..b8bc51b 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -199,7 +199,7 @@ public class CrowdTool : Tool if (refs != 0) { Result flags = nav.getPolyFlags(refs); - if (flags.succeeded()) + if (flags.Succeeded()) { nav.setPolyFlags(refs, flags.result ^ SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED); } diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs index 0587bb0..1f707c9 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs @@ -252,7 +252,7 @@ public class TestNavmeshTool : Tool polys = PathUtils.fixupShortcuts(polys, m_navQuery); Result polyHeight = m_navQuery.getPolyHeight(polys[0], moveAlongSurface.getResultPos()); - if (polyHeight.succeeded()) + if (polyHeight.Succeeded()) { iterPos[1] = polyHeight.result; } @@ -288,7 +288,7 @@ public class TestNavmeshTool : Tool // Handle the connection. var offMeshCon = m_navMesh.getOffMeshConnectionPolyEndPoints(prevRef, polyRef); - if (offMeshCon.succeeded()) + if (offMeshCon.Succeeded()) { var startPos = offMeshCon.result.Item1; var endPos = offMeshCon.result.Item2; @@ -336,7 +336,7 @@ public class TestNavmeshTool : Tool { Result result = m_navQuery .closestPointOnPoly(m_polys[m_polys.Count - 1], m_epos); - if (result.succeeded()) + if (result.Succeeded()) { epos = result.result.getClosest(); } @@ -368,7 +368,7 @@ public class TestNavmeshTool : Tool { { Result hit = m_navQuery.raycast(m_startRef, m_spos, m_epos, m_filter, 0, 0); - if (hit.succeeded()) + if (hit.Succeeded()) { m_polys = hit.result.path; if (hit.result.t > 1) @@ -390,7 +390,7 @@ public class TestNavmeshTool : Tool { Result result = m_navQuery .getPolyHeight(hit.result.path[hit.result.path.Count - 1], m_hitPos); - if (result.succeeded()) + if (result.Succeeded()) { m_hitPos[1] = result.result; } @@ -411,7 +411,7 @@ public class TestNavmeshTool : Tool m_distanceToWall = 0.0f; Result result = m_navQuery.findDistanceToWall(m_startRef, m_spos, 100.0f, m_filter); - if (result.succeeded()) + if (result.Succeeded()) { m_distanceToWall = result.result.getDistance(); m_hitPos = result.result.getPosition(); @@ -428,7 +428,7 @@ public class TestNavmeshTool : Tool float dist = (float)Math.Sqrt(dx * dx + dz * dz); Result result = m_navQuery.findPolysAroundCircle(m_startRef, m_spos, dist, m_filter); - if (result.succeeded()) + if (result.Succeeded()) { m_polys = result.result.getRefs(); m_parent = result.result.getParentRefs(); @@ -460,7 +460,7 @@ public class TestNavmeshTool : Tool m_queryPoly[11] = m_epos[2] + nz; Result result = m_navQuery.findPolysAroundShape(m_startRef, m_queryPoly, m_filter); - if (result.succeeded()) + if (result.Succeeded()) { m_polys = result.result.getRefs(); m_parent = result.result.getParentRefs(); @@ -474,7 +474,7 @@ public class TestNavmeshTool : Tool m_neighbourhoodRadius = m_sample.getSettingsUI().getAgentRadius() * 20.0f; Result result = m_navQuery.findLocalNeighbourhood(m_startRef, m_spos, m_neighbourhoodRadius, m_filter); - if (result.succeeded()) + if (result.Succeeded()) { m_polys = result.result.getRefs(); m_parent = result.result.getParentRefs(); @@ -496,7 +496,7 @@ public class TestNavmeshTool : Tool { Result result = m_navQuery.findRandomPointAroundCircle(m_startRef, m_spos, dist, m_filter, new FRand(), constraint); - if (result.succeeded()) + if (result.Succeeded()) { randomPoints.Add(result.result.getRandomPt()); } @@ -840,7 +840,7 @@ public class TestNavmeshTool : Tool { Result result = m_sample.getNavMeshQuery() .getPolyWallSegments(m_polys[i], false, m_filter); - if (result.succeeded()) + if (result.Succeeded()) { dd.begin(LINES, 2.0f); GetPolyWallSegmentsResult wallSegments = result.result; @@ -951,7 +951,7 @@ public class TestNavmeshTool : Tool Vector3f center = Vector3f.Zero; Result> tileAndPoly = navMesh.getTileAndPolyByRef(refs); - if (tileAndPoly.succeeded()) + if (tileAndPoly.Succeeded()) { MeshTile tile = tileAndPoly.result.Item1; Poly poly = tileAndPoly.result.Item2; @@ -996,7 +996,7 @@ public class TestNavmeshTool : Tool { Result result = m_navQuery .closestPointOnPoly(m_polys[m_polys.Count - 1], m_epos); - if (result.succeeded()) + if (result.Succeeded()) { epos = result.result.getClosest(); } @@ -1005,7 +1005,7 @@ public class TestNavmeshTool : Tool { Result> result = m_navQuery.findStraightPath(m_spos, epos, m_polys, MAX_POLYS, NavMeshQuery.DT_STRAIGHTPATH_ALL_CROSSINGS); - if (result.succeeded()) + if (result.Succeeded()) { m_straightPath = result.result; } diff --git a/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs b/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs index 4f4b695..f25cb59 100644 --- a/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs +++ b/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs @@ -44,7 +44,7 @@ public class PathCorridorTest straightPath.Add(new StraightPathItem(Vector3f.Of(12, 20, 30.00002f), 0, 0)); straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), 0, 0)); straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), 0, 0)); - Result> result = Results.success(straightPath); + Result> result = Results.Success(straightPath); var mockQuery = new Mock(It.IsAny()); mockQuery.Setup(q => q.findStraightPath( It.IsAny(), @@ -67,7 +67,7 @@ public class PathCorridorTest straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), 0, 0)); straightPath.Add(new StraightPathItem(Vector3f.Of(12f, 22, 33f), NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh - Result> result = Results.success(straightPath); + Result> result = Results.Success(straightPath); var mockQuery = new Mock(It.IsAny()); var s = mockQuery.Setup(q => q.findStraightPath( diff --git a/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs b/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs index aea71dd..d1b8e1b 100644 --- a/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs +++ b/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs @@ -110,7 +110,7 @@ public class UnityAStarPathfindingImporterTest { Vector3f position = positions[i]; Result result = query.findNearestPoly(position, extents, filter); - Assert.That(result.succeeded(), Is.True); + Assert.That(result.Succeeded(), Is.True); Assert.That(result.result.getNearestPos(), Is.Not.EqualTo(Vector3f.Zero), "Nearest start position is null!"); results[i] = result.result; } diff --git a/test/DotRecast.Detour.Test/FindNearestPolyTest.cs b/test/DotRecast.Detour.Test/FindNearestPolyTest.cs index 3026170..e24f13a 100644 --- a/test/DotRecast.Detour.Test/FindNearestPolyTest.cs +++ b/test/DotRecast.Detour.Test/FindNearestPolyTest.cs @@ -43,7 +43,7 @@ public class FindNearestPolyTest : AbstractDetourTest { Vector3f startPos = startPoss[i]; Result poly = query.findNearestPoly(startPos, extents, filter); - Assert.That(poly.succeeded(), Is.True); + Assert.That(poly.Succeeded(), Is.True); Assert.That(poly.result.getNearestRef(), Is.EqualTo(POLY_REFS[i])); for (int v = 0; v < POLY_POS[i].Length; v++) { @@ -75,7 +75,7 @@ public class FindNearestPolyTest : AbstractDetourTest { Vector3f startPos = startPoss[i]; Result poly = query.findNearestPoly(startPos, extents, filter); - Assert.That(poly.succeeded(), Is.True); + Assert.That(poly.Succeeded(), Is.True); Assert.That(poly.result.getNearestRef(), Is.EqualTo(0L)); for (int v = 0; v < POLY_POS[i].Length; v++) { diff --git a/test/DotRecast.Detour.Test/FindPolysAroundCircleTest.cs b/test/DotRecast.Detour.Test/FindPolysAroundCircleTest.cs index 1e5f2ff..a99e049 100644 --- a/test/DotRecast.Detour.Test/FindPolysAroundCircleTest.cs +++ b/test/DotRecast.Detour.Test/FindPolysAroundCircleTest.cs @@ -107,7 +107,7 @@ public class FindPolysAroundCircleTest : AbstractDetourTest long startRef = startRefs[i]; Vector3f startPos = startPoss[i]; Result result = query.findPolysAroundCircle(startRef, startPos, 7.5f, filter); - Assert.That(result.succeeded(), Is.True); + Assert.That(result.Succeeded(), Is.True); FindPolysAroundResult polys = result.result; Assert.That(polys.getRefs().Count, Is.EqualTo(REFS[i].Length)); for (int v = 0; v < REFS[i].Length; v++) diff --git a/test/DotRecast.Detour.Test/MoveAlongSurfaceTest.cs b/test/DotRecast.Detour.Test/MoveAlongSurfaceTest.cs index 3ab5bde..73fa589 100644 --- a/test/DotRecast.Detour.Test/MoveAlongSurfaceTest.cs +++ b/test/DotRecast.Detour.Test/MoveAlongSurfaceTest.cs @@ -75,7 +75,7 @@ public class MoveAlongSurfaceTest : AbstractDetourTest Vector3f startPos = startPoss[i]; Vector3f endPos = endPoss[i]; Result result = query.moveAlongSurface(startRef, startPos, endPos, filter); - Assert.That(result.succeeded(), Is.True); + Assert.That(result.Succeeded(), Is.True); MoveAlongSurfaceResult path = result.result; for (int v = 0; v < 3; v++) { diff --git a/test/DotRecast.Detour.Test/RandomPointTest.cs b/test/DotRecast.Detour.Test/RandomPointTest.cs index e7aa59e..f8d24f2 100644 --- a/test/DotRecast.Detour.Test/RandomPointTest.cs +++ b/test/DotRecast.Detour.Test/RandomPointTest.cs @@ -36,7 +36,7 @@ public class RandomPointTest : AbstractDetourTest for (int i = 0; i < 1000; i++) { Result point = query.findRandomPoint(filter, f); - Assert.That(point.succeeded(), Is.True); + Assert.That(point.Succeeded(), Is.True); Tuple tileAndPoly = navmesh.getTileAndPolyByRef(point.result.getRandomRef()).result; float[] bmin = new float[2]; float[] bmax = new float[2]; @@ -66,7 +66,7 @@ public class RandomPointTest : AbstractDetourTest { Result result = query.findRandomPointAroundCircle(point.getRandomRef(), point.getRandomPt(), 5f, filter, f); - Assert.That(result.failed(), Is.False); + Assert.That(result.Failed(), Is.False); point = result.result; Tuple tileAndPoly = navmesh.getTileAndPolyByRef(point.getRandomRef()).result; float[] bmin = new float[2]; @@ -98,7 +98,7 @@ public class RandomPointTest : AbstractDetourTest { Result result = query.findRandomPointWithinCircle(point.getRandomRef(), point.getRandomPt(), radius, filter, f); - Assert.That(result.failed(), Is.False); + Assert.That(result.Failed(), Is.False); float distance = vDist2D(point.getRandomPt(), result.result.getRandomPt()); Assert.That(distance <= radius, Is.True); point = result.result;