Decompiled source of NoMainEntrance v1.0.0

NoMainEntrance.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using NoMainEntrance.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoMainEntrance")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoMainEntrance")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2eac4f9d-0a2e-43f8-b0a5-b66835dc6072")]
[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 NoMainEntrance
{
	[BepInPlugin("NoMainEntrance", "No Main Entrance", "1.0.0")]
	public class NoMainEntranceBase : BaseUnityPlugin
	{
		private const string modGUID = "NoMainEntrance";

		private const string modName = "No Main Entrance";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("NoMainEntrance");

		private static NoMainEntranceBase Instance;

		public static ManualLogSource LoggerInstance { get; private set; }

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			if ((Object)Instance == (Object)null)
			{
				Instance = this;
			}
			LoggerInstance = ((BaseUnityPlugin)this).Logger;
			LoggerInstance.LogInfo((object)"Plugin No Main Entrance loaded successfully.");
			harmony.PatchAll(typeof(NoMainEntranceBase));
			harmony.PatchAll(typeof(EntranceTeleportPatch));
			harmony.PatchAll(typeof(HUDManagerPatch));
		}
	}
}
namespace NoMainEntrance.Patches
{
	[HarmonyPatch(typeof(EntranceTeleport))]
	internal class EntranceTeleportPatch : HarmonyPatch
	{
		[HarmonyPatch("TeleportPlayer")]
		[HarmonyPrefix]
		public static bool TeleportPlayerPrefix(bool ___isEntranceToBuilding, int ___entranceId, bool ___gotExitPoint)
		{
			if (!___gotExitPoint)
			{
				Logger.CreateLogSource("NoMainEntrance").LogInfo((object)"Pre Initial Sweep");
			}
			else if (___entranceId == 0 && ___isEntranceToBuilding)
			{
				Logger.CreateLogSource("NoMainEntrance").LogInfo((object)"Pre Main Entrance Denied");
				HUDManager.Instance.DisplayTip("???", "The entrance appears to be welded shut from the outside...", false, false, "LC_Tip1");
				return false;
			}
			return true;
		}

		[HarmonyPatch("FindExitPoint")]
		[HarmonyPostfix]
		public static void FindExitPointPostfix(bool ___isEntranceToBuilding, int ___entranceId, bool ___gotExitPoint, ref bool __result)
		{
			Logger.CreateLogSource("NoMainEntrance").LogInfo((object)$"Entrance ID: {___entranceId}");
			Logger.CreateLogSource("NoMainEntrance").LogInfo((object)$"Is Entrance?: {___isEntranceToBuilding}");
			if (!___gotExitPoint)
			{
				Logger.CreateLogSource("NoMainEntrance").LogInfo((object)"Post Initial Sweep");
			}
			else if (___entranceId == 0 && ___isEntranceToBuilding)
			{
				Logger.CreateLogSource("NoMainEntrance").LogInfo((object)"Post Main Entrance Denied");
				HUDManager.Instance.DisplayTip("???", "The entrance appears to be welded shut from the outside...", false, false, "LC_Tip1");
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch : HarmonyPatch
	{
		[HarmonyPatch("DisplayTip")]
		[HarmonyPostfix]
		public static void DisplayTipPostfix(string headerText, string bodyText, bool isWarning = false, bool useSave = false, string prefsKey = "LC_Tip1")
		{
			Logger.CreateLogSource("NoMainEntrance").LogInfo((object)"Displaying Tip On Hud");
			Logger.CreateLogSource("NoMainEntrance").LogInfo((object)(bodyText ?? ""));
		}
	}
}