Decompiled source of ParkSettings v1.0.2

Mods/ParkSettings.dll

Decompiled 2 weeks ago
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2CppRUMBLE.Interactions.InteractionBase;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.UI;
using Il2CppRUMBLE.Utilities;
using MelonLoader;
using ParkConsole;
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(Core), "ParkSettings", "1.0.2", "TacoSlayer36", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 248, 231)]
[assembly: MelonAuthorColor(255, 255, 248, 231)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ParkSettings")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ParkSettings")]
[assembly: AssemblyTitle("ParkSettings")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ParkConsole;

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

	public const string Version = "1.0.2";

	public const string Description = "Puts an extra settings menu in the Park";

	public const string Author = "TacoSlayer36";

	public const string Company = "";
}
public class Core : MelonMod
{
	private string currentScene;

	private GameObject settingsClone;

	private bool cloneInitialized = false;

	private const float micThresholdRenderDistance = 4f;

	private GameObject settingsClone_base
	{
		get
		{
			GameObject obj = settingsClone;
			object result;
			if (obj == null)
			{
				result = null;
			}
			else
			{
				Transform transform = obj.transform;
				if (transform == null)
				{
					result = null;
				}
				else
				{
					Transform child = transform.GetChild(0);
					if (child == null)
					{
						result = null;
					}
					else
					{
						Transform child2 = child.GetChild(0);
						result = ((child2 != null) ? ((Component)child2).gameObject : null);
					}
				}
			}
			return (GameObject)result;
		}
	}

	private GameObject settingsClone_threshold
	{
		get
		{
			GameObject obj = settingsClone_base;
			object result;
			if (obj == null)
			{
				result = null;
			}
			else
			{
				Transform transform = obj.transform;
				if (transform == null)
				{
					result = null;
				}
				else
				{
					Transform child = transform.GetChild(4);
					if (child == null)
					{
						result = null;
					}
					else
					{
						Transform child2 = child.GetChild(1);
						if (child2 == null)
						{
							result = null;
						}
						else
						{
							Transform child3 = child2.GetChild(0);
							if (child3 == null)
							{
								result = null;
							}
							else
							{
								Transform child4 = child3.GetChild(1);
								if (child4 == null)
								{
									result = null;
								}
								else
								{
									Transform child5 = child4.GetChild(2);
									if (child5 == null)
									{
										result = null;
									}
									else
									{
										Transform child6 = child5.GetChild(3);
										result = ((child6 != null) ? ((Component)child6).gameObject : null);
									}
								}
							}
						}
					}
				}
			}
			return (GameObject)result;
		}
	}

	private Transform playerHead
	{
		get
		{
			Transform result = null;
			try
			{
				result = ((Component)Singleton<PlayerManager>.Instance.localPlayer.Controller).transform.GetChild(2).GetChild(0).GetChild(0);
			}
			catch
			{
			}
			return result;
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		if (!cloneInitialized)
		{
			if (currentScene == "Gym")
			{
				MelonCoroutines.Start(cloneSettings());
			}
			return;
		}
		if (currentScene == "Park")
		{
			toPark();
		}
		if (currentScene == "Gym" || currentScene.Contains("Map"))
		{
			toGymOrMatch();
		}
	}

	private IEnumerator cloneSettings()
	{
		if ((Object)(object)settingsClone != (Object)null)
		{
			cloneInitialized = true;
			yield break;
		}
		int i = 0;
		while ((Object)(object)playerHead == (Object)null)
		{
			if (i++ > 700)
			{
				yield break;
			}
			yield return (object)new WaitForFixedUpdate();
		}
		settingsClone = Object.Instantiate<GameObject>(GameObject.Find("--------------LOGIC--------------/Slabbuddy menu variant"));
		((Object)settingsClone).name = "Settings Clone";
		Object.DontDestroyOnLoad((Object)(object)settingsClone);
		settingsClone_base.SetActive(false);
		cloneInitialized = true;
	}

	public override void OnFixedUpdate()
	{
		//IL_002f: 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)
		if (cloneInitialized && !((Object)(object)playerHead == (Object)null))
		{
			settingsClone_threshold.SetActive(Vector3.Distance(settingsClone_threshold.transform.position, playerHead.position) <= 4f);
		}
	}

	private void setSettingsActive(bool active)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: 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_001f: Unknown result type (might be due to invalid IL or missing references)
		settingsClone_base.SetActive(active);
		if (active)
		{
			settingsClone.transform.localScale = Vector3.one;
			return;
		}
		settingsClone.transform.localScale = Vector3.zero;
		settingsClone.transform.position = new Vector3(0f, -100f, 0f);
		settingsClone.transform.localRotation = Quaternion.identity;
	}

	private void toPark()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		setSettingsActive(active: true);
		settingsClone.transform.position = new Vector3(-29.22f, -1.34f, -4.8f);
		settingsClone_base.transform.position = settingsClone.transform.position;
		settingsClone_base.transform.rotation = Quaternion.Euler(0f, 99.4f, 0f);
		settingsClone.GetComponentInChildren<SettingsForm>().UpdateInteractionBaseObjects();
		((InteractionNumericalBase)((Component)settingsClone_base.transform.GetChild(6).GetChild(0)).GetComponentInChildren<InteractionSlider>()).MoveToValue(0f);
	}

	private void toGymOrMatch()
	{
		setSettingsActive(active: false);
		settingsClone.GetComponentInChildren<SettingsForm>().SetPageNo(0);
		((InteractionNumericalBase)((Component)settingsClone_base.transform.GetChild(6).GetChild(0)).GetComponentInChildren<InteractionSlider>()).currentValue = 0f;
	}
}