Decompiled source of ClearStructures v1.0.0

Mods/ClearStructures.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using ClearStructures;
using Il2CppRUMBLE.Interactions.InteractionBase;
using Il2CppRUMBLE.MoveSystem;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RumbleModdingAPI;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(HostInfoMod), "Clear structures", "1.0.0", "oreotrollturbo", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("ClearStructures")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ClearStructures")]
[assembly: AssemblyTitle("ClearStructures")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ClearStructures
{
	public static class BuildInfo
	{
		public const string ModName = "Clear structures";

		public const string ModVersion = "1.0.0";

		public const string Author = "oreotrollturbo";
	}
	public class HostInfoMod : MelonMod
	{
		private const float textOffset = 0.17f;

		private static GameObject clearStructuresParent;

		public override void OnLateInitializeMelon()
		{
			Calls.onMapInitialized += SceneLoaded;
		}

		private static void SceneLoaded()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (!(Scene.GetSceneName() != "Gym"))
			{
				clearStructuresParent = new GameObject("Clear structures");
				CreatePlayerStructuresButtons();
				CreateNaturalStructuresButton();
			}
		}

		private static void CreateNaturalStructuresButton()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			GameObject val = Create.NewButton(new Vector3(0.4486f, 1.2937f, -4.5301f), Quaternion.Euler(90f, 68.9361f, 0f));
			((Object)val).name = "Delete natural structures button";
			val.transform.parent = clearStructuresParent.transform;
			Vector3 vector = val.transform.position + new Vector3(0f, 0.17f, 0f);
			CreateTextBox("Delete natural structures", 0.5f, Color.white, vector, Quaternion.Euler(13.3693f, 248.5481f, -0.0004f)).transform.SetParent(val.transform);
			((Component)val.transform.GetChild(0)).gameObject.GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
			{
				MelonCoroutines.Start(OnDeleteNaturalButtonPressed());
			}));
		}

		private static void CreatePlayerStructuresButtons()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Create.NewButton(new Vector3(0.2031f, 1.2937f, -3.8228f), Quaternion.Euler(90f, 68.9361f, 0f));
			((Object)val).name = "Delete player structures button";
			val.transform.parent = clearStructuresParent.transform;
			Vector3 vector = val.transform.position + new Vector3(0f, 0.17f, 0f);
			GameObject val2 = CreateTextBox("Delete player structures", 0.5f, Color.white, vector, Quaternion.Euler(13.3693f, 248.5481f, -0.0004f));
			val2.transform.SetParent(val.transform);
			((Component)val.transform.GetChild(0)).gameObject.GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
			{
				MelonCoroutines.Start(OnDeletePlayerButtonPressed());
			}));
			GameObject val3 = Object.Instantiate<GameObject>(val);
			((Object)val3).name = "Howard button";
			val3.transform.parent = clearStructuresParent.transform;
			val3.transform.position = new Vector3(3.9885f, -1.9329f, -10.2107f);
			val3.transform.rotation = Quaternion.Euler(90f, 180.6203f, 0f);
			((Component)val3.transform.GetChild(0)).gameObject.GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
			{
				MelonCoroutines.Start(OnDeletePlayerButtonPressed());
			}));
			GameObject val4 = Object.Instantiate<GameObject>(val);
			((Object)val4).name = "Pose ghost button";
			val4.transform.parent = clearStructuresParent.transform;
			val4.transform.position = new Vector3(-14.1415f, 1.2796f, 3.0538f);
			val4.transform.rotation = Quaternion.Euler(75.5654f, 168.3386f, 0f);
			((Component)val4.transform.GetChild(0)).gameObject.GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
			{
				MelonCoroutines.Start(OnDeletePlayerButtonPressed());
			}));
			GameObject val5 = Object.Instantiate<GameObject>(val);
			((Object)val5).name = "Flat area button";
			val5.transform.parent = clearStructuresParent.transform;
			val5.transform.position = new Vector3(-35.5767f, 4.2626f, 8.9219f);
			val5.transform.rotation = Quaternion.Euler(90f, 148.5198f, 0f);
			((Component)val5.transform.GetChild(0)).gameObject.GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
			{
				MelonCoroutines.Start(OnDeletePlayerButtonPressed());
			}));
		}

		private static IEnumerator OnDeletePlayerButtonPressed()
		{
			DestroyPlayerStructures();
			yield return (object)new WaitForSeconds(0f);
		}

		private static IEnumerator OnDeleteNaturalButtonPressed()
		{
			DestroyNaturalStructures();
			yield return (object)new WaitForSeconds(0f);
		}

		private static void DestroyStructure(GameObject pool)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!pool.activeSelf)
			{
				return;
			}
			for (int i = 0; i < pool.transform.childCount; i++)
			{
				Transform child = pool.transform.GetChild(i);
				if ((Object)(object)child == (Object)null)
				{
					break;
				}
				Structure component = ((Component)child).GetComponent<Structure>();
				if ((Object)(object)component == (Object)null)
				{
					break;
				}
				component.Kill(default(Vector3), true, true, true);
			}
		}

		private static void DestroyPlayerStructures()
		{
			DestroyStructure(Structures.GetPoolDisc());
			DestroyStructure(Structures.GetPoolPillar());
			DestroyStructure(Structures.GetPoolBall());
			DestroyStructure(Structures.GetPoolCube());
			DestroyStructure(Structures.GetPoolWall());
		}

		private static void DestroyNaturalStructures()
		{
			DestroyStructure(Structures.GetPoolBoulderBall());
			DestroyStructure(Structures.GetPoolLargeRock());
			DestroyStructure(Structures.GetPoolSmallRock());
		}

		private static GameObject CreateTextBox(string text, float textSize, Color color, Vector3 vector, Quaternion rotation)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Create.NewText(text, textSize, color, default(Vector3), Quaternion.Euler(0f, 0f, 0f));
			val.transform.position = vector;
			val.transform.rotation = rotation;
			return val;
		}
	}
}