Decompiled source of Unbound Terrain v1.0.0

UnboundTerrain.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Landfall.TABS;
using LevelCreator;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UnboundTerrain")]
[assembly: AssemblyDescription("UnboundTerrain")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("UnboundTerrain")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace UnboundTerrain;

[BepInPlugin("GeeztJeez.UnboundTerrain", "UnboundTerrain", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
	private void Awake()
	{
		((MonoBehaviour)this).StartCoroutine("Call");
	}

	private IEnumerator Call()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
		yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
		Debug.Log((object)"Loading UnboundTerrain...");
		SLMALoader.GetInstance();
		SceneManager.sceneLoaded += SceneLoaded;
		new Harmony("UnboundTerrain").PatchAll();
		Debug.Log((object)"Loaded UnboundTerrain Successfully!");
	}

	public void SceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
	{
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: 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)
		ControllerManager[] array = Object.FindObjectsOfType<ControllerManager>();
		foreach (ControllerManager val in array)
		{
			val.outOfBoundsHeight *= 1000f;
			Debug.Log((object)$"Updated ControllerManager: {((Object)((Component)val).gameObject).name}, new outOfBoundHeight: {val.outOfBoundsHeight}");
		}
		if (((Scene)(ref scene)).name == "Editor Scene")
		{
			MeshCollider[] array2 = Object.FindObjectsOfType<MeshCollider>();
			foreach (MeshCollider val2 in array2)
			{
				if (((Object)((Component)val2).gameObject).name == "Water")
				{
					Transform transform = ((Component)val2).transform;
					transform.localScale = new Vector3(10000f, transform.localScale.y, 10000f);
					Debug.Log((object)("Scaled MeshCollider GameObject: " + ((Object)((Component)val2).gameObject).name));
				}
			}
		}
		if (((Scene)(ref scene)).name == "LevelScene")
		{
			SpawnLevel[] array3 = Object.FindObjectsOfType<SpawnLevel>();
			for (int j = 0; j < array3.Length; j++)
			{
				Transform transform2 = ((Component)array3[j]).transform;
				transform2.localScale *= 10f;
				Vector3 position = transform2.position;
				position.x *= 10f;
				position.z *= 10f;
				position.y = -125f;
				transform2.position = position;
			}
			Water[] array4 = Object.FindObjectsOfType<Water>();
			foreach (Water val3 in array4)
			{
				Transform transform3 = ((Component)val3).transform;
				transform3.localScale = new Vector3(10000f, transform3.localScale.y, 10000f);
				transform3.parent.position = new Vector3(transform3.parent.position.x, CalculateYScale(transform3.parent.position.y, -24f), transform3.parent.position.z);
				Debug.Log((object)("Scaled and Positioned Water GameObject: " + ((Object)((Component)val3).gameObject).name));
			}
		}
	}

	[CompilerGenerated]
	internal static float CalculateYScale(float y, float defaultY)
	{
		float num = defaultY - y;
		Debug.Log((object)("Difference: " + num));
		Debug.Log((object)("Y: " + y));
		Debug.Log((object)("Defaukt: " + defaultY));
		if (num < 0f)
		{
			return num * -5f;
		}
		if (num > 0f)
		{
			return num * -15f;
		}
		return defaultY;
	}
}
[HarmonyPatch(typeof(MapSettings), "Awake")]
internal class MapSettingsPatch
{
	private static void Prefix(MapSettings __instance)
	{
		FieldInfo field = typeof(MapSettings).GetField("m_mapRadius", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field != null)
		{
			field.SetValue(__instance, 1000000f);
			Debug.Log((object)$"[MapSettingsPatch] m_mapRadius set to {field.GetValue(__instance)}");
		}
		else
		{
			Debug.LogWarning((object)"[MapSettingsPatch] m_mapRadius field not found in MapSettings!");
		}
	}
}