Pathfinding.RichAI.TraverseSpecial C# (CSharp) Method

TraverseSpecial() private method

private TraverseSpecial ( RichSpecial rs ) : IEnumerator
rs RichSpecial
return IEnumerator
		IEnumerator TraverseSpecial (RichSpecial rs) {
			traversingSpecialPath = true;
			velocity = Vector3.zero;
			
			AnimationLink al = rs.nodeLink as AnimationLink;
			if (al == null) {
				Debug.LogError ("Unhandled RichSpecial");
				yield break;
			}
			
			//Rotate character to face the correct direction
			while (!RotateTowards(rs.first.forward)) yield return null;
			
			//Reposition
			tr.parent.position = tr.position;
			
			tr.parent.rotation = tr.rotation;
			tr.localPosition = Vector3.zero;
			tr.localRotation = Quaternion.identity;
			
			//Set up animation speeds
			if (rs.reverse && al.reverseAnim) {
				anim[al.clip].speed = -al.animSpeed;
				anim[al.clip].normalizedTime = 1;
				anim.Play(al.clip);
				anim.Sample();
			} else {
				anim[al.clip].speed = al.animSpeed;
				anim.Rewind(al.clip);
				anim.Play(al.clip);
			}
			
			//Fix required for animations in reverse direction
			tr.parent.position -= tr.position-tr.parent.position;
			
			//Wait for the animation to finish
			yield return new WaitForSeconds(Mathf.Abs(anim[al.clip].length/al.animSpeed));
			
			traversingSpecialPath = false;
			NextPart ();
			
			//If a path completed during the time we traversed the special connection, we need to recalculate it
			if (delayUpdatePath) {
				delayUpdatePath = false;
				UpdatePath();
			}
		}
	}