- // We're done with the current path, so find the path to\r
- // the next waypoint... forever.\r
- mIdlePathIndex++;\r
- PathFinder pathFinder = new PathFinder(mGame.Grid);\r
- mPath = new List<Point>(32);\r
- mPath.Add(Coordinates);\r
- mPath.AddRange(pathFinder.GetPath(mMotion.Coordinates, mIdlePath[mIdlePathIndex % mIdlePath.Count]));\r
- mPath.Add(mIdlePath[mIdlePathIndex % mIdlePath.Count]);\r
- mPathIndex = 0;\r
+ if (mPathIndex >= mPath.Count)\r
+ {\r
+ // We're done with the current path, so find the path to\r
+ // the next waypoint... forever.\r
+ mWaypointIndex++;\r
+ ChartPath();\r
+ }\r
+\r
+ // We need to make sure our direction is set to the next cell\r
+ // we want to be. If our current coordinates match that, we need\r
+ // to change our direction to get to the next cell.\r
+ else if (mPath[mPathIndex] == mMotion.Coordinates)\r
+ {\r
+ mPathIndex++;\r
+ mPathDirection = MovementManager.GetDirection(mMotion.Coordinates, mPath[mPathIndex % mPath.Count]);\r
+ }\r
+\r
+ return mPathDirection;\r