summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/Effects.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/Effects.cs')
-rw-r--r--Client/Assembly-CSharp/Effects.cs248
1 files changed, 248 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/Effects.cs b/Client/Assembly-CSharp/Effects.cs
new file mode 100644
index 0000000..56b3efe
--- /dev/null
+++ b/Client/Assembly-CSharp/Effects.cs
@@ -0,0 +1,248 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public static class Effects
+{
+ private static HashSet<Transform> activeShakes = new HashSet<Transform>();
+
+ public static IEnumerator Wait(float duration)
+ {
+ for (float t = 0f; t < duration; t += Time.deltaTime)
+ {
+ yield return null;
+ }
+ yield break;
+ }
+
+ public static IEnumerator All(params IEnumerator[] items)
+ {
+ Stack<IEnumerator>[] enums = new Stack<IEnumerator>[items.Length];
+ for (int i = 0; i < items.Length; i++)
+ {
+ enums[i] = new Stack<IEnumerator>();
+ enums[i].Push(items[i]);
+ }
+ int num;
+ for (int cap = 0; cap < 100000; cap = num)
+ {
+ bool flag = false;
+ for (int j = 0; j < enums.Length; j++)
+ {
+ if (enums[j].Count > 0)
+ {
+ flag = true;
+ IEnumerator enumerator = enums[j].Peek();
+ if (enumerator.MoveNext())
+ {
+ if (enumerator.Current is IEnumerator)
+ {
+ enums[j].Push((IEnumerator)enumerator.Current);
+ }
+ }
+ else
+ {
+ enums[j].Pop();
+ }
+ }
+ }
+ if (!flag)
+ {
+ break;
+ }
+ yield return null;
+ num = cap + 1;
+ }
+ yield break;
+ }
+
+ internal static IEnumerator ScaleIn(Transform self, float source, float target, float duration)
+ {
+ if (!self)
+ {
+ yield break;
+ }
+ Vector3 localScale = default(Vector3);
+ for (float t = 0f; t < duration; t += Time.deltaTime)
+ {
+ localScale.x = (localScale.y = (localScale.z = Mathf.SmoothStep(source, target, t / duration)));
+ self.localScale = localScale;
+ yield return null;
+ }
+ localScale.z = target;
+ localScale.y = target;
+ localScale.x = target;
+ self.localScale = localScale;
+ yield break;
+ }
+
+ internal static IEnumerator CycleColors(SpriteRenderer self, Color source, Color target, float rate, float duration)
+ {
+ if (!self)
+ {
+ yield break;
+ }
+ self.enabled = true;
+ for (float t = 0f; t < duration; t += Time.deltaTime)
+ {
+ float t2 = Mathf.Sin(t * 3.1415927f / rate) / 2f + 0.5f;
+ self.color = Color.Lerp(source, target, t2);
+ yield return null;
+ }
+ self.color = source;
+ yield break;
+ }
+
+ internal static IEnumerator PulseColor(SpriteRenderer self, Color source, Color target, float duration = 0.5f)
+ {
+ if (!self)
+ {
+ yield break;
+ }
+ self.enabled = true;
+ for (float t = 0f; t < duration; t += Time.deltaTime)
+ {
+ self.color = Color.Lerp(target, source, t / duration);
+ yield return null;
+ }
+ self.color = source;
+ yield break;
+ }
+
+ internal static IEnumerator PulseColor(TextRenderer self, Color source, Color target, float duration = 0.5f)
+ {
+ if (!self)
+ {
+ yield break;
+ }
+ for (float t = 0f; t < duration; t += Time.deltaTime)
+ {
+ self.Color = Color.Lerp(target, source, t / duration);
+ yield return null;
+ }
+ self.Color = source;
+ yield break;
+ }
+
+ public static IEnumerator ColorFade(SpriteRenderer self, Color source, Color target, float duration)
+ {
+ if (!self)
+ {
+ yield break;
+ }
+ self.enabled = true;
+ for (float t = 0f; t < duration; t += Time.deltaTime)
+ {
+ self.color = Color.Lerp(source, target, t / duration);
+ yield return null;
+ }
+ self.color = target;
+ yield break;
+ }
+
+ public static IEnumerator Rotate2D(Transform target, float source, float dest, float duration = 0.75f)
+ {
+ Vector3 temp = target.localEulerAngles;
+ for (float time = 0f; time < duration; time += Time.deltaTime)
+ {
+ float t = time / duration;
+ temp.z = Mathf.SmoothStep(source, dest, t);
+ target.localEulerAngles = temp;
+ yield return null;
+ }
+ temp.z = dest;
+ target.localEulerAngles = temp;
+ yield break;
+ }
+
+ public static IEnumerator Slide2D(Transform target, Vector2 source, Vector2 dest, float duration = 0.75f)
+ {
+ Vector3 temp = default(Vector3);
+ temp.z = target.localPosition.z;
+ for (float time = 0f; time < duration; time += Time.deltaTime)
+ {
+ float t = time / duration;
+ temp.x = Mathf.SmoothStep(source.x, dest.x, t);
+ temp.y = Mathf.SmoothStep(source.y, dest.y, t);
+ target.localPosition = temp;
+ yield return null;
+ }
+ temp.x = dest.x;
+ temp.y = dest.y;
+ target.localPosition = temp;
+ yield break;
+ }
+
+ public static IEnumerator Bounce(Transform target, float duration = 0.3f, float height = 0.15f)
+ {
+ if (!target)
+ {
+ yield break;
+ }
+ Vector3 origin = target.localPosition;
+ Vector3 temp = origin;
+ for (float timer = 0f; timer < duration; timer += Time.deltaTime)
+ {
+ float num = timer / duration;
+ float num2 = 1f - num;
+ temp.y = origin.y + height * Mathf.Abs(Mathf.Sin(num * 3.1415927f * 3f)) * num2;
+ if (!target)
+ {
+ yield break;
+ }
+ target.localPosition = temp;
+ yield return null;
+ }
+ if (target)
+ {
+ target.transform.localPosition = origin;
+ }
+ yield break;
+ }
+
+ public static IEnumerator Shake(Transform target, float duration = 0.75f, float halfWidth = 0.25f)
+ {
+ if (Effects.activeShakes.Add(target))
+ {
+ Vector3 origin = target.localPosition;
+ for (float timer = 0f; timer < duration; timer += Time.deltaTime)
+ {
+ float num = timer / duration;
+ target.localPosition = origin + Vector3.right * (halfWidth * Mathf.Sin(num * 30f) * (1f - num));
+ yield return null;
+ }
+ target.transform.localPosition = origin;
+ Effects.activeShakes.Remove(target);
+ origin = default(Vector3);
+ }
+ yield break;
+ }
+
+ public static IEnumerator Bloop(float delay, Transform target, float duration = 0.5f)
+ {
+ for (float t = 0f; t < delay; t += Time.deltaTime)
+ {
+ yield return null;
+ }
+ Vector3 localScale = default(Vector3);
+ for (float t = 0f; t < duration; t += Time.deltaTime)
+ {
+ float z = Effects.ElasticOut(t, duration);
+ localScale.x = (localScale.y = (localScale.z = z));
+ target.localScale = localScale;
+ yield return null;
+ }
+ localScale.x = (localScale.y = (localScale.z = 1f));
+ target.localScale = localScale;
+ yield break;
+ }
+
+ private static float ElasticOut(float time, float duration)
+ {
+ time /= duration;
+ float num = time * time;
+ float num2 = num * time;
+ return 33f * num2 * num + -106f * num * num + 126f * num2 + -67f * num + 15f * time;
+ }
+}