Decompiled source of Open Burial v1.1.0

OpenBurial.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OpenBurial")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenBurial")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("514a1887-506d-4b71-8be0-c82954a559f2")]
[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 OpenBurial;

public enum EDisableMazeRocks
{
	Never,
	[Description("When Tomb Forced Open")]
	WhenForcedOpen,
	Always
}
[BepInPlugin("valafi.openburial", "Open Burial", "1.1.0")]
public class OpenBurialPlugin : BaseUnityPlugin
{
	public static ManualLogSource logSource;

	public static ConfigEntry<EDisableMazeRocks> disableMazeRocks;

	private void Awake()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		logSource = ((BaseUnityPlugin)this).Logger;
		logSource.LogInfo((object)"Open Burial is loaded!");
		disableMazeRocks = ((BaseUnityPlugin)this).Config.Bind<EDisableMazeRocks>("Tomb Maze Rocks", "DisableMazeRocks", EDisableMazeRocks.WhenForcedOpen, "Maze rocks can totally block the maze tunnels! This determines when to disable them.");
		new Harmony("valafi.openburial").PatchAll();
	}
}
[HarmonyPatch(typeof(RunManager), "StartRun")]
public static class RunManagerStartRunOpenBurialPatch
{
	[HarmonyPostfix]
	public static void Postfix()
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Expected O, but got Unknown
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Expected O, but got Unknown
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Expected O, but got Unknown
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_0421: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_043b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0447: Unknown result type (might be due to invalid IL or missing references)
		//IL_0451: 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_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Expected O, but got Unknown
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Expected O, but got Unknown
		MethodInfo method = typeof(DesertRockSpawner).GetMethod("GetRefs", BindingFlags.Instance | BindingFlags.NonPublic);
		FieldInfo field = typeof(DesertRockSpawner).GetField("enterences", BindingFlags.Instance | BindingFlags.NonPublic);
		FieldInfo field2 = typeof(DesertRockSpawner).GetField("inside", BindingFlags.Instance | BindingFlags.NonPublic);
		MethodInfo method2 = typeof(HelperFunctions).GetMethod("InstantiatePrefab", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[4]
		{
			typeof(GameObject),
			typeof(Vector3),
			typeof(Quaternion),
			typeof(Transform)
		}, null);
		Scene activeScene = SceneManager.GetActiveScene();
		Random random = new Random(((Scene)(ref activeScene)).path.GetHashCode());
		DesertRockSpawner[] array = Object.FindObjectsByType<DesertRockSpawner>((FindObjectsInactive)1, (FindObjectsSortMode)0);
		LODGroup val4 = default(LODGroup);
		foreach (DesertRockSpawner val in array)
		{
			method.Invoke(val, null);
			Transform val2 = (Transform)field.GetValue(val);
			Transform val3 = (Transform)field2.GetValue(val);
			bool flag = false;
			foreach (Transform item in val2)
			{
				foreach (Transform item2 in item)
				{
					Transform doorObject = item2;
					if (!val.enterenceObjects.Any((GameObject e) => ((Object)e).name == ((Object)doorObject).name))
					{
						continue;
					}
					if (!val.blockerObjects.Any((GameObject b) => ((Object)b).name == ((Object)doorObject).name))
					{
						flag = true;
						break;
					}
					bool flag2 = false;
					foreach (Transform item3 in doorObject)
					{
						if (((Component)item3).TryGetComponent<LODGroup>(ref val4))
						{
							flag2 = true;
							break;
						}
					}
					if (!flag2)
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					break;
				}
			}
			if (OpenBurialPlugin.disableMazeRocks.Value == EDisableMazeRocks.Always || (OpenBurialPlugin.disableMazeRocks.Value == EDisableMazeRocks.WhenForcedOpen && !flag))
			{
				HashSet<string> hashSet = new HashSet<string> { "rocks", "floor", "roof" };
				foreach (Transform item4 in ((Component)val).gameObject.transform)
				{
					Transform val5 = item4;
					if (((Object)val5).name.ToLower() != "inside")
					{
						continue;
					}
					foreach (Transform item5 in val5)
					{
						Transform val6 = item5;
						if (((Object)val6).name.ToLower() != "maze")
						{
							continue;
						}
						foreach (Transform item6 in val6)
						{
							Transform val7 = item6;
							if (hashSet.Contains(((Object)val7).name.ToLower()))
							{
								((Component)val7).gameObject.SetActive(false);
							}
						}
					}
				}
			}
			if (!flag)
			{
				Transform child = val2.GetChild(random.Next(0, val2.childCount));
				for (int num = child.childCount - 1; num >= 0; num--)
				{
					Object.DestroyImmediate((Object)(object)((Component)child.GetChild(num)).gameObject);
				}
				((GameObject)method2.Invoke(null, new object[4]
				{
					val.enterenceObjects[random.Next(0, val.enterenceObjects.Length)],
					child.position,
					child.rotation,
					child
				})).transform.localScale = Vector3.one * 2f;
				val3.position = new Vector3(child.position.x, val3.position.y, child.position.z);
			}
		}
	}
}