public static Matrix4x4 GetTransform(this IAIPath path, float distance) { var length = GetLength(path); var progress = distance / length; if (path.Reverse) { progress = 1 - progress; } distance = path.PathOffsetStart + progress * length; var maxDistance = path.LoftPath?.Length ?? 1; var t = progress; var lerp = Mathf.Lerp(path.SideOffsetStart, path.SideOffsetEnd, t * t * t * (t * (6f * t - 15f) + 10f)); var m = Matrix4x4.Translate(new Vector3(lerp, 0, 0)); var result = path.LoftPath.GetTransform(distance) * m; if (path.Reverse) { return(result * rotate); } return(result); }
public static float GetPathOffset(this IAIPath path, bool end) { if (path.Reverse ^ end) { return(path.LoftPath?.Length - path.PathOffsetEnd ?? 0); } else { return(path.PathOffsetStart); } }
public static float GetSideOffset(this IAIPath path, bool end) { if (path.Reverse ^ end) { return(path.SideOffsetEnd); } else { return(path.SideOffsetStart); } }
public static float GetDistanceFromLoftPath(this IAIPath path, float loftpathDistance) { var nS = path.GetStartPathOffset(); var nE = path.GetEndPathOffset(); //n = (nE - nS) * t + nS; //(nE - nS) * t = n - nS var t = (loftpathDistance - nS) / (nE - nS); return(t * path.GetLength()); }
public void Play() { _previousFrameDistance = 100F; _isPlaying = true; _startedPlaying = false; if (TargetActivated != null) { TargetActivated.Invoke(this , new TargetActivatedEventArgs(this.transform, this.AffectCharacterRotation)); } // Get the active pc _pathingCharacter = GameController.PartyManager.ActivePC.GetComponent<IAIPath>(); }
public static Matrix4x4 GetEndTransform(this IAIPath path) => path.GetTransform(path.GetLength());
public static Matrix4x4 GetStartTransform(this IAIPath path) => path.GetTransform(0);
public static float GetOffsetPercentual(this IAIPath path, float n) { return(Mathf.Lerp(path.GetStartPathOffset(), path.GetEndPathOffset(), n)); }
public static float GetLength(this IAIPath path) => path.LoftPath?.Length - path.PathOffsetEnd - path.PathOffsetStart ?? 0;
public static float GetEndSideOffset(this IAIPath path) => GetSideOffset(path, end: true);
public static float GetStartSideOffset(this IAIPath path) => GetSideOffset(path, end: false);
public PathDescription(IAIPath Path, float Start, float End) : this() { this.Path = Path; this.Start = Start; this.End = End; }