summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/SlideBar.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/SlideBar.cs')
-rw-r--r--Client/Assembly-CSharp/SlideBar.cs78
1 files changed, 78 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/SlideBar.cs b/Client/Assembly-CSharp/SlideBar.cs
new file mode 100644
index 0000000..da36f58
--- /dev/null
+++ b/Client/Assembly-CSharp/SlideBar.cs
@@ -0,0 +1,78 @@
+using System;
+using UnityEngine;
+using UnityEngine.Events;
+
+public class SlideBar : MonoBehaviour
+{
+ public TextRenderer Title;
+
+ public SpriteRenderer Bar;
+
+ public Collider2D HitBox;
+
+ public SpriteRenderer Dot;
+
+ public FloatRange Range;
+
+ public bool Vertical;
+
+ public float Value;
+
+ public UnityEvent OnValueChange;
+
+ public void OnEnable()
+ {
+ if (this.Title)
+ {
+ this.Title.Color = Color.white;
+ }
+ this.Bar.color = Color.white;
+ this.Dot.color = Color.white;
+ }
+
+ public void OnDisable()
+ {
+ if (this.Title)
+ {
+ this.Title.Color = Color.gray;
+ }
+ this.Bar.color = Color.gray;
+ this.Dot.color = Color.gray;
+ }
+
+ public void Update()
+ {
+ Vector3 localPosition = this.Dot.transform.localPosition;
+ switch (DestroyableSingleton<PassiveButtonManager>.Instance.Controller.CheckDrag(this.HitBox, false))
+ {
+ case DragState.Dragging:
+ {
+ Vector2 vector = DestroyableSingleton<PassiveButtonManager>.Instance.Controller.DragPosition - this.Bar.transform.position;
+ if (this.Vertical)
+ {
+ localPosition.y = this.Range.Clamp(vector.y);
+ this.Value = this.Range.ReverseLerp(localPosition.y);
+ }
+ else
+ {
+ localPosition.x = this.Range.Clamp(vector.x);
+ this.Value = this.Range.ReverseLerp(localPosition.x);
+ }
+ this.OnValueChange.Invoke();
+ break;
+ }
+ case DragState.Released:
+ this.OnValueChange.Invoke();
+ break;
+ }
+ if (this.Vertical)
+ {
+ localPosition.y = this.Range.Lerp(this.Value);
+ }
+ else
+ {
+ localPosition.x = this.Range.Lerp(this.Value);
+ }
+ this.Dot.transform.localPosition = localPosition;
+ }
+}