Decompiled source of VoidLand v1.0.0

Mods/VoidLand.dll

Decompiled 2 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.0.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
{
	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;

	private 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;

	public override void OnLateInitializeMelon()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Expected O, but got Unknown
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Expected O, but got Unknown
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		VoidLand.ModName = "VoidLand";
		VoidLand.ModVersion = "1.0.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("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");
	}

	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_003b: 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(13).GetChild(0)
				.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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Expected O, but got Unknown
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: 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_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: 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 = Shader.Find("Universal Render Pipeline/Lit");
			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)RankRelaxControls.GetGameObject().transform.GetChild(17)).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)RankRelaxControls.GetGameObject().transform.GetChild(15).GetChild(6)).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;
		}
	}

	private IEnumerator ToVoidLandPressed()
	{
		((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.GetComponent<PlayerResetSystem>().ResetPlayerController();
		yield return (object)new WaitForSeconds(1f);
		RenderSettings.fog = false;
		voidLandActive = true;
		DeloadGym();
		LoadVoidLand();
	}

	private IEnumerator ReLoadVoidLand()
	{
		((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.GetComponent<PlayerResetSystem>().ResetPlayerController();
		yield return (object)new WaitForSeconds(1f);
		Object.DestroyImmediate((Object)(object)cube);
		yield return 0;
		LoadVoidLand();
	}

	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.active && !dontDisableGameObject.Contains(((Object)val2).name))
			{
				val2.SetActive(false);
				DisabledDDOLGameObjects.Add(val2);
			}
		}
		GameObject[] array4 = array2;
		foreach (GameObject val3 in array4)
		{
			if (val3.active && !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)SceneBoundaryPlayer.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_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: 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 = Shader.Find("Universal Render Pipeline/Lit");
		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.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.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.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.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.color = new Color(r, g, b);
	}
}