Decompiled source of Rising Tide v1.5.0

ClassLibrary2.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ClassLibrary2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary2")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c4f1db90-43ed-4e88-9794-ff9b0f4562ad")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.user.goi.risingtide", "Rising Tide", "8.2.0")]
public class RisingTide : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <ForceFreezeLoop>d__15 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public RisingTide <>4__this;

		private Rigidbody2D[] <>s__1;

		private int <>s__2;

		private Rigidbody2D <rb>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ForceFreezeLoop>d__15(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>s__1 = null;
			<rb>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (!<>4__this.isDifficultyChosen)
			{
				Time.timeScale = 0f;
				AudioListener.pause = true;
				if ((Object)(object)<>4__this.playerTransform != (Object)null)
				{
					<>s__1 = ((Component)<>4__this.playerTransform).GetComponentsInChildren<Rigidbody2D>();
					for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++)
					{
						<rb>5__3 = <>s__1[<>s__2];
						<rb>5__3.simulated = false;
						<rb>5__3.velocity = Vector2.zero;
						<rb>5__3 = null;
					}
					<>s__1 = null;
				}
				<>2__current = (object)new WaitForEndOfFrame();
				<>1__state = 1;
				return true;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <InitializeTideSystem>d__16 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public RisingTide <>4__this;

		private GameObject <pObj>5__1;

		private string[] <targets>5__2;

		private string[] <>s__3;

		private int <>s__4;

		private string <t>5__5;

		private GameObject <go>5__6;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <InitializeTideSystem>d__16(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<pObj>5__1 = null;
			<targets>5__2 = null;
			<>s__3 = null;
			<t>5__5 = null;
			<go>5__6 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<pObj>5__1 = null;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)<pObj>5__1 == (Object)null)
			{
				<pObj>5__1 = GameObject.Find("Player") ?? GameObject.FindGameObjectWithTag("Player");
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			<>4__this.playerTransform = <pObj>5__1.transform;
			<>4__this.waterObject = GameObject.Find("Water");
			if ((Object)(object)<>4__this.waterObject != (Object)null)
			{
				<>4__this.waterStartPos = <>4__this.waterObject.transform.position;
			}
			<targets>5__2 = new string[5] { "Sensor", "Splashes", "WaterSplashes", "waterSplashes", "FallTrigger" };
			<>s__3 = <targets>5__2;
			for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
			{
				<t>5__5 = <>s__3[<>s__4];
				<go>5__6 = GameObject.Find(<t>5__5);
				if ((Object)(object)<go>5__6 != (Object)null)
				{
					<>4__this.deathTriggers.Add(<go>5__6);
				}
				<go>5__6 = null;
				<t>5__5 = null;
			}
			<>s__3 = null;
			<>4__this.initialized = true;
			if (Time.unscaledTime - <>4__this.lastWaterHitTime <= 5f)
			{
				<>4__this.isDifficultyChosen = true;
				<>4__this.isWaitingToStart = false;
			}
			else
			{
				<>4__this.isDifficultyChosen = false;
				((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.ForceFreezeLoop());
				<>4__this.CreateDifficultyMenu();
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <SafeTeleportReset>d__22 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public RisingTide <>4__this;

		private List<GameObject>.Enumerator <>s__1;

		private GameObject <dt>5__2;

		private Rigidbody2D[] <>s__3;

		private int <>s__4;

		private Rigidbody2D <body>5__5;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <SafeTeleportReset>d__22(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>s__1 = default(List<GameObject>.Enumerator);
			<dt>5__2 = null;
			<>s__3 = null;
			<body>5__5 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.isRestarting = true;
				if ((Object)(object)<>4__this.waterObject != (Object)null)
				{
					<>4__this.waterObject.transform.position = <>4__this.waterStartPos;
				}
				<>s__1 = <>4__this.deathTriggers.GetEnumerator();
				try
				{
					while (<>s__1.MoveNext())
					{
						<dt>5__2 = <>s__1.Current;
						if ((Object)(object)<dt>5__2 != (Object)null)
						{
							<dt>5__2.transform.position = <>4__this.waterStartPos;
						}
						<dt>5__2 = null;
					}
				}
				finally
				{
					((IDisposable)<>s__1).Dispose();
				}
				<>s__1 = default(List<GameObject>.Enumerator);
				<>4__this.playerTransform.position = <>4__this.resetPos;
				<>s__3 = ((Component)<>4__this.playerTransform).GetComponentsInChildren<Rigidbody2D>();
				for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
				{
					<body>5__5 = <>s__3[<>s__4];
					<body>5__5.velocity = Vector2.zero;
					((Component)<body>5__5).transform.position = <>4__this.resetPos;
					<body>5__5 = null;
				}
				<>s__3 = null;
				((Component)<>4__this.playerTransform).gameObject.SendMessage("Save", (SendMessageOptions)1);
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this.isRestarting = false;
				if (Time.unscaledTime - <>4__this.lastWaterHitTime > 5f)
				{
					<>4__this.isDifficultyChosen = false;
					((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.ForceFreezeLoop());
					<>4__this.CreateDifficultyMenu();
				}
				else
				{
					<>4__this.isDifficultyChosen = true;
					<>4__this.isWaitingToStart = false;
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <StartTideSequence>d__20 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public float delay;

		public RisingTide <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <StartTideSequence>d__20(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.isWaitingToStart = true;
				if (delay > 0f)
				{
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				}
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			<>4__this.isWaitingToStart = false;
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private float currentBaseSpeed = 0.1f;

	private float savedDelay = 3.5f;

	private float lastWaterHitTime = -100f;

	private GameObject waterObject;

	private List<GameObject> deathTriggers = new List<GameObject>();

	private Transform playerTransform;

	private Vector3 waterStartPos;

	private Vector3 resetPos = new Vector3(-43.7f, -1.6f, 0f);

	private bool initialized = false;

	private bool isRestarting = false;

	private bool menuOpen = false;

	private bool isWaitingToStart = false;

	private bool isDifficultyChosen = false;

	private void Awake()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (((Scene)(ref scene)).name == "Mian")
		{
			initialized = false;
			isRestarting = false;
			isWaitingToStart = false;
			isDifficultyChosen = false;
			menuOpen = false;
			deathTriggers.Clear();
			((MonoBehaviour)this).StartCoroutine(InitializeTideSystem());
		}
	}

	[IteratorStateMachine(typeof(<ForceFreezeLoop>d__15))]
	private IEnumerator ForceFreezeLoop()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ForceFreezeLoop>d__15(0)
		{
			<>4__this = this
		};
	}

	[IteratorStateMachine(typeof(<InitializeTideSystem>d__16))]
	private IEnumerator InitializeTideSystem()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <InitializeTideSystem>d__16(0)
		{
			<>4__this = this
		};
	}

	private void CreateDifficultyMenu()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Expected O, but got Unknown
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Expected O, but got Unknown
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Expected O, but got Unknown
		if (!menuOpen)
		{
			menuOpen = true;
			GameObject val = GameObject.Find("Canvas");
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = new GameObject("MenuBlocker", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val2.transform.SetParent(val.transform, false);
				val2.GetComponent<RectTransform>().sizeDelta = new Vector2((float)(Screen.width * 3), (float)(Screen.height * 3));
				((Graphic)val2.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.85f);
				GameObject val3 = new GameObject("DifficultyPanel", new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(VerticalLayoutGroup)
				});
				val3.transform.SetParent(val2.transform, false);
				RectTransform component = val3.GetComponent<RectTransform>();
				component.sizeDelta = new Vector2(400f, 500f);
				((Graphic)val3.GetComponent<Image>()).color = new Color(0.1f, 0.1f, 0.1f, 1f);
				VerticalLayoutGroup component2 = val3.GetComponent<VerticalLayoutGroup>();
				((LayoutGroup)component2).childAlignment = (TextAnchor)1;
				((HorizontalOrVerticalLayoutGroup)component2).spacing = 15f;
				((LayoutGroup)component2).padding = new RectOffset(20, 20, 40, 20);
				GameObject val4 = new GameObject("Title", new Type[2]
				{
					typeof(RectTransform),
					typeof(TextMeshProUGUI)
				});
				val4.transform.SetParent(val3.transform, false);
				TextMeshProUGUI component3 = val4.GetComponent<TextMeshProUGUI>();
				((TMP_Text)component3).text = "SELECT DIFFICULTY";
				((TMP_Text)component3).fontSize = 28f;
				((TMP_Text)component3).alignment = (TextAlignmentOptions)514;
				CreateMenuButton(val3.transform, "Beginner", 0.025f, 3.5f, val2);
				CreateMenuButton(val3.transform, "Intermediate", 0.13f, 3.5f, val2);
				CreateMenuButton(val3.transform, "Fast", 0.24f, 3.5f, val2);
				CreateMenuButton(val3.transform, "SpeedRunner", 0.38f, 3.5f, val2);
				CreateMenuButton(val3.transform, "WR Guys", 0.65f, 4f, val2);
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}
	}

	private void CreateMenuButton(Transform parent, string label, float speed, float delay, GameObject blocker)
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Expected O, but got Unknown
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Expected O, but got Unknown
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(label, new Type[3]
		{
			typeof(RectTransform),
			typeof(Button),
			typeof(Image)
		});
		val.transform.SetParent(parent, false);
		val.GetComponent<RectTransform>().sizeDelta = new Vector2(300f, 50f);
		((Graphic)val.GetComponent<Image>()).color = new Color(0.2f, 0.2f, 0.2f, 1f);
		Button component = val.GetComponent<Button>();
		((UnityEvent)component.onClick).AddListener((UnityAction)delegate
		{
			SetDifficulty(speed, delay, blocker);
		});
		GameObject val2 = new GameObject("Text", new Type[2]
		{
			typeof(RectTransform),
			typeof(TextMeshProUGUI)
		});
		val2.transform.SetParent(val.transform, false);
		TextMeshProUGUI component2 = val2.GetComponent<TextMeshProUGUI>();
		((TMP_Text)component2).text = label;
		((Graphic)component2).color = Color.white;
		((TMP_Text)component2).fontSize = 20f;
		((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
		val2.GetComponent<RectTransform>().sizeDelta = new Vector2(300f, 50f);
	}

	private void SetDifficulty(float speed, float delay, GameObject blocker)
	{
		currentBaseSpeed = speed;
		savedDelay = delay;
		isDifficultyChosen = true;
		Object.Destroy((Object)(object)blocker);
		menuOpen = false;
		Time.timeScale = 1f;
		AudioListener.pause = false;
		if ((Object)(object)playerTransform != (Object)null)
		{
			Rigidbody2D[] componentsInChildren = ((Component)playerTransform).GetComponentsInChildren<Rigidbody2D>();
			foreach (Rigidbody2D val in componentsInChildren)
			{
				val.simulated = true;
			}
		}
		Cursor.visible = false;
		Cursor.lockState = (CursorLockMode)1;
		((MonoBehaviour)this).StartCoroutine(StartTideSequence(delay));
	}

	[IteratorStateMachine(typeof(<StartTideSequence>d__20))]
	private IEnumerator StartTideSequence(float delay)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <StartTideSequence>d__20(0)
		{
			<>4__this = this,
			delay = delay
		};
	}

	private void Update()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)playerTransform == (Object)null || (Object)(object)waterObject == (Object)null || !isDifficultyChosen || menuOpen || !initialized || isRestarting || isWaitingToStart)
		{
			return;
		}
		float num = playerTransform.position.y - waterObject.transform.position.y;
		float num2 = currentBaseSpeed * (1f + Mathf.Max(0f, num) / 10f);
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(0f, num2 * Time.deltaTime, 0f);
		Transform transform = waterObject.transform;
		transform.position += val;
		foreach (GameObject deathTrigger in deathTriggers)
		{
			if ((Object)(object)deathTrigger != (Object)null)
			{
				Transform transform2 = deathTrigger.transform;
				transform2.position += val;
			}
		}
		if (playerTransform.position.y < waterObject.transform.position.y + 8f)
		{
			lastWaterHitTime = Time.unscaledTime;
			((MonoBehaviour)this).StartCoroutine(SafeTeleportReset());
		}
	}

	[IteratorStateMachine(typeof(<SafeTeleportReset>d__22))]
	private IEnumerator SafeTeleportReset()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <SafeTeleportReset>d__22(0)
		{
			<>4__this = this
		};
	}
}