Decompiled source of Lower Elemental Resistances v1.0.4

Lower_Player_Resistances.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Lower_Player_Resistances")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("warpalicious")]
[assembly: AssemblyProduct("Lower_Player_Resistances")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")]
[assembly: AssemblyFileVersion("1.0.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace Lower_Player_Resistances
{
	public class DamageModifierClass
	{
		[HarmonyPatch(typeof(Player), "ApplyArmorDamageMods")]
		private static class ApplyArmorDamageModsPatch
		{
			private static void Postfix(ref DamageModifiers mods)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//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_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: 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_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					mods.m_blunt = Lower_Player_ResistancesPlugin.GetDamageModifier(Lower_Player_ResistancesPlugin.BluntConfig.Value);
					mods.m_slash = Lower_Player_ResistancesPlugin.GetDamageModifier(Lower_Player_ResistancesPlugin.SlashConfig.Value);
					mods.m_pierce = Lower_Player_ResistancesPlugin.GetDamageModifier(Lower_Player_ResistancesPlugin.PierceConfig.Value);
					mods.m_fire = Lower_Player_ResistancesPlugin.GetDamageModifier(Lower_Player_ResistancesPlugin.FireConfig.Value);
					mods.m_frost = Lower_Player_ResistancesPlugin.GetDamageModifier(Lower_Player_ResistancesPlugin.FrostConfig.Value);
					mods.m_lightning = Lower_Player_ResistancesPlugin.GetDamageModifier(Lower_Player_ResistancesPlugin.LightningConfig.Value);
					mods.m_poison = Lower_Player_ResistancesPlugin.GetDamageModifier(Lower_Player_ResistancesPlugin.PoisonConfig.Value);
					mods.m_spirit = Lower_Player_ResistancesPlugin.GetDamageModifier(Lower_Player_ResistancesPlugin.SpiritConfig.Value);
				}
				catch (Exception ex)
				{
					Lower_Player_ResistancesPlugin.Lower_Player_ResistancesLogger.LogError((object)("Error in ApplyArmorDamageModsPatch: " + ex.Message));
				}
			}
		}
	}
	[BepInPlugin("warpalicious.Lower_Player_Resistances", "Lower_Player_Resistances", "1.0.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Lower_Player_ResistancesPlugin : BaseUnityPlugin
	{
		internal const string ModName = "Lower_Player_Resistances";

		internal const string ModVersion = "1.0.4";

		internal const string Author = "warpalicious";

		private const string ModGUID = "warpalicious.Lower_Player_Resistances";

		private static string ConfigFileName = "warpalicious.Lower_Player_Resistances.cfg";

		private static string ConfigFileFullPath;

		private readonly Harmony _harmony = new Harmony("warpalicious.Lower_Player_Resistances");

		public static readonly ManualLogSource Lower_Player_ResistancesLogger;

		public static ConfigEntry<DamageModifier> BluntConfig;

		public static ConfigEntry<DamageModifier> SlashConfig;

		public static ConfigEntry<DamageModifier> PierceConfig;

		public static ConfigEntry<DamageModifier> FireConfig;

		public static ConfigEntry<DamageModifier> FrostConfig;

		public static ConfigEntry<DamageModifier> LightningConfig;

		public static ConfigEntry<DamageModifier> PoisonConfig;

		public static ConfigEntry<DamageModifier> SpiritConfig;

		private static readonly DamageModifier[] AllModifiers;

		public static DamageModifier GetDamageModifier(DamageModifier value)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return value;
		}

		public void Awake()
		{
			bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			BluntConfig = SyncedConfig("Resistances", "Blunt", (DamageModifier)2, "Blunt");
			SlashConfig = SyncedConfig("Resistances", "Slash", (DamageModifier)2, "Slash");
			PierceConfig = SyncedConfig("Resistances", "Pierce", (DamageModifier)2, "Pierce");
			FireConfig = SyncedConfig("Resistances", "Fire", (DamageModifier)2, "Fire");
			FrostConfig = SyncedConfig("Resistances", "Frost", (DamageModifier)2, "Frost");
			LightningConfig = SyncedConfig("Resistances", "Lightning", (DamageModifier)2, "Lightning");
			PoisonConfig = SyncedConfig("Resistances", "Poison", (DamageModifier)2, "Poison");
			SpiritConfig = SyncedConfig("Resistances", "Spirit", (DamageModifier)2, "Spirit");
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
			if (saveOnConfigSet)
			{
				((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet;
				((BaseUnityPlugin)this).Config.Save();
			}
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(ConfigFileFullPath))
			{
				return;
			}
			try
			{
				Lower_Player_ResistancesLogger.LogDebug((object)"ReadConfigValues called");
				((BaseUnityPlugin)this).Config.Reload();
			}
			catch
			{
				Lower_Player_ResistancesLogger.LogError((object)("There was an issue loading your " + ConfigFileName));
				Lower_Player_ResistancesLogger.LogError((object)"Please check your config entries for spelling and format!");
			}
		}

		private ConfigEntry<DamageModifier> SyncedConfig(string group, string name, DamageModifier defaultValue, string damageType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			};
			ConfigDescription val2 = new ConfigDescription(damageType + " damage modifier. Options: " + string.Join(", ", AllModifiers) + ".", (AcceptableValueBase)null, new object[1] { val });
			return ((BaseUnityPlugin)this).Config.Bind<DamageModifier>(group, name, defaultValue, val2);
		}

		static Lower_Player_ResistancesPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			Lower_Player_ResistancesLogger = Logger.CreateLogSource("Lower_Player_Resistances");
			BluntConfig = null;
			SlashConfig = null;
			PierceConfig = null;
			FireConfig = null;
			FrostConfig = null;
			LightningConfig = null;
			PoisonConfig = null;
			SpiritConfig = null;
			AllModifiers = Enum.GetValues(typeof(DamageModifier)).Cast<DamageModifier>().ToArray();
		}
	}
}