/// <summary> /// MoveAsync /// </summary> /// <param name="sourceGroupId"></param> /// <param name="targetGroupId"></param> /// <param name="movingLocation"></param> /// <param name="isChild"></param> /// <param name="modelState"></param> /// <returns></returns> public async Task <bool> MoveAsync(Guid sourceGroupId, Guid targetGroupId, MovingLocation movingLocation, bool?isChild, ModelStateDictionary modelState) { var result = await _manager.MoveAsync(sourceGroupId, targetGroupId, movingLocation, isChild, modelState); if (result) { CleanupCache(); } return(result); }
public async Task <bool> MoveAsync(Guid sourceGroupId, Guid targetGroupId, MovingLocation movingLocation, bool?isChild, ModelStateDictionary modelState) { var result = await _repository.MoveAsync(sourceGroupId, targetGroupId, movingLocation, isChild, modelState); if (result) { await _cache.RemoveAsync(GroupListCacheKey); } return(result); }
/// <summary> /// Generates a detour that avoids the obstacle that was found by the provided entryRay and hit. /// </summary> /// <param name="entryRay">The ray used to find the entryPt.</param> /// <param name="entryHit">The info for the entryHit.</param> /// <returns></returns> private INavigableTarget GenerateDetourAroundObstacle(Ray entryRay, RaycastHit entryHit) { INavigableTarget detour = null; Transform obstacle = entryHit.transform; string obstacleName = obstacle.parent.name + "." + obstacle.name; Vector3 rayEntryPoint = entryHit.point; SphereCollider obstacleCollider = entryHit.collider as SphereCollider; float obstacleRadius = obstacleCollider.radius; float rayLength = (2F * obstacleRadius) + 1F; Vector3 pointBeyondKeepoutZone = entryRay.GetPoint(entryHit.distance + rayLength); Vector3 rayExitPoint = FindRayExitPoint(entryRay, entryHit, pointBeyondKeepoutZone, 0); //D.Log("{0} found RayExitPoint. EntryPt to exitPt distance = {1}.", Name, Vector3.Distance(rayEntryPoint, rayExitPoint)); Vector3 obstacleCenter = obstacle.position; var ptOnSphere = UnityUtility.FindClosestPointOnSphereOrthogonalToIntersectingLine(rayEntryPoint, rayExitPoint, obstacleCenter, obstacleRadius); float obstacleClearanceLeeway = 2F; // HACK var detourWorldSpaceLocation = ptOnSphere + (ptOnSphere - obstacleCenter).normalized * obstacleClearanceLeeway; INavigableTarget obstacleParent = obstacle.gameObject.GetSafeFirstInterfaceInParents<INavigableTarget>(); D.Assert(obstacleParent != null, "Obstacle {0} does not have a {1} parent.".Inject(obstacleName, typeof(INavigableTarget).Name)); if (obstacleParent.IsMobile) { var detourRelativeToObstacleCenter = detourWorldSpaceLocation - obstacleCenter; var detourRef = new Reference<Vector3>(() => obstacle.position + detourRelativeToObstacleCenter); detour = new MovingLocation(detourRef); } else { detour = new StationaryLocation(detourWorldSpaceLocation); } //D.Log("{0} found detour {1} to avoid obstacle {2} at {3}. \nDistance to detour = {4:0.#}. Obstacle keepout radius = {5:0.##}. Detour is {6:0.#} from obstacle center.", //Name, detour.FullName, obstacleName, obstacleCenter, Vector3.Distance(Position, detour.Position), obstacleRadius, Vector3.Distance(obstacleCenter, detour.Position)); return detour; }
/// <summary> /// MoveAsync /// </summary> /// <param name="sourceDisplayOrder"></param> /// <param name="targetDisplayOrder"></param> /// <param name="movingLocation"></param> /// <param name="isChild"></param> /// <param name="modelState"></param> /// <returns></returns> public async Task <bool> MoveByDisplayOrderAsync(int sourceDisplayOrder, int targetDisplayOrder, MovingLocation movingLocation, bool?isChild, ModelStateDictionary modelState) { var result = await _manager.MoveByDisplayOrderAsync(sourceDisplayOrder, targetDisplayOrder, movingLocation, isChild, modelState); if (result) { CleanupCache(); } return(result); }
public async Task <bool> MoveAsync(int sourceDisplayOrder, int targetDisplayOrder, MovingLocation movingLocation, bool?isChild, ModelStateDictionary modelState) { var result = await _repository.MoveAsync(sourceDisplayOrder, targetDisplayOrder, movingLocation, isChild, modelState); if (result) { await _cache.RemoveAsync(GroupListCacheKey); } return(result); }