Decompiled source of Challenging Corruptors v1.2.2

BepInEx/plugins/com.stiffmeds.challengingcorruptors.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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Challenging_Corruptors;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Obeliskial_Essentials;
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("com.stiffmeds.challengingcorruptors")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows you to choose the minimum difficulty of corruptors")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2+af7e19fb5b2f0f7cbbcaf95a170b701ccb772a9b")]
[assembly: AssemblyProduct("com.stiffmeds.challengingcorruptors")]
[assembly: AssemblyTitle("com.stiffmeds.challengingcorruptors")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.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;
		}
	}
}
public static class EssentialsCompatibility
{
	private static bool? _enabled;

	public static bool Enabled
	{
		get
		{
			bool valueOrDefault = _enabled.GetValueOrDefault();
			if (!_enabled.HasValue)
			{
				valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.stiffmeds.obeliskialessentials");
				_enabled = valueOrDefault;
			}
			return _enabled.Value;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void EssentialsRegister()
	{
		Essentials.RegisterMod(Plugin.PluginName, "Stiff Meds", "Challenging Corruptors", Plugin.PluginVersion, Plugin.ModDate, "https://github.com/binbinmods/Challenging_Corruptors", (string[])null, "", 100, (string[])null, "", true);
		Plugin.LogInfo(Plugin.PluginGUID + " " + Plugin.PluginVersion + " has loaded with Essentials!");
	}
}
namespace Challenging_Corruptors
{
	[BepInPlugin("com.meds.challengingcorruptors", "com.stiffmeds.challengingcorruptors", "1.2.2")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("com.meds.challengingcorruptors");

		public static string PluginName;

		public static string PluginVersion;

		public static string PluginGUID;

		internal static int ModDate = int.Parse(DateTime.Today.ToString("yyyyMMdd"));

		internal static ManualLogSource Log;

		public static string debugBase = "com.stiffmeds.challengingcorruptors ";

		public static ConfigEntry<bool> EnableMod { get; set; }

		public static ConfigEntry<bool> EnableDebugging { get; set; }

		public static ConfigEntry<bool> ForceUpwind { get; set; }

		public static ConfigEntry<int> medsMinimumCorruptor { get; private set; }

		private void Awake()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0039: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0066: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00c5: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			string text = "Challenging Corruptors";
			EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "EnableMod"), true, new ConfigDescription("Enables the mod. If false, the mod will not work then next time you load the game.", (AcceptableValueBase)null, Array.Empty<object>()));
			EnableDebugging = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "EnableDebugging"), false, new ConfigDescription("Enables the debugging", (AcceptableValueBase)null, Array.Empty<object>()));
			medsMinimumCorruptor = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Minimum Corruptor Difficulty", 4, new ConfigDescription("1: easy (vanilla); 2: average; 3: hard; 4: extreme; 5: tabula rasa only o:", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
			ForceUpwind = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "ForceUpwind"), false, new ConfigDescription("Forces Upwind to always be an option for a corruptor.", (AcceptableValueBase)null, Array.Empty<object>()));
			medsMinimumCorruptor.SettingChanged += delegate
			{
				Challenging_Corruptors.UpdateChallengeCorruptors();
			};
			ForceUpwind.SettingChanged += delegate
			{
				Challenging_Corruptors.UpdateChallengeCorruptors();
			};
			PluginName = "com.stiffmeds.challengingcorruptors";
			PluginVersion = "1.2.2";
			PluginGUID = "com.stiffmeds.challengingcorruptors";
			if (EnableMod.Value)
			{
				if (EssentialsCompatibility.Enabled)
				{
					EssentialsCompatibility.EssentialsRegister();
				}
				else
				{
					LogInfo(PluginGUID + " " + PluginVersion + " has loaded!");
				}
				harmony.PatchAll();
			}
		}

		internal static void LogDebug(string msg)
		{
			if (EnableDebugging.Value)
			{
				Log.LogDebug((object)(debugBase + msg));
			}
		}

		internal static void LogInfo(string msg)
		{
			Log.LogInfo((object)(debugBase + msg));
		}

		internal static void LogError(string msg)
		{
			Log.LogError((object)(debugBase + msg));
		}
	}
	[HarmonyPatch]
	public class Challenging_Corruptors
	{
		public static List<string> medsCorruptors = new List<string>();

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Globals), "CreateGameContent")]
		public static void CreateGameContentPostfix()
		{
			medsCorruptors = Globals.Instance.CardListByType[(CardType)27];
			UpdateChallengeCorruptors();
		}

		public static void UpdateChallengeCorruptors()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Invalid comparison between Unknown and I4
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			Globals.Instance.CardListByType[(CardType)27] = new List<string>();
			if (Plugin.medsMinimumCorruptor.Value == 5)
			{
				AddCorruptor("windsofamnesia");
			}
			else
			{
				foreach (string medsCorruptor in medsCorruptors)
				{
					CardData cardData = Globals.Instance.GetCardData(medsCorruptor, true);
					if ((Object)(object)cardData != (Object)null && (((int)cardData.CardRarity == 0 && Plugin.medsMinimumCorruptor.Value == 1) || ((int)cardData.CardRarity == 1 && Plugin.medsMinimumCorruptor.Value <= 2) || ((int)cardData.CardRarity == 2 && Plugin.medsMinimumCorruptor.Value <= 3) || (int)cardData.CardRarity == 3))
					{
						Globals.Instance.CardListByType[(CardType)27].Add(medsCorruptor);
					}
				}
			}
			if (Plugin.ForceUpwind.Value)
			{
				if (Plugin.medsMinimumCorruptor.Value == 4)
				{
					MakeCardEpic("upwind");
					MakeCardEpic("upwinda");
					MakeCardEpic("upwindb");
					MakeCardEpic("upwindrare");
				}
				AddCorruptor("upwind");
			}
		}

		public static void AddCorruptor(string corruptorID)
		{
			if (!Globals.Instance.CardListByType[(CardType)27].Contains(corruptorID))
			{
				Plugin.LogDebug("Adding corruptor " + corruptorID + " and variants");
				Globals.Instance.CardListByType[(CardType)27].Add(corruptorID);
				Globals.Instance.CardListByType[(CardType)27].Add(corruptorID + "a");
				Globals.Instance.CardListByType[(CardType)27].Add(corruptorID + "b");
				Globals.Instance.CardListByType[(CardType)27].Add(corruptorID + "rare");
			}
			else
			{
				Plugin.LogDebug("Corruptor " + corruptorID + " already present");
			}
		}

		public static void MakeCardEpic(string cardID)
		{
			CardData cardData = Globals.Instance.GetCardData(cardID, true);
			Dictionary<string, CardData> value = Traverse.Create((object)Globals.Instance).Field("_Cards").GetValue<Dictionary<string, CardData>>();
			Dictionary<string, CardData> value2 = Traverse.Create((object)Globals.Instance).Field("_CardsSource").GetValue<Dictionary<string, CardData>>();
			if ((Object)(object)cardData != (Object)null)
			{
				cardData.CardRarity = (CardRarity)3;
				value[cardID] = cardData;
				value2[cardID] = cardData;
				Traverse.Create((object)Globals.Instance).Field("_Cards").SetValue((object)value);
				Traverse.Create((object)Globals.Instance).Field("_CardsSource").SetValue((object)value2);
				Plugin.LogDebug("Made " + cardID + " epic");
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.stiffmeds.challengingcorruptors";

		public const string PLUGIN_NAME = "com.stiffmeds.challengingcorruptors";

		public const string PLUGIN_VERSION = "1.2.2";
	}
}