Decompiled source of ExtraResetButtons v1.0.1

ExtraResetButtons.dll

Decompiled 4 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 MelonLoader;
using RUMBLE.Environment;
using RUMBLE.Interactions.InteractionBase;
using RUMBLE.MoveSystem;
using TMPro;
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
{
	private GameObject[] pools = (GameObject[])(object)new GameObject[5];

	private GameObject ResetSessionButton;

	private GameObject newResetSessionButton;

	private GameObject buttonDisplay;

	private GameObject buttonDisplayText;

	private GameObject originalButton;

	private GameObject gymButton1;

	private GameObject gymButton2;

	private GameObject keybindSwitcherButton;

	private GameObject regionText;

	private GameObject gymButtonText1;

	private GameObject gymButtonText2;

	private GameObject keybindSwitcherText1;

	private GameObject keybindSwitcherText2;

	private InteractionButton button;

	private ParkInstance parkinstance;

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

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

	public void DestroyStructures()
	{
		//IL_002f: 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)
				{
					gameObject.GetComponent<Structure>().Kill(Vector3.zero, false, false, true);
				}
			}
		}
	}

	private void SetupPark()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: 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_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: 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.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.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.position = new Vector3(-12.68f, -4.955f, 6.279f);
		buttonDisplayText.transform.rotation = Quaternion.Euler(0f, 305f, 0f);
		buttonDisplayText.transform.localScale = Vector3.one * 0.7f;
		MelonLogger.Msg("successfully completed ExtraResetButtons Park setup");
	}

	private void SetupGym()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: 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_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		originalButton = GameObject.Find("------------TUTORIAL------------/Static tutorials/RUMBLE Starter Guide/Next Page Button/InteractionButton");
		gymButton1 = Object.Instantiate<GameObject>(originalButton);
		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.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();
		}));
		keybindSwitcherButton = Object.Instantiate<GameObject>(originalButton);
		regionText = GameObject.Find("--------------LOGIC--------------/Heinhouser products/MatchConsole/RankRelaxControls/Texts/Title Text");
		gymButtonText1 = Object.Instantiate<GameObject>(regionText);
		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.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";
		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)";
	}

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