Pathfinding.AstarProfiler.StartFastProfile C# (CSharp) Method

StartFastProfile() private method

private StartFastProfile ( int tag ) : void
tag int
return void
		public static void StartFastProfile(int tag)
		{
			//profiles.TryGetValue(tag, out point);
			fastProfiles[tag].watch.Start();//lastRecorded = DateTime.UtcNow;
		}
		

Usage Example

Ejemplo n.º 1
0
        /** Opens nodes until there are none left to search (or until the max time limit has been exceeded) */
        public override void CalculateStep(long targetTick)
        {
            int counter = 0;

            //Continue to search while there hasn't ocurred an error and the end hasn't been found
            while (CompleteState == PathCompleteState.NotCalculated)
            {
                searchedNodes++;

                AstarProfiler.StartFastProfile(4);
                //Debug.DrawRay ((Vector3)currentR.node.Position, Vector3.up*2,Color.red);

                //Loop through all walkable neighbours of the node and add them to the open list.
                currentR.node.Open(this, currentR, pathHandler);

                // Insert into internal search tree
                if (saveParents)
                {
                    parents[currentR.node] = currentR.parent.node;
                }

                AstarProfiler.EndFastProfile(4);

                //any nodes left to search?
                if (pathHandler.HeapEmpty())
                {
                    CompleteState = PathCompleteState.Complete;
                    break;
                }

                //Select the node with the lowest F score and remove it from the open list
                AstarProfiler.StartFastProfile(7);
                currentR = pathHandler.PopNode();
                AstarProfiler.EndFastProfile(7);

                //Check for time every 500 nodes, roughly every 0.5 ms usually
                if (counter > 500)
                {
                    //Have we exceded the maxFrameTime, if so we should wait one frame before continuing the search since we don't want the game to lag
                    if (DateTime.UtcNow.Ticks >= targetTick)
                    {
                        //Return instead of yield'ing, a separate function handles the yield (CalculatePaths)
                        return;
                    }
                    counter = 0;

                    if (searchedNodes > 1000000)
                    {
                        throw new Exception("Probable infinite loop. Over 1,000,000 nodes searched");
                    }
                }

                counter++;
            }
        }
All Usage Examples Of Pathfinding.AstarProfiler::StartFastProfile