summaryrefslogtreecommitdiff
path: root/Assembly_CSharp/Waypoint.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assembly_CSharp/Waypoint.cs')
-rw-r--r--Assembly_CSharp/Waypoint.cs62
1 files changed, 62 insertions, 0 deletions
diff --git a/Assembly_CSharp/Waypoint.cs b/Assembly_CSharp/Waypoint.cs
new file mode 100644
index 0000000..b250079
--- /dev/null
+++ b/Assembly_CSharp/Waypoint.cs
@@ -0,0 +1,62 @@
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Waypoint : MonoBehaviour
+{
+ [SerializeField]
+ private Waypoint next;
+
+ [SerializeField]
+ private List<Waypoint> previous = new List<Waypoint>();
+
+ public float distanceFromEnd;
+
+ public bool trueDistance;
+
+ private void Start()
+ {
+ UpdateDistance();
+ }
+
+ public Waypoint GetNextWaypoint()
+ {
+ if (next != null)
+ {
+ return next;
+ }
+ return this;
+ }
+
+ public void SetNextWaypoint(Waypoint newNext)
+ {
+ next = newNext;
+ }
+
+ public void AddPreviousWaypoint(Waypoint previousWaypoint)
+ {
+ previous.Add(previousWaypoint);
+ }
+
+ public Waypoint[] GetPreviousWaypoints()
+ {
+ return previous.ToArray();
+ }
+
+ public void UpdateDistance()
+ {
+ if (next == null)
+ {
+ trueDistance = true;
+ return;
+ }
+ if (!next.trueDistance)
+ {
+ next.UpdateDistance();
+ }
+ if (!trueDistance)
+ {
+ distanceFromEnd = next.distanceFromEnd + Vector3.Magnitude(next.transform.position - base.transform.position);
+ trueDistance = true;
+ }
+ }
+}