+ if (mPathIndex >= mPath.Count)\r
+ {\r
+ // We're done with the current path, so find the path to\r
+ // the next waypoint... forever.\r
+ switch (mState)\r
+ {\r
+ case AiState.Pacing:\r
+ SetWaypoint();\r
+ ChartPath();\r
+ break;\r
+\r
+ default:\r
+ mPathIndex = 0;\r
+ mPath = null;\r
+ mPathDirection = Direction.None;\r
+ break;\r
+ }\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