Decompiled source of VoidLand v1.3.0

Mods/VoidLand.dll

Decompiled 3 weeks 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 Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRUMBLE.Audio;
using Il2CppRUMBLE.Interactions.InteractionBase;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.MoveSystem;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using MelonLoader;
using RumbleModUI;
using RumbleModdingAPI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using VoidLand;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(main), "VoidLand", "1.3.0", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTitle("VoidLand")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VoidLand")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d91a37e8-b5c7-4a64-9943-76b8a8cd3adc")]
[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")]
namespace VoidLand;

public class main : MelonMod
{
	[CompilerGenerated]
	private sealed class <ReLoadVoidLand>d__26 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public main <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.GetComponent<PlayerResetSystem>().ResetPlayerController();
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				Object.DestroyImmediate((Object)(object)<>4__this.cube);
				<>2__current = 0;
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<>4__this.LoadVoidLand();
				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 <ToVoidLandPressed>d__25 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public main <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.GetComponent<PlayerResetSystem>().ResetPlayerController();
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				RenderSettings.fog = false;
				<>4__this.voidLandActive = true;
				<>4__this.DeloadGym();
				<>4__this.LoadVoidLand();
				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 string currentScene = "Loader";

	private bool gymInit = false;

	private bool voidLandActive = false;

	private bool respawning = false;

	private GameObject buttonToSwaptoVoidLand;

	private GameObject voidLandTextPanel;

	private GameObject voidLandParent;

	private GameObject cube;

	public static List<string> dontDisableGameObject = new List<string>();

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

	private GameObject plane;

	private UI UI = UI.instance;

	private Mod VoidLand = new Mod();

	private int size;

	private float r;

	private float g;

	private float b;

	private bool returnToGym;

	private Shader unlit;

	public override void OnLateInitializeMelon()
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Expected O, but got Unknown
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Expected O, but got Unknown
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Expected O, but got Unknown
		unlit = Shader.Find("Universal Render Pipeline/Unlit");
		VoidLand.ModName = "VoidLand";
		VoidLand.ModVersion = "1.3.0";
		VoidLand.SetFolder("VoidLand");
		VoidLand.AddToList("Map Size", 125, "Determins the size of the VoidLand", new Tags());
		VoidLand.AddToList("Return to Gym", false, 0, "Loads from VoidLand to Gym", new Tags
		{
			DoNotSave = true
		});
		VoidLand.AddToList("Color R", 0, "R Value out of 255", new Tags());
		VoidLand.AddToList("Color G", 0, "G Value out of 255", new Tags());
		VoidLand.AddToList("Color B", 0, "B Value out of 255", new Tags());
		VoidLand.GetFromFile();
		VoidLand.ModSaved += Save;
		size = (int)VoidLand.Settings[0].SavedValue;
		if (size < 1)
		{
			size = 1;
			VoidLand.Settings[0].SavedValue = 1;
			VoidLand.Settings[0].Value = 1;
		}
		returnToGym = (bool)VoidLand.Settings[1].SavedValue;
		r = (float)(int)VoidLand.Settings[2].SavedValue / 255f;
		g = (float)(int)VoidLand.Settings[3].SavedValue / 255f;
		b = (float)(int)VoidLand.Settings[4].SavedValue / 255f;
		UI.instance.UI_Initialized += UIInit;
		Calls.onMapInitialized += SceneInit;
		dontDisableGameObject.Add("UniverseLibBehaviour");
		dontDisableGameObject.Add("ExplorerBehaviour");
		dontDisableGameObject.Add("SteamManager");
		dontDisableGameObject.Add("LanguageManager");
		dontDisableGameObject.Add("PhotonMono");
		dontDisableGameObject.Add("Game Instance");
		dontDisableGameObject.Add("Timer Updater");
		dontDisableGameObject.Add("PlayFabHttp");
		dontDisableGameObject.Add("LIV");
		dontDisableGameObject.Add("UniverseLibCanvas");
		dontDisableGameObject.Add("UE_Freecam");
		dontDisableGameObject.Add("--------------SCENE--------------");
		dontDisableGameObject.Add("!ftraceLightmaps");
		dontDisableGameObject.Add("VoiceLogger");
		dontDisableGameObject.Add("Player Controller(Clone)");
		dontDisableGameObject.Add("Health");
		dontDisableGameObject.Add("New Game Object");
		dontDisableGameObject.Add("LCK Tablet");
	}

	private void Save()
	{
		size = (int)VoidLand.Settings[0].SavedValue;
		if (size < 1)
		{
			size = 1;
			VoidLand.Settings[0].SavedValue = 1;
			VoidLand.Settings[0].Value = 1;
		}
		r = (float)(int)VoidLand.Settings[2].SavedValue / 255f;
		g = (float)(int)VoidLand.Settings[3].SavedValue / 255f;
		b = (float)(int)VoidLand.Settings[4].SavedValue / 255f;
		if (voidLandActive && (bool)VoidLand.Settings[1].SavedValue)
		{
			VoidLand.Settings[1].Value = false;
			ReLoadGym();
		}
		else if (voidLandActive)
		{
			MelonCoroutines.Start(ReLoadVoidLand());
		}
	}

	private void UIInit()
	{
		UI.AddMod(VoidLand);
	}

	public override void OnFixedUpdate()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		if (voidLandActive)
		{
			float y = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(2).GetChild(3).position.y;
			if (!respawning && y <= -10f)
			{
				respawning = true;
				((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.GetComponent<PlayerResetSystem>().ResetPlayerController();
			}
			else if (respawning && y >= -10f)
			{
				respawning = false;
			}
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		if (voidLandActive)
		{
			ReactivateDDOLObjects();
			voidLandActive = false;
		}
		gymInit = false;
	}

	private void SceneInit()
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Expected O, but got Unknown
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		if (currentScene == "Gym" && !gymInit)
		{
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = "BackPanel";
			val.GetComponent<Renderer>().material.shader = unlit;
			val.GetComponent<Renderer>().material.color = new Color(0f, 1f, 0.814f);
			val.transform.parent = MatchConsole.GetGameObject().transform;
			val.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
			val.transform.localPosition = new Vector3(-0.4915f, 1.2083f, -0.0151f);
			val.transform.localScale = new Vector3(3f, 2.41f, 0.02f);
			voidLandParent = new GameObject();
			((Object)voidLandParent).name = "VoidLand";
			voidLandTextPanel = Object.Instantiate<GameObject>(((Component)MatchmakingSettings.GetGameObject().transform.GetChild(1)).gameObject);
			((Object)voidLandTextPanel).name = "VoidLand Plate";
			voidLandTextPanel.transform.parent = voidLandParent.transform;
			voidLandTextPanel.transform.position = new Vector3(7.45f, 1.9f, 10.12f);
			voidLandTextPanel.transform.rotation = Quaternion.Euler(90f, 122.8f, 0f);
			voidLandTextPanel.transform.localScale = new Vector3(0.29f, 0.3036f, 0.362f);
			GameObject val2 = Object.Instantiate<GameObject>(((Component)MatchmakingSettings.GetGameObject().transform.GetChild(3)).gameObject);
			val2.transform.parent = voidLandTextPanel.transform;
			((Object)val2).name = "Text";
			val2.transform.localPosition = new Vector3(0.04f, 0.74f, 0f);
			val2.transform.localRotation = Quaternion.Euler(0f, 270f, 90f);
			val2.transform.localScale = new Vector3(6.0414f, 3.7636f, 6.462f);
			TextMeshPro component = val2.GetComponent<TextMeshPro>();
			((TMP_Text)component).text = "VoidLand";
			buttonToSwaptoVoidLand = Create.NewButton();
			((Object)buttonToSwaptoVoidLand).name = "VoidLandButton";
			buttonToSwaptoVoidLand.transform.parent = voidLandParent.transform;
			buttonToSwaptoVoidLand.transform.position = new Vector3(7.67f, 1.7f, 10f);
			buttonToSwaptoVoidLand.transform.localRotation = Quaternion.Euler(0f, 302.5f, 90f);
			((Component)buttonToSwaptoVoidLand.transform.GetChild(0)).gameObject.GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
			{
				MelonCoroutines.Start(ToVoidLandPressed());
			}));
			voidLandParent.transform.position = new Vector3(0.72f, 0f, -0.53f);
			gymInit = true;
		}
	}

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

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

	private void TurnOffAllExtraRootObjects()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject();
		Object.DontDestroyOnLoad((Object)(object)val);
		Scene scene = val.scene;
		Object.DestroyImmediate((Object)(object)val);
		GameObject[] array = Il2CppArrayBase<GameObject>.op_Implicit((Il2CppArrayBase<GameObject>)(object)((Scene)(ref scene)).GetRootGameObjects());
		Scene activeScene = SceneManager.GetActiveScene();
		GameObject[] array2 = Il2CppArrayBase<GameObject>.op_Implicit((Il2CppArrayBase<GameObject>)(object)((Scene)(ref activeScene)).GetRootGameObjects());
		GameObject[] array3 = array;
		foreach (GameObject val2 in array3)
		{
			if (val2.activeSelf && !dontDisableGameObject.Contains(((Object)val2).name))
			{
				val2.SetActive(false);
				DisabledDDOLGameObjects.Add(val2);
			}
		}
		GameObject[] array4 = array2;
		foreach (GameObject val3 in array4)
		{
			if (val3.activeSelf && !dontDisableGameObject.Contains(((Object)val3).name))
			{
				val3.SetActive(false);
			}
			else if (((Object)val3).name == "--------------SCENE--------------")
			{
				((Component)val3.transform.GetChild(0)).gameObject.SetActive(false);
				((Component)val3.transform.GetChild(1)).gameObject.SetActive(false);
				((Component)val3.transform.GetChild(2)).gameObject.SetActive(false);
				((Component)val3.transform.GetChild(3)).gameObject.SetActive(false);
				((Component)val3.transform.GetChild(4).GetChild(0)).gameObject.SetActive(false);
				((Component)val3.transform.GetChild(4).GetChild(3)).gameObject.SetActive(false);
			}
		}
	}

	private void DeloadGym()
	{
		ResetStructures();
		Object.Destroy((Object)(object)SceneBoundaryPlayerGYM.GetGameObject());
		TurnOffAllExtraRootObjects();
	}

	private void ResetStructures()
	{
		Singleton<PoolManager>.instance.GetPool("Disc").Reset(true);
		Singleton<PoolManager>.instance.GetPool("Ball").Reset(true);
		Singleton<PoolManager>.instance.GetPool("Pillar").Reset(true);
		Singleton<PoolManager>.instance.GetPool("RockCube").Reset(true);
		Singleton<PoolManager>.instance.GetPool("Wall").Reset(true);
		Singleton<PoolManager>.instance.GetPool("BoulderBall").Reset(true);
		Singleton<PoolManager>.instance.GetPool("SmallRock").Reset(true);
		Singleton<PoolManager>.instance.GetPool("LargeRock").Reset(true);
	}

	private void ReLoadGym()
	{
		Singleton<SceneManager>.instance.LoadSceneAsync(1, false, false, 2f, (LoadSceneMode)0, (AudioCall)null);
		RenderSettings.fog = true;
	}

	private void ReactivateDDOLObjects()
	{
		foreach (GameObject disabledDDOLGameObject in DisabledDDOLGameObjects)
		{
			disabledDDOLGameObject.SetActive(true);
		}
		DisabledDDOLGameObjects.Clear();
	}

	private void LoadVoidLand()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0420: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: Unknown result type (might be due to invalid IL or missing references)
		cube = new GameObject();
		((Object)cube).name = "Void Box";
		float num = size;
		plane = GameObject.CreatePrimitive((PrimitiveType)3);
		((Object)plane).name = "VoidFloor";
		plane.transform.parent = cube.transform;
		plane.transform.localScale = new Vector3(num, 0.01f, num);
		plane.transform.position = new Vector3(0f, 0f, 0f);
		plane.layer = 9;
		MeshCollider collider = plane.AddComponent<MeshCollider>();
		GroundCollider val = plane.AddComponent<GroundCollider>();
		Object.Destroy((Object)(object)plane.GetComponent<BoxCollider>());
		val.isMainGroundCollider = true;
		val.collider = (Collider)(object)collider;
		plane.GetComponent<Renderer>().material.shader = unlit;
		plane.GetComponent<Renderer>().material.color = new Color(r, g, b);
		GameObject val2 = Object.Instantiate<GameObject>(plane);
		val2.transform.parent = cube.transform;
		val2.transform.position = new Vector3(num / 2f, num / 2f, 0f);
		val2.transform.rotation = Quaternion.Euler(0f, 0f, 90f);
		val2.GetComponent<Renderer>().material.shader = unlit;
		val2.GetComponent<Renderer>().material.color = new Color(r, g, b);
		GameObject val3 = Object.Instantiate<GameObject>(val2);
		val3.transform.parent = cube.transform;
		val3.transform.position = new Vector3((0f - num) / 2f, num / 2f, 0f);
		val3.transform.rotation = Quaternion.Euler(0f, 0f, 90f);
		val3.GetComponent<Renderer>().material.shader = unlit;
		val3.GetComponent<Renderer>().material.color = new Color(r, g, b);
		GameObject val4 = Object.Instantiate<GameObject>(val2);
		val4.transform.parent = cube.transform;
		val4.transform.position = new Vector3(0f, num / 2f, num / 2f);
		val4.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
		val4.GetComponent<Renderer>().material.shader = unlit;
		val4.GetComponent<Renderer>().material.color = new Color(r, g, b);
		GameObject val5 = Object.Instantiate<GameObject>(val2);
		val5.transform.parent = cube.transform;
		val5.transform.position = new Vector3(0f, num / 2f, (0f - num) / 2f);
		val5.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
		val5.GetComponent<Renderer>().material.shader = unlit;
		val5.GetComponent<Renderer>().material.color = new Color(r, g, b);
		GameObject val6 = Object.Instantiate<GameObject>(val2);
		val6.transform.parent = cube.transform;
		val6.transform.position = new Vector3(0f, num, 0f);
		val6.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
		val6.GetComponent<Renderer>().material.shader = unlit;
		val6.GetComponent<Renderer>().material.color = new Color(r, g, b);
	}
}