Decompiled source of LeechingSeedBuff v1.1.1

LeechingSeedBuff.dll

Decompiled 6 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.Logging;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using R2API;
using RoR2;
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.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("LeechingSeedBuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LeechingSeedBuff")]
[assembly: AssemblyTitle("LeechingSeedBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ExamplePlugin
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void LogDebug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void LogError(object data)
		{
			_logSource.LogError(data);
		}

		internal static void LogFatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void LogInfo(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void LogMessage(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}
namespace LeechingSeedBuff
{
	[BepInPlugin("OakPrime.LeechingSeedBuff", "LeechingSeedBuff", "1.1.1")]
	public class LeechingSeedBuff : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Instruction, bool> <>9__5_1;

			public static Func<Instruction, bool> <>9__5_2;

			public static Func<Instruction, bool> <>9__5_3;

			public static Action<DamageInfo> <>9__5_4;

			public static Manipulator <>9__5_0;

			internal void <Awake>b__5_0(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				int num3 = default(int);
				int num2 = default(int);
				val.TryGotoNext(new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num3),
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "combinedHealth"),
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num2)
				});
				val.Emit(OpCodes.Ldarg_1);
				val.EmitDelegate<Action<DamageInfo>>((Action<DamageInfo>)delegate(DamageInfo damageInfo)
				{
					//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
					//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
					if (damageInfo != null && !((Object)(object)damageInfo.attacker == (Object)null))
					{
						CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
						CharacterMaster val2 = ((component != null) ? component.master : null);
						Inventory val3 = ((val2 != null) ? val2.inventory : null);
						if ((Object)(object)val3 != (Object)null && !((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)6))
						{
							int itemCount = val3.GetItemCount(Items.Seed);
							if (itemCount > 0)
							{
								HealthComponent val4 = ((component != null) ? ((Component)component).GetComponent<HealthComponent>() : null);
								if ((Object)(object)val4 != (Object)null && Object.op_Implicit((Object)(object)val4))
								{
									ProcChainMask procChainMask = damageInfo.procChainMask;
									((ProcChainMask)(ref procChainMask)).AddProc((ProcType)6);
									double num = val4.Heal((float)itemCount * 0.2f, procChainMask, true);
								}
							}
						}
					}
				});
			}

			internal bool <Awake>b__5_1(Instruction x)
			{
				int num = default(int);
				return ILPatternMatchingExt.MatchLdarg(x, ref num);
			}

			internal bool <Awake>b__5_2(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "combinedHealth");
			}

			internal bool <Awake>b__5_3(Instruction x)
			{
				int num = default(int);
				return ILPatternMatchingExt.MatchStloc(x, ref num);
			}

			internal void <Awake>b__5_4(DamageInfo damageInfo)
			{
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				if (damageInfo == null || (Object)(object)damageInfo.attacker == (Object)null)
				{
					return;
				}
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				CharacterMaster val = ((component != null) ? component.master : null);
				Inventory val2 = ((val != null) ? val.inventory : null);
				if (!((Object)(object)val2 != (Object)null) || ((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)6))
				{
					return;
				}
				int itemCount = val2.GetItemCount(Items.Seed);
				if (itemCount > 0)
				{
					HealthComponent val3 = ((component != null) ? ((Component)component).GetComponent<HealthComponent>() : null);
					if ((Object)(object)val3 != (Object)null && Object.op_Implicit((Object)(object)val3))
					{
						ProcChainMask procChainMask = damageInfo.procChainMask;
						((ProcChainMask)(ref procChainMask)).AddProc((ProcType)6);
						double num = val3.Heal((float)itemCount * 0.2f, procChainMask, true);
					}
				}
			}
		}

		public const string PluginGUID = "OakPrime.LeechingSeedBuff";

		public const string PluginAuthor = "OakPrime";

		public const string PluginName = "LeechingSeedBuff";

		public const string PluginVersion = "1.1.1";

		private readonly Dictionary<string, string> DefaultLanguage = new Dictionary<string, string>();

		public void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			try
			{
				object obj = <>c.<>9__5_0;
				if (obj == null)
				{
					Manipulator val = delegate(ILContext il)
					{
						//IL_0002: Unknown result type (might be due to invalid IL or missing references)
						//IL_0008: Expected O, but got Unknown
						//IL_007c: Unknown result type (might be due to invalid IL or missing references)
						ILCursor val2 = new ILCursor(il);
						int num3 = default(int);
						int num2 = default(int);
						val2.TryGotoNext(new Func<Instruction, bool>[3]
						{
							(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num3),
							(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "combinedHealth"),
							(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num2)
						});
						val2.Emit(OpCodes.Ldarg_1);
						val2.EmitDelegate<Action<DamageInfo>>((Action<DamageInfo>)delegate(DamageInfo damageInfo)
						{
							//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
							//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
							//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
							if (damageInfo != null && !((Object)(object)damageInfo.attacker == (Object)null))
							{
								CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
								CharacterMaster val3 = ((component != null) ? component.master : null);
								Inventory val4 = ((val3 != null) ? val3.inventory : null);
								if ((Object)(object)val4 != (Object)null && !((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)6))
								{
									int itemCount = val4.GetItemCount(Items.Seed);
									if (itemCount > 0)
									{
										HealthComponent val5 = ((component != null) ? ((Component)component).GetComponent<HealthComponent>() : null);
										if ((Object)(object)val5 != (Object)null && Object.op_Implicit((Object)(object)val5))
										{
											ProcChainMask procChainMask = damageInfo.procChainMask;
											((ProcChainMask)(ref procChainMask)).AddProc((ProcType)6);
											double num = val5.Heal((float)itemCount * 0.2f, procChainMask, true);
										}
									}
								}
							}
						});
					};
					<>c.<>9__5_0 = val;
					obj = (object)val;
				}
				HealthComponent.TakeDamage += (Manipulator)obj;
				ReplaceSeedText();
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)(ex.Message + " - " + ex.StackTrace));
			}
		}

		private void ReplaceSeedText()
		{
			ReplaceString("ITEM_SEED_DESC", "Proc damage <style=cIsHealing>heals</style> you for  <style=cIsHealing>1</style> <style=cStack>(+1 per stack)</style>, <style=cIsHealing>health</style>. Also heals for <style=cIsHealing>0.2</style> <style=cStack>(+0.2 per stack)</style>on all damage instances.");
		}

		private void ReplaceString(string token, string newText)
		{
			DefaultLanguage[token] = Language.GetString(token);
			LanguageAPI.Add(token, newText);
		}
	}
}