/// <summary> /// Finds a path using waypoints. Use whenever the direct path is blocked. /// </summary> /// <param name="from">First endpoint of the path. Will be duplicated in the returned path.</param> /// <param name="to">First endpoint of the path. Will be duplicated in the returned path.</param> /// <param name="pathFoundHandler">To be called after the pathfinder is finished. Will receive the found path, or null when there's none.</param> /// <param name="userData">An object that will be passed to pathFoundHandler. Can be used to identify the query.</param> /// <param name="useRaycasts">Whether the bot should use raycasts.</param> public static void FindPathInBackground(Vector3 from, Vector3 to, PathFoundHandler pathFoundHandler, object userData, bool useRaycasts) { MyCommonDebugUtils.AssertDebug(from != null && to != null && pathFoundHandler != null); m_queue.Enqueue(new PathToBeFound(from, to, pathFoundHandler, userData, useRaycasts)); //m_event.Set(); m_findPathTask = Parallel.Start(m_pathfindingHelper); }
public PathToBeFound(Vector3 from, Vector3 to, PathFoundHandler pathFoundHandler, object userData, bool useRaycasts) { From = from; To = to; PathFoundHandler = pathFoundHandler; UserData = userData; UseRaycasts = useRaycasts; }
private void CallPathFoundEvent(ArrayList path) { var args = new PathFoundEventArgs(path); PathFoundHandler handler = PathFound; if (handler != null) { handler.DynamicInvoke(this, args); } }