/// <summary> /// Inicializa A* /// </summary> protected void InitSearchAStart() { NavigationMap navigationMap = GameMgr.GetInstance().GetCustomMgrs().GetServer <NavigationMap>(); WayPoint wpInit = navigationMap.FindWayPointNear(this.transform.position); WayPoint wpEnd = navigationMap.FindWayPointNear(m_target.transform.position); // TODO: En vez de devolver solo el último punto llamar al PathfindingJob if (m_pathfinding) { NativeArray <Vector3> wayPoints = new NativeArray <Vector3>(10, Allocator.TempJob); NativeArray <int> numelements = new NativeArray <int>(1, Allocator.TempJob); PathfindingJob pathJob = new PathfindingJob(navigationMap.getMap(), wpInit.ID, wpEnd.ID, ref wayPoints, ref numelements); JobHandle handle = pathJob.Schedule(); handle.Complete(); m_waypointList.Clear(); for (int i = numelements[0]; i > 0; --i) { m_waypointList.Add(wayPoints[i - 1]); } wayPoints.Dispose(); numelements.Dispose(); pathJob.Delete(); NextWaypoint(); } else { m_waypointList.Clear(); m_waypointList.Add(wpInit.transform.position); m_waypointList.Add(wpEnd.transform.position); } }
public void SetDestinationJob(Vector2 dest, bool run = false, bool hide = false) { nonce += 1; int lastKnownNonce = nonce; NativeList <Vector2> rawList = new NativeList <Vector2>(Allocator.TempJob); //Debug.Log(name + "'s job started with jobId = " + lastKnownNonce); // Set up the job data PathfindingJob fetcher = new PathfindingJob { start = mover.GetDiscretePosition(), dest = dest, maxPathLength = maxPathLength, path = rawList, jobId = lastKnownNonce, running = run, hiding = hide }; // Schedule the job JobHandle handle = fetcher.Schedule(); activeJobs.Add(new KeyValuePair <JobHandle, PathfindingJob>(handle, fetcher)); //if (!usesMultithreading) // handle.Complete(); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new PathfindingJob { regions = regions, aiUnits = aiUnits }; return(job.Schedule(aiUnits.Length, 64, inputDeps)); }