Decompiled source of MineshaftBegone v1.0.0

plugins/ESN.MineshaftBegone/ESN.MineshaftBegone.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MineshaftBegone.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ESN.MineshaftBegone")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f8537520a7cf82d180c5c2d38a4c6144d72f0e08")]
[assembly: AssemblyProduct("MineshaftBegone")]
[assembly: AssemblyTitle("ESN.MineshaftBegone")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MineshaftBegone
{
	public class MyLog
	{
		public static void LogInfo(string message)
		{
			Plugin.Logger.LogInfo((object)message);
		}

		public static void LogWarning(string message)
		{
			Plugin.Logger.LogWarning((object)message);
		}

		public static void LogError(string message)
		{
			Plugin.Logger.LogError((object)message);
		}

		public static void LogDebug(string message)
		{
		}
	}
	[BepInPlugin("ESN.MineshaftBegone", "MineshaftBegone", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"ESN.MineshaftBegone v1.0.0 has loaded!");
		}

		internal void Patch()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("ESN.MineshaftBegone");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll(typeof(DungeonPatch));
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ESN.MineshaftBegone";

		public const string PLUGIN_NAME = "MineshaftBegone";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MineshaftBegone.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	public class DungeonPatch
	{
		public enum States
		{
			LevelDisabled,
			LevelEnabled
		}

		[HarmonyPatch("GenerateNewFloor")]
		[HarmonyPrefix]
		private static void GenerateNewFloorPrefixPatch(RoundManager __instance)
		{
			int num = __instance.currentLevel.dungeonFlowTypes.Length;
			MyLog.LogDebug($"__instance.currentLevel.dungeonFlowTypes.Length = {num}");
			int num2 = __instance.dungeonFlowTypes.Length;
			MyLog.LogDebug($"__instance.dungeonFlowTypes.Length = {num2}");
			Dictionary<int, States> dictionary = new Dictionary<int, States>
			{
				{
					0,
					States.LevelEnabled
				},
				{
					1,
					States.LevelEnabled
				},
				{
					4,
					States.LevelDisabled
				},
				{
					5,
					States.LevelEnabled
				},
				{
					6,
					States.LevelEnabled
				},
				{
					7,
					States.LevelEnabled
				},
				{
					8,
					States.LevelEnabled
				},
				{
					9,
					States.LevelEnabled
				},
				{
					10,
					States.LevelEnabled
				},
				{
					11,
					States.LevelEnabled
				}
			};
			Dictionary<int, string> dictionary2 = new Dictionary<int, string>
			{
				{ 0, "Factory" },
				{ 1, "Mansion" },
				{ 4, "Mineshaft" }
			};
			for (int i = 0; i < num; i++)
			{
				IntWithRarity val = __instance.currentLevel.dungeonFlowTypes[i];
				IndoorMapType val2 = __instance.dungeonFlowTypes[val.id];
				MyLog.LogInfo(string.Format("Processing interior #{0} - ID {1} - {2} - {3} - Rarity {4}", i, val.id, ((Object)val2.dungeonFlow).name, dictionary2.ContainsKey(val.id) ? dictionary2[val.id] : "NA", val.rarity));
				if (!dictionary.ContainsKey(val.id))
				{
					MyLog.LogWarning($"Level ID {val.id} unknown");
				}
				else if (dictionary[val.id] == States.LevelDisabled)
				{
					val.rarity = 0;
					MyLog.LogInfo("Disabling interior '" + (dictionary2.ContainsKey(val.id) ? dictionary2[val.id] : ((Object)val2.dungeonFlow).name) + "'");
				}
			}
		}

		[HarmonyPatch("GenerateNewFloor")]
		[HarmonyPostfix]
		private static void GenerateNewFloorPostfixPatch(RoundManager __instance)
		{
			MyLog.LogInfo("###################### Loaded new floor ######################");
			MyLog.LogInfo($"Loaded level ID {__instance.currentDungeonType} - {((Object)__instance.dungeonFlowTypes[__instance.currentDungeonType].dungeonFlow).name}");
			MyLog.LogInfo("##############################################################");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}