Decompiled source of BlightBurstBuff v1.1.1

BlightBurstBuff.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.Configuration;
using BepInEx.Logging;
using IL.RoR2;
using Microsoft.CodeAnalysis;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BlightBurstBuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7c06212da51d9052becf7cdd1459972dc54c1676")]
[assembly: AssemblyProduct("BlightBurstBuff")]
[assembly: AssemblyTitle("BlightBurstBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 BlightBurstBuff
{
	internal static class AcridConfig
	{
		public static ConfigEntry<int> targetBuffCount;

		public static ConfigEntry<float> procCoeff;

		public static ConfigEntry<bool> canCrit;

		public static void InitializeConfig()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			ConfigFile val = new ConfigFile(Paths.ConfigPath + "\\OakPrime.BlightBurstBuff.cfg", true);
			targetBuffCount = val.Bind<int>("Main", "Blight Burst Stack Count", 3, "Stack count at which blight bursts");
			procCoeff = val.Bind<float>("Main", "Proc Coefficient", 1f, "Proc coefficient of burst");
			canCrit = val.Bind<bool>("Main", "Burst Can Crit", true, "If burst damage can crit");
		}
	}
	[BepInPlugin("OakPrime.BlightBurstBuff", "BlightBurstBuff", "1.1.1")]
	public class BlightBurstBuff : BaseUnityPlugin
	{
		public const string PluginGUID = "OakPrime.BlightBurstBuff";

		public const string PluginAuthor = "OakPrime";

		public const string PluginName = "BlightBurstBuff";

		public const string PluginVersion = "1.1.1";

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

		public void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			try
			{
				Log.Init(((BaseUnityPlugin)this).Logger);
				AcridConfig.InitializeConfig();
				GlobalEventManager.ProcessHitEnemy += (Manipulator)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_00bb: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
					ILCursor val = new ILCursor(il);
					DotController val2 = default(DotController);
					float num = default(float);
					if (!val.TryGotoNext(new Func<Instruction, bool>[1]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1048576)
					}))
					{
						Log.LogInstrNotFound(il);
					}
					else if (!val.TryGotoNext(new Func<Instruction, bool>[2]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num),
						(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val2)
					}))
					{
						Log.LogInstrNotFound(il);
					}
					else
					{
						val.Index += 2;
						val.Emit(OpCodes.Ldarg_1);
						val.Emit(OpCodes.Ldloc_0);
						val.EmitDelegate<Action<DamageInfo, CharacterBody>>((Action<DamageInfo, CharacterBody>)delegate(DamageInfo damageInfo, CharacterBody victim)
						{
							//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
							//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
							//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
							//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
							//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
							//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_00df: Unknown result type (might be due to invalid IL or missing references)
							//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
							//IL_0106: Unknown result type (might be due to invalid IL or missing references)
							//IL_0107: Unknown result type (might be due to invalid IL or missing references)
							//IL_010c: Unknown result type (might be due to invalid IL or missing references)
							//IL_0111: Unknown result type (might be due to invalid IL or missing references)
							//IL_0118: Unknown result type (might be due to invalid IL or missing references)
							//IL_011a: Unknown result type (might be due to invalid IL or missing references)
							//IL_011f: Unknown result type (might be due to invalid IL or missing references)
							//IL_0124: Unknown result type (might be due to invalid IL or missing references)
							//IL_0126: Unknown result type (might be due to invalid IL or missing references)
							//IL_012b: Unknown result type (might be due to invalid IL or missing references)
							//IL_0130: Unknown result type (might be due to invalid IL or missing references)
							//IL_0142: Expected O, but got Unknown
							//IL_0168: Unknown result type (might be due to invalid IL or missing references)
							//IL_016d: Unknown result type (might be due to invalid IL or missing references)
							//IL_016f: Unknown result type (might be due to invalid IL or missing references)
							//IL_017a: Unknown result type (might be due to invalid IL or missing references)
							//IL_018c: Unknown result type (might be due to invalid IL or missing references)
							//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
							//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
							//IL_01b1: Expected O, but got Unknown
							//IL_0063: Unknown result type (might be due to invalid IL or missing references)
							//IL_0069: Invalid comparison between Unknown and I4
							int buffCount = victim.GetBuffCount(Buffs.Blight);
							if (buffCount >= AcridConfig.targetBuffCount.Value)
							{
								val2 = DotController.FindDotController(((Component)victim).gameObject);
								num = 0f;
								if (Object.op_Implicit((Object)(object)val2))
								{
									for (int num2 = val2.dotStackList.Count - 1; num2 >= 0; num2--)
									{
										if ((int)val2.dotStackList[num2].dotIndex == 5)
										{
											DotStack val3 = val2.dotStackList[num2];
											num += val3.damage / val3.dotDef.interval * val3.timer;
											val2.RemoveDotStackAtServer(num2);
										}
									}
								}
								DamageInfo val4 = new DamageInfo
								{
									damage = num,
									damageColorIndex = (DamageColorIndex)4,
									damageType = DamageTypeCombo.op_Implicit((DamageType)0),
									attacker = damageInfo.attacker,
									crit = (AcridConfig.canCrit.Value && damageInfo.crit),
									force = Vector3.zero,
									inflictor = null,
									position = damageInfo.position,
									procChainMask = damageInfo.procChainMask,
									procCoefficient = AcridConfig.procCoeff.Value
								};
								GlobalEventManager.instance.OnHitEnemy(val4, ((Component)victim).gameObject);
								victim.healthComponent.TakeDamage(val4);
								EffectManager.SpawnEffect(CommonAssets.igniteOnKillExplosionEffectPrefab, new EffectData
								{
									origin = victim.corePosition,
									scale = 12f + victim.radius,
									rotation = new Quaternion(0f, 0f, 0f, 1f)
								}, true);
								Util.PlaySound("Play_acrid_shift_land", ((Component)victim).gameObject);
							}
						});
						ReplaceText();
					}
				};
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)(ex.Message + " - " + ex.StackTrace));
			}
		}

		private void ReplaceText()
		{
			ReplaceString("CROCO_PASSIVE_ALT_DESCRIPTION", "Attacks that apply <style=cIsHealing>Poison</style> apply stacking <style=cIsDamage>Blight</style> instead, dealing <style=cIsDamage>60% damage per second</style>. Reaching <style=cIsDamage>3</style> stacks deals the remaining damage at once.");
		}

		private void ReplaceString(string token, string newText)
		{
			DefaultLanguage[token] = Language.GetString(token);
			LanguageAPI.Add(token, newText);
		}
	}
	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);
		}

		internal static void LogInstrNotFound(ILContext il)
		{
			LogError("GoToNext instructions not found at method: " + (object)il.Method);
		}
	}
}