/// <summary> /// Request a path from point pathStart to point pathEnd, in a specific grid. /// </summary> /// <param name="pathStart">The starting point of the path</param> /// <param name="pathEnd">The ending point of the path</param> /// <param name="callback">A function with the parameters (Path)</param> /// <param name="grid">The specific grid you want to find the path on.</param> public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, Action<Path> callback, GridGraph grid = null) { if (grid == null) { grid = Grid; } if (grid.Scanning) { return; } string Name = callback.GetHashCode().ToString(); PathRequest newRequest = new PathRequest(pathStart, pathEnd, callback, Name, grid); PathRequest contains = instance.pathRequests.Contains(Name); if (contains != null) { instance.pathRequests.Remove(contains); } instance.pathRequests.Enqueue(newRequest); instance.Process(); }
/// <summary> /// Check if the queue contains the agent with the Callback callback. /// </summary> /// <param name="callback">The callback to check for,</param> /// <returns>Whether or not it contains the object.</returns> public static bool Contains(Action<Path> callback) { if (instance.pathRequests.Contains(callback.GetHashCode().ToString()) != null) { return true; } return false; }