Decompiled source of ExtraResetButtons v2.0.0

Mods/ExtraResetButtons.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using ExtraResetButtons;
using Il2CppRUMBLE.Environment;
using Il2CppRUMBLE.Interactions.InteractionBase;
using Il2CppRUMBLE.MoveSystem;
using Il2CppTMPro;
using MelonLoader;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("a simple RUMBLE mod, adds more reset session buttons")]
[assembly: AssemblyDescription("a simple RUMBLE mod, adds more reset session buttons")]
[assembly: AssemblyCompany(null)]
[assembly: AssemblyProduct("ExtraResetButtons")]
[assembly: AssemblyCopyright("Created by elmish")]
[assembly: AssemblyTrademark(null)]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: MelonInfo(typeof(global::ExtraResetButtons.ExtraResetButtons), "ExtraResetButtons", "1.0.1", "elmish", null)]
[assembly: MelonColor]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace ExtraResetButtons;

public static class BuildInfo
{
	public const string Name = "ExtraResetButtons";

	public const string Description = "a simple RUMBLE mod, adds more reset session buttons";

	public const string Author = "elmish";

	public const string Company = null;

	public const string Version = "1.0.1";

	public const string DownloadLink = null;
}
public class ExtraResetButtons : MelonMod
{
	public static GameObject dummy;

	public static GameObject gymDummy;

	public bool gymInitialized;

	public static GameObject parkDummy;

	public bool parkInitialized;

	private GameObject[] pools = (GameObject[])(object)new GameObject[8];

	private string[] poolPaths = new string[8];

	private GameObject ResetSessionButton;

	private GameObject newResetSessionButton;

	private GameObject buttonDisplay;

	private GameObject buttonDisplayText;

	private GameObject originalButton;

	private GameObject gymButton1;

	private GameObject gymButton2;

	private GameObject regionText;

	private GameObject gymButtonText1;

	private GameObject gymButtonText2;

	private string currentscene = "";

	private ParkInstance parkinstance;

	private void PoolStructures()
	{
		try
		{
			for (int i = 0; i < pools.Length; i++)
			{
				pools[i] = GameObject.Find(poolPaths[i]).gameObject;
			}
		}
		catch
		{
		}
	}

	public void DestroyStructures()
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < pools.Length; i++)
		{
			for (int j = 0; j < pools[i].transform.childCount; j++)
			{
				GameObject gameObject = ((Component)pools[i].transform.GetChild(j)).gameObject;
				if (gameObject.activeSelf && currentscene != "Park" && ((Object)gameObject.transform).name != "BoulderBall" && ((Object)gameObject.transform).name != "LargeRock" && ((Object)gameObject.transform).name != "SmallRock")
				{
					gameObject.GetComponent<Structure>().Kill(Vector3.zero, false, false, true);
				}
				else if (gameObject.activeSelf && currentscene == "Park")
				{
					gameObject.GetComponent<Structure>().Kill(Vector3.zero, false, false, true);
				}
			}
		}
	}

	private void SetupPark()
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		parkinstance = GameObject.Find("________________LOGIC__________________ /Park Instance").GetComponent<ParkInstance>();
		ResetSessionButton = GameObject.Find("________________LOGIC__________________ /Heinhouwser products/Parkboard (Park)/Primary Display/Park/Minigame Start button/InteractionButton");
		newResetSessionButton = Object.Instantiate<GameObject>(ResetSessionButton);
		newResetSessionButton.transform.SetParent(parkDummy.transform);
		newResetSessionButton.transform.position = new Vector3(-12.62f, -4.86f, 6.39f);
		newResetSessionButton.transform.rotation = Quaternion.Euler(90f, 125f, 0f);
		((Component)newResetSessionButton.transform.GetChild(0)).gameObject.GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
		{
			DestroyStructures();
			parkinstance.RPC_CleanScene();
		}));
		buttonDisplay = Object.Instantiate<GameObject>(GameObject.Find("________________LOGIC__________________ /Park Toys/MatchCounter/Scoreboard/ResetScoreBoard"));
		buttonDisplay.transform.SetParent(parkDummy.transform);
		buttonDisplay.transform.position = new Vector3(-12.738f, -4.99f, 6.221f);
		buttonDisplay.transform.rotation = Quaternion.Euler(90f, 35f, 0f);
		buttonDisplayText = Object.Instantiate<GameObject>(GameObject.Find("________________LOGIC__________________ /Heinhouwser products/Parkboard (Park)/Primary Display/Park/Minigame Start button/TextandIcons/NameCanvas"));
		buttonDisplayText.transform.SetParent(parkDummy.transform);
		buttonDisplayText.transform.position = new Vector3(-12.68f, -4.955f, 6.279f);
		buttonDisplayText.transform.rotation = Quaternion.Euler(0f, 305f, 0f);
		buttonDisplayText.transform.localScale = Vector3.one * 0.7f;
		parkInitialized = true;
		MelonLogger.Msg("successfully completed ExtraResetButtons Park setup");
	}

	private void SetupGym()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		dummy = new GameObject("ExtraResetButtons objects");
		Object.DontDestroyOnLoad((Object)(object)dummy);
		gymDummy = new GameObject("Gym");
		Object.DontDestroyOnLoad((Object)(object)gymDummy);
		gymDummy.transform.SetParent(dummy.transform);
		parkDummy = new GameObject("Park");
		Object.DontDestroyOnLoad((Object)(object)parkDummy);
		parkDummy.transform.SetParent(dummy.transform);
		originalButton = GameObject.Find("------------TUTORIAL------------/Static tutorials/RUMBLE Starter Guide/Next Page Button/InteractionButton");
		gymButton1 = Object.Instantiate<GameObject>(originalButton);
		gymButton1.transform.SetParent(gymDummy.transform);
		gymButton1.transform.position = new Vector3(4.4542f, -2.0399f, -10.106f);
		gymButton1.transform.rotation = Quaternion.Euler(270f, 350f, 0f);
		((Object)gymButton1.transform).name = "Howard Area Destroy structures button";
		((Component)gymButton1.transform.GetChild(0)).gameObject.GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
		{
			DestroyStructures();
		}));
		gymButton2 = Object.Instantiate<GameObject>(originalButton);
		gymButton2.transform.SetParent(gymDummy.transform);
		gymButton2.transform.position = new Vector3(-41.8807f, 4.6797f, 2.3603f);
		gymButton2.transform.rotation = Quaternion.Euler(90f, 130f, 0f);
		((Object)gymButton2.transform).name = "Training Area Destroy structures button";
		((Component)gymButton2.transform.GetChild(0)).gameObject.GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
		{
			DestroyStructures();
		}));
		regionText = GameObject.Find("--------------LOGIC--------------/Heinhouser products/MatchConsole/RankRelaxControls/Texts/Title Text");
		gymButtonText1 = Object.Instantiate<GameObject>(regionText);
		gymButtonText1.transform.SetParent(gymDummy.transform);
		gymButtonText1.transform.position = new Vector3(4.4592f, -2.1949f, -10.1115f);
		gymButtonText1.transform.rotation = Quaternion.Euler(0f, 350f, 0f);
		((TMP_Text)gymButtonText1.GetComponent<TextMeshPro>()).text = "Destroy Structures";
		((Object)gymButtonText1.transform).name = "Howard Area Destroy structures text";
		gymButtonText2 = Object.Instantiate<GameObject>(regionText);
		gymButtonText2.transform.SetParent(gymDummy.transform);
		gymButtonText2.transform.position = new Vector3(-41.8807f, 4.5497f, 2.3603f);
		gymButtonText2.transform.rotation = Quaternion.Euler(0f, 310f, 0f);
		((TMP_Text)gymButtonText2.GetComponent<TextMeshPro>()).text = "Destroy Structures";
		((Object)gymButtonText2.transform).name = "Training Area Destroy structures text";
		gymInitialized = true;
		MelonLogger.Msg("successfully completed ExtraResetButtons Gym setup");
	}

	public override void OnLateInitializeMelon()
	{
		((MelonBase)this).OnLateInitializeMelon();
		poolPaths[0] = "Game Instance/Pre-Initializable/PoolManager/Pool: Pillar (RUMBLE.MoveSystem.Structure)";
		poolPaths[1] = "Game Instance/Pre-Initializable/PoolManager/Pool: Wall (RUMBLE.MoveSystem.Structure)";
		poolPaths[2] = "Game Instance/Pre-Initializable/PoolManager/Pool: Disc (RUMBLE.MoveSystem.Structure)";
		poolPaths[3] = "Game Instance/Pre-Initializable/PoolManager/Pool: RockCube (RUMBLE.MoveSystem.Structure)";
		poolPaths[4] = "Game Instance/Pre-Initializable/PoolManager/Pool: Ball (RUMBLE.MoveSystem.Structure)";
		poolPaths[5] = "Game Instance/Pre-Initializable/PoolManager/Pool: LargeRock (RUMBLE.MoveSystem.Structure)";
		poolPaths[6] = "Game Instance/Pre-Initializable/PoolManager/Pool: SmallRock (RUMBLE.MoveSystem.Structure)";
		poolPaths[7] = "Game Instance/Pre-Initializable/PoolManager/Pool: BoulderBall (RUMBLE.MoveSystem.Structure)";
	}

	private void Disable()
	{
		gymDummy.SetActive(false);
		if (parkInitialized)
		{
			parkDummy.SetActive(false);
		}
	}

	private void EnableGym()
	{
		gymDummy.SetActive(true);
	}

	private void EnablePark()
	{
		parkDummy.SetActive(true);
	}

	public override void OnSceneWasLoaded(int buildindex, string sceneName)
	{
		if (gymInitialized)
		{
			Disable();
		}
		currentscene = sceneName;
		if (sceneName != "" && sceneName != "Loader")
		{
			PoolStructures();
		}
		if (sceneName == "Park" && !parkInitialized)
		{
			SetupPark();
		}
		else if (sceneName == "Gym" && !gymInitialized)
		{
			SetupGym();
		}
		else if (sceneName == "Park" && parkInitialized)
		{
			EnablePark();
		}
		else if (sceneName == "Gym" && gymInitialized)
		{
			EnableGym();
		}
	}
}