Decompiled source of Bucket Equipper v2.0.1

Mods/BucketEquipper.dll

Decompiled 5 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BucketEquipper;
using HarmonyLib;
using Il2CppRUMBLE.Environment.Minigames;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using RumbleModUI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(BucketEquipperClass), "Equips THE Bucket", "2.0.1", "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("BucketEquipper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BucketEquipper")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0d7d5f50-aa49-4c95-9903-67cc97c373c4")]
[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 BucketEquipper;

[HarmonyPatch(typeof(ParkMinigame), "OnMiniGameEnded")]
public static class Patch
{
	private static void Postfix()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Invalid comparison between Unknown and I4
		try
		{
			Enumerator<Player> enumerator = Singleton<PlayerManager>.instance.AllPlayers.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Player current = enumerator.Current;
				if ((int)current.Controller.controllerType == 1)
				{
					if (BucketEquipperClass.showForSelf)
					{
						((Component)((Component)current.Controller).gameObject.transform.GetChild(6).GetChild(0)).gameObject.SetActive(true);
					}
				}
				else if (BucketEquipperClass.showForOthers)
				{
					((Component)((Component)current.Controller).gameObject.transform.GetChild(7).GetChild(0)).gameObject.SetActive(true);
				}
			}
		}
		catch
		{
		}
	}
}
public class BucketEquipperClass : MelonMod
{
	private string currentScene = "Loader";

	private bool sceneChanged = false;

	private int playerCount;

	public static bool showForSelf;

	public static bool showForOthers;

	private UI UI = UI.instance;

	private Mod BucketEquipper = new Mod();

	public override void OnLateInitializeMelon()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		BucketEquipper.ModName = "Equips THE Bucket";
		BucketEquipper.ModVersion = "2.0.1";
		BucketEquipper.SetFolder("BucketEquipper");
		BucketEquipper.AddDescription("Description", "Description", "Toggles Buckets on Everyone", new Tags
		{
			IsSummary = true
		});
		BucketEquipper.AddToList("Self", false, 0, "Turns On/Off Self Bucket", new Tags());
		BucketEquipper.AddToList("Others", true, 0, "Turns On/Off Others Buckets", new Tags());
		BucketEquipper.GetFromFile();
		showForSelf = (bool)BucketEquipper.Settings[1].Value;
		showForOthers = (bool)BucketEquipper.Settings[2].Value;
		BucketEquipper.ModSaved += Save;
		UI.instance.UI_Initialized += UIInit;
	}

	public void UIInit()
	{
		UI.AddMod(BucketEquipper);
	}

	public void Save()
	{
		showForSelf = (bool)BucketEquipper.Settings[1].Value;
		showForOthers = (bool)BucketEquipper.Settings[2].Value;
		equipBuckets();
	}

	public override void OnFixedUpdate()
	{
		if (sceneChanged)
		{
			equipBuckets();
			sceneChanged = false;
		}
		else if (currentScene != "Loader" && currentScene != "Gym" && playerCount != Singleton<PlayerManager>.instance.AllPlayers.Count)
		{
			equipBuckets();
		}
	}

	private void equipBuckets()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		try
		{
			int num = 0;
			Enumerator<Player> enumerator = Singleton<PlayerManager>.instance.AllPlayers.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Player current = enumerator.Current;
				if ((int)current.Controller.controllerType == 1)
				{
					if (showForSelf)
					{
						((Component)((Component)current.Controller).gameObject.transform.GetChild(6).GetChild(0)).gameObject.SetActive(true);
					}
					else
					{
						((Component)((Component)current.Controller).gameObject.transform.GetChild(6).GetChild(0)).gameObject.SetActive(false);
					}
				}
				else if (showForOthers)
				{
					((Component)((Component)current.Controller).gameObject.transform.GetChild(7).GetChild(0)).gameObject.SetActive(true);
				}
				else
				{
					((Component)((Component)current.Controller).gameObject.transform.GetChild(7).GetChild(0)).gameObject.SetActive(false);
				}
				playerCount = num;
				num++;
			}
		}
		catch
		{
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		sceneChanged = true;
	}
}