Decompiled source of DeathMarkFix v1.0.1

DeathMarkFix.dll

Decompiled 7 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;

[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("DeathMarkFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DeathMarkFix")]
[assembly: AssemblyTitle("DeathMarkFix")]
[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 DeathMarkFix
{
	[BepInPlugin("OakPrime.DeathMarkFix", "DeathMarkFix", "1.0.1")]
	public class DeathMarkFix : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

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

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

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

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

			public static Manipulator <>9__5_0;

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

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

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

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

			public static Manipulator <>9__5_1;

			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_00b2: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				ILLabel val3 = default(ILLabel);
				int num = default(int);
				ILLabel val2 = default(ILLabel);
				val.TryGotoNext(new Func<Instruction, bool>[4]
				{
					(Instruction x) => ILPatternMatchingExt.MatchBlt(x, ref val3),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num),
					(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 4),
					(Instruction x) => ILPatternMatchingExt.MatchBlt(x, ref val2)
				});
				val.Index += 2;
				val.Next.OpCode = OpCodes.Ldc_I4_3;
			}

			internal bool <Awake>b__5_2(Instruction x)
			{
				ILLabel val = default(ILLabel);
				return ILPatternMatchingExt.MatchBlt(x, ref val);
			}

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

			internal bool <Awake>b__5_4(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdcI4(x, 4);
			}

			internal bool <Awake>b__5_5(Instruction x)
			{
				ILLabel val = default(ILLabel);
				return ILPatternMatchingExt.MatchBlt(x, ref val);
			}

			internal void <Awake>b__5_1(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				ILCursor val = new ILCursor(il);
				int num2 = default(int);
				int num = default(int);
				val.TryGotoNext(new Func<Instruction, bool>[4]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2),
					(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 1.5f),
					(Instruction x) => ILPatternMatchingExt.MatchMul(x),
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num)
				});
				int index = val.Index;
				val.Index = index + 1;
				val.Next.Operand = 1.35f;
			}

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

			internal bool <Awake>b__5_7(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdcR4(x, 1.5f);
			}

			internal bool <Awake>b__5_8(Instruction x)
			{
				return ILPatternMatchingExt.MatchMul(x);
			}

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

		public const string PluginGUID = "OakPrime.DeathMarkFix";

		public const string PluginAuthor = "OakPrime";

		public const string PluginName = "DeathMarkFix";

		public const string PluginVersion = "1.0.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
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
						ILCursor val4 = new ILCursor(il);
						ILLabel val6 = default(ILLabel);
						int num3 = default(int);
						ILLabel val5 = default(ILLabel);
						val4.TryGotoNext(new Func<Instruction, bool>[4]
						{
							(Instruction x) => ILPatternMatchingExt.MatchBlt(x, ref val6),
							(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num3),
							(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 4),
							(Instruction x) => ILPatternMatchingExt.MatchBlt(x, ref val5)
						});
						val4.Index += 2;
						val4.Next.OpCode = OpCodes.Ldc_I4_3;
					};
					<>c.<>9__5_0 = val;
					obj = (object)val;
				}
				GlobalEventManager.OnHitEnemy += (Manipulator)obj;
				object obj2 = <>c.<>9__5_1;
				if (obj2 == null)
				{
					Manipulator val2 = delegate(ILContext il)
					{
						//IL_0002: Unknown result type (might be due to invalid IL or missing references)
						//IL_0008: Expected O, but got Unknown
						ILCursor val3 = new ILCursor(il);
						int num2 = default(int);
						int num = default(int);
						val3.TryGotoNext(new Func<Instruction, bool>[4]
						{
							(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2),
							(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 1.5f),
							(Instruction x) => ILPatternMatchingExt.MatchMul(x),
							(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num)
						});
						int index = val3.Index;
						val3.Index = index + 1;
						val3.Next.Operand = 1.35f;
					};
					<>c.<>9__5_1 = val2;
					obj2 = (object)val2;
				}
				HealthComponent.TakeDamage += (Manipulator)obj2;
				ReplaceDeathMarkText();
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)(ex.Message + " - " + ex.StackTrace));
			}
		}

		private void ReplaceDeathMarkText()
		{
			ReplaceString("ITEM_DEATHMARK_PICKUP", "Enemies with 3 or more debuffs are marked for death, taking bonus damage.");
			ReplaceString("ITEM_DEATHMARK_DESC", "Enemies with <style=cIsDamage>3</style> or more debuffs are <style=cIsDamage>marked for death</style>, increasing damage taken by <style=cIsDamage>35%</style> from all sources for <style=cIsUtility>7</style> <style=cStack>(+7 per stack)</style> seconds.");
		}

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