Advertisement
Guest User

Untitled

a guest
Feb 20th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1.         private FindPathToTarget _findPathToTarget;
  2.  
  3.             _findPathToTarget = new FindPathToTarget();
  4.             _findPathToTarget.maxIterationsPerFrame = maxPathFindStepsPerFrame;
  5.        
  6.     public bool GetPathToMoveTarget(Agent agent, float deltaTime, out PathBase path)
  7.         {
  8.             bool stillWorking = false;
  9.             path = null;
  10.             if (_findPathToTarget.inProgress)
  11.             {
  12.                 stillWorking = (_findPathToTarget.Execute(agent, deltaTime) == Action.Action.ActionResult.RUNNING);
  13.             }
  14.             else
  15.             {
  16.                 _findPathToTarget.SetActionContext(agent.actionContext);
  17.                 if (_currentPathGraph is NavGridMultiRegionGraph) ((NavGridMultiRegionGraph)_currentPathGraph).stepUpHeight = agent.Kinematic.StepUpHeight;
  18.                 _findPathToTarget.pathGraph = _currentPathGraph;
  19.                 _findPathToTarget.pathTarget = moveTarget.GetMoveTarget(deltaTime);
  20.                 _findPathToTarget.Start(agent, deltaTime);
  21.                 stillWorking = (_findPathToTarget.Execute(agent, deltaTime) == Action.Action.ActionResult.RUNNING);
  22.             }
  23.             if (!stillWorking)
  24.             {
  25.                 _findPathToTarget.Stop(agent, deltaTime);
  26.             }
  27.             path = agent.actionContext.GetContextItem<PathBase>(PathConstants.PATHTOTARGET);
  28.             return !stillWorking;
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement