Decompiled source of HavingFunWithButtons v1.0.1

Mods/HavingFunWithButtons.dll

Decompiled 5 days 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 HavingFunWithButtons;
using Il2CppSystem;
using MelonLoader;
using RumbleModdingAPI;
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(main), "Having Fun With Buttons", "1.0.0", "ERROR", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 0, 0)]
[assembly: MelonAuthorColor(255, 255, 0, 0)]
[assembly: AssemblyTitle("Having Fun With Button")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Having Fun With Buttons")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b10c94a1-8a40-4701-bc5b-98eabb44dfea")]
[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 HavingFunWithButtons;

public class main : MelonMod
{
	private bool init = false;

	private string currentScene = "Loader";

	private int sceneCount = 0;

	private List<GameObject> SineWaveButtons = new List<GameObject>();

	private float time = 0f;

	private float amplitude = 1f;

	private float wavelength = 5f;

	public override void OnLateInitializeMelon()
	{
		Calls.onMapInitialized += OnMapInitialized;
		MelonLogger.Msg("Why would you install this");
	}

	public void OnMapInitialized()
	{
		if (currentScene != "Loader")
		{
			MelonCoroutines.Start(InitializeWithPause(sceneCount));
		}
	}

	private IEnumerator InitializeWithPause(int sceneNumber)
	{
		DateTime now = DateTime.Now;
		DateTime targetTime = ((DateTime)(ref now)).AddSeconds(1.0);
		while (DateTime.Now < targetTime)
		{
			yield return (object)new WaitForFixedUpdate();
		}
		if (sceneNumber == sceneCount)
		{
			Initialize();
		}
	}

	public void Initialize()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		CreateCircleOfButtons(2000, new Vector3(2.8007f, 0.3792f, -1.9802f), 2f);
		CreateSineWaveOfButtons(100, new Vector3(3.8127f, 1.2818f, 2.7782f), amplitude, wavelength, 0.1f);
		CreateHeightMapOfButtons(60, new Vector3(3.8127f, 10.2818f, 2.7782f));
		init = true;
	}

	private void CreateCircleOfButtons(int numberOfButtons, Vector3 center, float radius)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0050: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("HavingFunWithButtons (Dont look inside)");
		Vector3 val2 = default(Vector3);
		for (int i = 0; i < numberOfButtons; i++)
		{
			float num = Mathf.Acos(1f - 2f * (float)((double)i + 0.5) / (float)numberOfButtons);
			float num2 = (float)Math.PI * (1f + Mathf.Sqrt(5f)) * (float)i;
			float num3 = center.x + radius * Mathf.Sin(num) * Mathf.Cos(num2);
			float num4 = center.y + radius * Mathf.Cos(num);
			float num5 = center.z + radius * Mathf.Sin(num) * Mathf.Sin(num2);
			((Vector3)(ref val2))..ctor(num3, num4, num5);
			GameObject val3 = Create.NewButton(val2, Quaternion.identity, (Action)delegate
			{
				MelonLogger.Msg("Hello!");
			});
			val3.transform.LookAt(center);
			val3.transform.SetParent(val.transform);
			val3.transform.Rotate(270f, 180f, 0f);
		}
	}

	private void CreateHeightMapOfButtons(int numberOfButtonsPerAxis, Vector3 startPosition)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("HeightMapOfButtons");
		Vector3 val2 = default(Vector3);
		for (int i = 0; i < numberOfButtonsPerAxis; i++)
		{
			for (int j = 0; j < numberOfButtonsPerAxis; j++)
			{
				float num = startPosition.x + (float)i * 0.15f;
				float num2 = startPosition.z + (float)j * 0.15f;
				float num3 = startPosition.y + 1.5f + 20f * Mathf.PerlinNoise(num / 5f, num2 / 5f);
				((Vector3)(ref val2))..ctor(num, num3, num2);
				GameObject val3 = Create.NewButton(val2, Quaternion.identity, (Action)delegate
				{
					MelonLogger.Msg("Height map button!");
				});
				val3.transform.LookAt(new Vector3(num, num3, num2 + 1f));
				val3.transform.SetParent(val.transform);
				val3.transform.Rotate(270f, 180f, 0f);
			}
		}
	}

	private void CreateSineWaveOfButtons(int numberOfButtons, Vector3 startPosition, float amplitude, float wavelength, float spacing)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("SineWaveOfButtons");
		Vector3 val2 = default(Vector3);
		for (int i = 0; i < numberOfButtons; i++)
		{
			float num = startPosition.x + (float)i * spacing;
			float num2 = startPosition.y + amplitude * Mathf.Sin((float)Math.PI * 2f / wavelength * num);
			float z = startPosition.z;
			((Vector3)(ref val2))..ctor(num, num2, z);
			GameObject val3 = Create.NewButton(val2, Quaternion.identity, (Action)delegate
			{
				MelonLogger.Msg("Sine wave button!");
			});
			val3.transform.LookAt(new Vector3(num, num2, z + 1f));
			val3.transform.SetParent(val.transform);
			val3.transform.Rotate(-270f, 180f, 0f);
			SineWaveButtons.Add(val3);
		}
	}

	private void CreateTangentWaveOfButtons(int numberOfButtons, Vector3 startPosition)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("TangentWaveOfButtons");
		Vector3 val2 = default(Vector3);
		for (int i = 0; (float)i < Mathf.Sqrt((float)numberOfButtons); i++)
		{
			for (int j = 0; (float)j < Mathf.Sqrt((float)numberOfButtons); j++)
			{
				float num = startPosition.x + (float)i * 0.1f;
				float num2 = startPosition.z + (float)j * 0.1f;
				float num3 = startPosition.y + 1.5f + amplitude * Mathf.Sin((float)Math.PI * 2f / wavelength * num) * Mathf.Cos((float)Math.PI * 2f / wavelength * num2);
				((Vector3)(ref val2))..ctor(num, num3, num2);
				GameObject val3 = Create.NewButton(val2, Quaternion.identity, (Action)delegate
				{
					MelonLogger.Msg("3D wave button!");
				});
				val3.transform.LookAt(new Vector3(num, num3, num2 + 1f));
				val3.transform.SetParent(val.transform);
				val3.transform.Rotate(270f, 180f, 0f);
			}
		}
	}

	private Quaternion GetAngleToFaceMe(Vector3 objectPosition, Vector3 lookAtPosition)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: 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)
		Vector3 val = objectPosition - lookAtPosition;
		return Quaternion.LookRotation(val);
	}

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

	public override void OnUpdate()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: 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)
		time += Time.deltaTime;
		foreach (GameObject sineWaveButton in SineWaveButtons)
		{
			Vector3 position = sineWaveButton.transform.position;
			float num = Mathf.Sin((float)Math.PI * 2f / wavelength * position.x + time);
			sineWaveButton.transform.position = new Vector3(position.x, num + 1.5f, position.z);
		}
	}
}