Decompiled source of WhiteGuillotine v1.0.2

WhiteGuillotine.dll

Decompiled 2 months ago
using System;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
using vanillaVoid;
using vanillaVoid.Items;

[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("WhiteGuillotine")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a38587412f9107ee1bd8047226c0fba4fe510ba4")]
[assembly: AssemblyProduct("WhiteGuillotine")]
[assembly: AssemblyTitle("WhiteGuillotine")]
[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 WhiteGuillotine
{
	[BepInPlugin("prodzpod.WhiteGuillotine", "WhiteGuillotine", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_SetItemDefs <>9__12_0;

			public static hook_OnInventoryChanged <>9__12_1;

			public static hook_SetItemDefs <>9__12_2;

			internal void <Awake>b__12_0(orig_SetItemDefs orig, ItemDef[] defs)
			{
				Items.ExecuteLowHealthElite._itemTierDef = ItemTierCatalog.GetItemTierDef((ItemTier)0);
				Items.ExecuteLowHealthElite.pickupIconSprite = AssetBundle.LoadAsset<Sprite>("Assets/texExecuteLowHealthElite.png");
				Items.ExecuteLowHealthElite.unlockableDef.achievementIcon = AssetBundle.LoadAsset<Sprite>("Assets/unlocks/texItemExecuteLowHealthElite.png");
				orig.Invoke(defs);
			}

			internal void <Awake>b__12_1(orig_OnInventoryChanged orig, CharacterBody self)
			{
				orig.Invoke(self);
				int itemCount = self.inventory.GetItemCount(Items.ExecuteLowHealthElite);
				if (itemCount > 0)
				{
					self.executeEliteHealthFraction = Util.ConvertAmplificationPercentageIntoReductionPercentage(Threshold.Value + ThresholdPerStack.Value * (float)(itemCount - 1)) / 100f;
				}
			}

			internal void <Awake>b__12_2(orig_SetItemDefs orig, ItemDef[] defs)
			{
				if (Chainloader.PluginInfos.ContainsKey("com.Zenithrium.vanillaVoid"))
				{
					PatchExeblade.Patch();
				}
				orig.Invoke(defs);
			}
		}

		public const string PluginGUID = "prodzpod.WhiteGuillotine";

		public const string PluginAuthor = "prodzpod";

		public const string PluginName = "WhiteGuillotine";

		public const string PluginVersion = "1.0.2";

		public static ManualLogSource Log;

		public static PluginInfo pluginInfo;

		public static ConfigFile Config;

		public static ConfigEntry<float> Threshold;

		public static ConfigEntry<float> ThresholdPerStack;

		private static AssetBundle _assetBundle;

		public static AssetBundle AssetBundle
		{
			get
			{
				if ((Object)(object)_assetBundle == (Object)null)
				{
					_assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(pluginInfo.Location), "riskymonkey"));
				}
				return _assetBundle;
			}
		}

		public void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//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_0096: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			pluginInfo = ((BaseUnityPlugin)this).Info;
			Log = ((BaseUnityPlugin)this).Logger;
			Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "prodzpod.WhiteGuillotine.cfg"), true);
			Threshold = Config.Bind<float>("General", "Threshold", 13f, "yeah");
			ThresholdPerStack = Config.Bind<float>("General", "Threshold per stack", 13f, "yeah");
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				hook_SetItemDefs val = delegate(orig_SetItemDefs orig, ItemDef[] defs)
				{
					Items.ExecuteLowHealthElite._itemTierDef = ItemTierCatalog.GetItemTierDef((ItemTier)0);
					Items.ExecuteLowHealthElite.pickupIconSprite = AssetBundle.LoadAsset<Sprite>("Assets/texExecuteLowHealthElite.png");
					Items.ExecuteLowHealthElite.unlockableDef.achievementIcon = AssetBundle.LoadAsset<Sprite>("Assets/unlocks/texItemExecuteLowHealthElite.png");
					orig.Invoke(defs);
				};
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			ItemCatalog.SetItemDefs += (hook_SetItemDefs)obj;
			object obj2 = <>c.<>9__12_1;
			if (obj2 == null)
			{
				hook_OnInventoryChanged val2 = delegate(orig_OnInventoryChanged orig, CharacterBody self)
				{
					orig.Invoke(self);
					int itemCount = self.inventory.GetItemCount(Items.ExecuteLowHealthElite);
					if (itemCount > 0)
					{
						self.executeEliteHealthFraction = Util.ConvertAmplificationPercentageIntoReductionPercentage(Threshold.Value + ThresholdPerStack.Value * (float)(itemCount - 1)) / 100f;
					}
				};
				<>c.<>9__12_1 = val2;
				obj2 = (object)val2;
			}
			CharacterBody.OnInventoryChanged += (hook_OnInventoryChanged)obj2;
			object obj3 = <>c.<>9__12_2;
			if (obj3 == null)
			{
				hook_SetItemDefs val3 = delegate(orig_SetItemDefs orig, ItemDef[] defs)
				{
					if (Chainloader.PluginInfos.ContainsKey("com.Zenithrium.vanillaVoid"))
					{
						PatchExeblade.Patch();
					}
					orig.Invoke(defs);
				};
				<>c.<>9__12_2 = val3;
				obj3 = (object)val3;
			}
			ItemCatalog.SetItemDefs += (hook_SetItemDefs)obj3;
		}
	}
	internal class PatchExeblade
	{
		public static void Patch()
		{
			BaseUnityPlugin instance = Chainloader.PluginInfos["com.Zenithrium.vanillaVoid"].Instance;
			ItemBase val = ((vanillaVoidPlugin)((instance is vanillaVoidPlugin) ? instance : null)).Items.Find((ItemBase x) => x.ItemLangTokenName == "EXEBLADE_ITEM");
			if (val != null)
			{
				val.ItemDef._itemTierDef = ItemTierCatalog.GetItemTierDef((ItemTier)6);
			}
		}
	}
}