Decompiled source of MinecraftStrongholdInterior v0.9.0

BepInEx/plugins/MCStronghold/MCStronghold.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using DunGen.Graph;
using HarmonyLib;
using LethalLevelLoader;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("MCStronghold")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Stronghold Dungeon From Minecraft")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("MCStronghold")]
[assembly: AssemblyTitle("MCStronghold")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 MCStronghold
{
	internal class ItemGroupPatch
	{
		[HarmonyPatch("Equals")]
		[HarmonyPrefix]
		public static bool FixItemGroupEquals(ref bool __result, object __instance, object other)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			ItemGroup val = (ItemGroup)((__instance is ItemGroup) ? __instance : null);
			if ((Object)(object)val != (Object)null)
			{
				ItemGroup val2 = (ItemGroup)((other is ItemGroup) ? other : null);
				if ((Object)(object)val2 != (Object)null)
				{
					__result = val.itemSpawnTypeName == val2.itemSpawnTypeName;
					return false;
				}
			}
			return true;
		}
	}
	[BepInPlugin("MCStronghold", "MCStronghold", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private ConfigEntry<int> configStrongholdRarity;

		private ConfigEntry<int> configMansionRarity;

		private ConfigEntry<string> configMoons;

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

		private void Awake()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Expected O, but got Unknown
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Expected O, but got Unknown
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Expected O, but got Unknown
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Expected O, but got Unknown
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Expected O, but got Unknown
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Expected O, but got Unknown
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Expected O, but got Unknown
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Expected O, but got Unknown
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Expected O, but got Unknown
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Expected O, but got Unknown
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Expected O, but got Unknown
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_055c: Expected O, but got Unknown
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Expected O, but got Unknown
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mcstronghold"));
			DungeonFlow dungeonFlow = val.LoadAsset<DungeonFlow>("Assets/Mods/MCStronghold/data/Stronghold/StrongholdDungeonFlow.asset");
			DungeonFlow dungeonFlow2 = val.LoadAsset<DungeonFlow>("Assets/Mods/MCStronghold/data/Mansion/MansionFlow.asset");
			AudioClip dungeonFirstTimeAudio = val.LoadAsset<AudioClip>("Assets/Mods/MCStronghold/snd/cave1.ogg");
			ExtendedDungeonFlow val2 = ScriptableObject.CreateInstance<ExtendedDungeonFlow>();
			val2.dungeonFlow = dungeonFlow;
			val2.dungeonFirstTimeAudio = dungeonFirstTimeAudio;
			val2.dungeonDisplayName = "Minecraft Stronghold";
			ExtendedDungeonFlow val3 = ScriptableObject.CreateInstance<ExtendedDungeonFlow>();
			val3.dungeonFlow = dungeonFlow2;
			val3.dungeonFirstTimeAudio = dungeonFirstTimeAudio;
			val3.dungeonDisplayName = "Minecraft Woodland Mansion";
			configStrongholdRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "StrongholdRarity", 300, new ConfigDescription("Higher values increases the chance of spawning. Vanillas' main dungeons use a value of 300.", (AcceptableValueBase)null, Array.Empty<object>()));
			configMoons = ((BaseUnityPlugin)this).Config.Bind<string>("General", "StrongholdMoonsList", "all", new ConfigDescription("The moon(s) that the stronghold can spawn on, in the form of a comma separated list of selectable level names and optionally a weight value by using an '@' and weight value after it (e.g. \"Titan@300,Dine,Rend@10\")\nThe name matching is lenient and should pick it up if you use the terminal name or internal mod name. If no rarity is specified, the Rarity parameter is used.\nThe following strings: \"all\", \"vanilla\", \"modded\", \"paid\", \"free\" are dynamic presets which add the dungeon to that specified group (string must only contain one of these, or a manual moon name list).\n", (AcceptableValueBase)null, Array.Empty<object>()));
			switch (configMoons.Value.ToLower())
			{
			case "all":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", configStrongholdRarity.Value));
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", configStrongholdRarity.Value));
				break;
			case "vanilla":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", configStrongholdRarity.Value));
				break;
			case "modded":
				val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", configStrongholdRarity.Value));
				break;
			case "paid":
				val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(1f, 9999f), configStrongholdRarity.Value));
				break;
			case "free":
				val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(0f, 0f), configStrongholdRarity.Value));
				break;
			default:
			{
				string[] array = configMoons.Value.Split(',', StringSplitOptions.RemoveEmptyEntries);
				List<StringWithRarity> list = new List<StringWithRarity>();
				for (int i = 0; i < array.Length; i++)
				{
					string[] array2 = array[i].Split('@', StringSplitOptions.RemoveEmptyEntries);
					int num = array2.Length;
					if (num <= 2)
					{
						int result;
						if (num == 1)
						{
							list.Add(new StringWithRarity(array[i], configStrongholdRarity.Value));
						}
						else if (int.TryParse(array2[1], out result))
						{
							list.Add(new StringWithRarity(array2[0], result));
						}
					}
				}
				val2.manualPlanetNameReferenceList = list;
				break;
			}
			}
			configMansionRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MansionRarity", 300, new ConfigDescription("Higher values increases the chance of spawning. Vanillas' main dungeons use a value of 300.", (AcceptableValueBase)null, Array.Empty<object>()));
			configMoons = ((BaseUnityPlugin)this).Config.Bind<string>("General", "MansionMoonsList", "all", new ConfigDescription("The moon(s) that the Mansion can spawn on, in the form of a comma separated list of selectable level names and optionally a weight value by using an '@' and weight value after it (e.g. \"Titan@300,Dine,Rend@10\")\nThe name matching is lenient and should pick it up if you use the terminal name or internal mod name. If no rarity is specified, the Rarity parameter is used.\nThe following strings: \"all\", \"vanilla\", \"modded\", \"paid\", \"free\" are dynamic presets which add the dungeon to that specified group (string must only contain one of these, or a manual moon name list).\n", (AcceptableValueBase)null, Array.Empty<object>()));
			switch (configMoons.Value.ToLower())
			{
			case "all":
				val3.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", configMansionRarity.Value));
				val3.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", configMansionRarity.Value));
				break;
			case "vanilla":
				val3.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", configMansionRarity.Value));
				break;
			case "modded":
				val3.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", configMansionRarity.Value));
				break;
			case "paid":
				val3.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(1f, 9999f), configMansionRarity.Value));
				break;
			case "free":
				val3.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(0f, 0f), configMansionRarity.Value));
				break;
			default:
			{
				string[] array3 = configMoons.Value.Split(',', StringSplitOptions.RemoveEmptyEntries);
				List<StringWithRarity> list2 = new List<StringWithRarity>();
				for (int j = 0; j < array3.Length; j++)
				{
					string[] array4 = array3[j].Split('@', StringSplitOptions.RemoveEmptyEntries);
					int num2 = array4.Length;
					if (num2 <= 2)
					{
						int result2;
						if (num2 == 1)
						{
							list2.Add(new StringWithRarity(array3[j], configMansionRarity.Value));
						}
						else if (int.TryParse(array4[1], out result2))
						{
							list2.Add(new StringWithRarity(array4[0], result2));
						}
					}
				}
				val3.manualPlanetNameReferenceList = list2;
				break;
			}
			}
			harmony.PatchAll();
			PatchedContent.RegisterExtendedDungeonFlow(val2);
			PatchedContent.RegisterExtendedDungeonFlow(val3);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MCStronghold is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MCStronghold";

		public const string PLUGIN_NAME = "MCStronghold";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}