From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/Vector2Range.cs | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Client/Assembly-CSharp/Vector2Range.cs (limited to 'Client/Assembly-CSharp/Vector2Range.cs') diff --git a/Client/Assembly-CSharp/Vector2Range.cs b/Client/Assembly-CSharp/Vector2Range.cs new file mode 100644 index 0000000..af83d56 --- /dev/null +++ b/Client/Assembly-CSharp/Vector2Range.cs @@ -0,0 +1,55 @@ +using System; +using UnityEngine; + +[Serializable] +public struct Vector2Range +{ + public float Width + { + get + { + return this.max.x - this.min.x; + } + } + + public float Height + { + get + { + return this.max.y - this.min.y; + } + } + + public Vector2 min; + + public Vector2 max; + + public Vector2Range(Vector2 min, Vector2 max) + { + this.min = min; + this.max = max; + } + + public void LerpUnclamped(ref Vector3 output, float t, float z) + { + output.Set(Mathf.LerpUnclamped(this.min.x, this.max.x, t), Mathf.LerpUnclamped(this.min.y, this.max.y, t), z); + } + + public void Lerp(ref Vector3 output, float t, float z) + { + output.Set(Mathf.Lerp(this.min.x, this.max.x, t), Mathf.Lerp(this.min.y, this.max.y, t), z); + } + + public Vector2 Next() + { + return new Vector2(UnityEngine.Random.Range(this.min.x, this.max.x), UnityEngine.Random.Range(this.min.y, this.max.y)); + } + + public static Vector2 NextEdge() + { + float f = 6.2831855f * UnityEngine.Random.value; + float x = Mathf.Cos(f); + float y = Mathf.Sin(f); + return new Vector2(x, y); + } +} -- cgit v1.1-26-g67d0