Decompiled source of NoBending v1.0.0

Mods/ProjectUmble.dll

Decompiled 6 months ago
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 MelonLoader;
using ProjectUmble;
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(UmbleWithoutTheR), "No Bending", "1.0.0", "Teddy", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: AssemblyTitle("ProjectUmble")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProjectUmble")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bd30066a-98d5-4c82-9220-fd8ec4e19da1")]
[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 ProjectUmble;

public class UmbleWithoutTheR : MelonMod
{
	private const float retryInterval = 5f;

	private const int maxRetries = 5;

	private readonly List<string> objectNames = new List<string> { "Col_combatfloor0", "Col_combatfloor2", "Col_combatfloor1", "Col_combatfloor3", "Floor collission" };

	private string currentScene;

	private bool sceneChanged;

	public override void OnInitializeMelon()
	{
		MelonLogger.Msg("Umble without the r mod loaded!");
	}

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

	public override void OnFixedUpdate()
	{
		if (!(currentScene != "Gym") && sceneChanged)
		{
			sceneChanged = false;
			MelonLogger.Msg("Gym scene detected. Applying changes...");
			MelonCoroutines.Start(ChangeLayerWithRetry(objectNames, "Floor"));
		}
	}

	private IEnumerator ChangeLayerWithRetry(List<string> objectNames, string layerName)
	{
		int newLayer = LayerMask.NameToLayer(layerName);
		if (newLayer == -1)
		{
			MelonLogger.Warning("Layer '" + layerName + "' does not exist.");
			yield break;
		}
		HashSet<string> remainingObjects = new HashSet<string>(objectNames);
		int retryCount = 0;
		while (remainingObjects.Count > 0 && retryCount < 5)
		{
			foreach (string objectName in new List<string>(remainingObjects))
			{
				GameObject targetObject = GameObject.Find(objectName);
				if ((Object)targetObject != (Object)null)
				{
					int oldLayer = targetObject.layer;
					targetObject.layer = newLayer;
					MelonLogger.Msg($"Changed layer of '{objectName}' from {oldLayer} to {newLayer} ('{layerName}').");
					remainingObjects.Remove(objectName);
				}
				else
				{
					MelonLogger.Warning($"GameObject with name '{objectName}' not found. Retrying in {5f} seconds...");
				}
			}
			if (remainingObjects.Count > 0)
			{
				retryCount++;
				yield return (object)new WaitForSeconds(5f);
			}
		}
		if (remainingObjects.Count <= 0)
		{
			yield break;
		}
		foreach (string objectName2 in remainingObjects)
		{
			MelonLogger.Error($"Failed to find and change layer of GameObject '{objectName2}' after {5} retries.");
		}
	}
}