Decompiled source of MansionOnly v1.0.1

BepInEx/plugins/MansionOnly/HitsujiSauce.MansionOnly.dll

Decompiled 2 months 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MansionOnly;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HitsujiSauce.MansionOnly")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MansionOnly")]
[assembly: AssemblyTitle("HitsujiSauce.MansionOnly")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
[HarmonyPatch(typeof(StartOfRound))]
public class StartOfRound_Patch
{
	[HarmonyPatch("ChooseNewRandomMapSeed")]
	[HarmonyPostfix]
	public static void ChooseNewRandomMapSeedPatch(StartOfRound __instance)
	{
		global::MansionOnly.MansionOnly.ConfigUtil.Reload();
		if (!global::MansionOnly.MansionOnly.ConfigUtil.enable.Value || RoundManager.Instance.currentLevel.levelID == 3 || RoundManager.Instance.currentLevel.dungeonFlowTypes == null || RoundManager.Instance.currentLevel.dungeonFlowTypes.Length == 0)
		{
			return;
		}
		List<int> list = new List<int>();
		int value = global::MansionOnly.MansionOnly.ConfigUtil.dungeonFlowType.Value;
		bool flag = false;
		for (int i = 0; i < RoundManager.Instance.currentLevel.dungeonFlowTypes.Length; i++)
		{
			if (RoundManager.Instance.currentLevel.dungeonFlowTypes[i].id == value && RoundManager.Instance.currentLevel.dungeonFlowTypes[i].rarity == 0)
			{
				return;
			}
			list.Add(RoundManager.Instance.currentLevel.dungeonFlowTypes[i].rarity);
			if (RoundManager.Instance.currentLevel.dungeonFlowTypes[i].id == value)
			{
				flag = true;
			}
		}
		if (!flag)
		{
			return;
		}
		int randomMapSeed = __instance.randomMapSeed;
		for (int j = 0; j < 5000; j++)
		{
			randomMapSeed = Random.Range(1, 100000000);
			Random random = new Random(randomMapSeed);
			int randomWeightedIndex = RoundManager.Instance.GetRandomWeightedIndex(list.ToArray(), random);
			int id = RoundManager.Instance.currentLevel.dungeonFlowTypes[randomWeightedIndex].id;
			if (id == value)
			{
				__instance.randomMapSeed = randomMapSeed;
			}
		}
	}
}
namespace MansionOnly
{
	[BepInPlugin("HitsujiSauce.MansionOnly", "MansionOnly", "1.0.0")]
	public class MansionOnly : BaseUnityPlugin
	{
		public class ConfigUtil
		{
			public static ConfigEntry<bool> enable;

			public static ConfigEntry<int> dungeonFlowType;

			private static ConfigFile cfg;

			public static void Init(ConfigFile config)
			{
				enable = config.Bind<bool>("General", "enable", true, "Enable this mod");
				dungeonFlowType = config.Bind<int>("General", "DungeonFlowType", 1, "The target dungeon flow type");
				cfg = config;
			}

			public static void Reload()
			{
				enable = cfg.Bind<bool>("General", "enable", true, "Enable this mod");
				dungeonFlowType = cfg.Bind<int>("General", "DungeonFlowType", 1, "The target dungeon flow type");
			}
		}

		public static MansionOnly 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();
			ConfigUtil.Init(((BaseUnityPlugin)this).Config);
			Logger.LogInfo((object)"HitsujiSauce.MansionOnly v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("HitsujiSauce.MansionOnly");
			}
			Harmony.PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "HitsujiSauce.MansionOnly";

		public const string PLUGIN_NAME = "MansionOnly";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}