Decompiled source of BlightBurstBuff v1.0.1

BlightBurstBuff.dll

Decompiled 8 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("BlightBurstBuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BlightBurstBuff")]
[assembly: AssemblyTitle("BlightBurstBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BlightBurstBuff;

[BepInPlugin("OakPrime.BlightBurstBuff", "BlightBurstBuff", "1.0.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.0.1";

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

	public void Awake()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		try
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			GlobalEventManager.OnHitEnemy += (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_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				float num5 = default(float);
				int num4 = default(int);
				val.TryGotoNext(new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 5),
					(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num5),
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num4)
				});
				val.Index += 8;
				val.Emit(OpCodes.Ldarg_1);
				val.Emit(OpCodes.Ldloc_2);
				val.EmitDelegate<Action<DamageInfo, CharacterBody>>((Action<DamageInfo, CharacterBody>)delegate(DamageInfo damageInfo, CharacterBody victim)
				{
					//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_00db: Unknown result type (might be due to invalid IL or missing references)
					//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
					//IL_0101: Unknown result type (might be due to invalid IL or missing references)
					//IL_0102: 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_0113: Unknown result type (might be due to invalid IL or missing references)
					//IL_0115: 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_0121: 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_0138: Expected O, but got Unknown
					//IL_006f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0075: Invalid comparison between Unknown and I4
					int buffCount = victim.GetBuffCount(Buffs.Blight);
					if (buffCount > 2)
					{
						float num = damageInfo.attacker.GetComponent<CharacterBody>().damage * 0.6f;
						DotController val2 = DotController.FindDotController(((Component)victim).gameObject);
						float num2 = 0f;
						if (Object.op_Implicit((Object)(object)val2))
						{
							for (int num3 = val2.dotStackList.Count - 1; num3 >= 0; num3--)
							{
								if ((int)val2.dotStackList[num3].dotIndex == 5)
								{
									DotStack val3 = val2.dotStackList[num3];
									num2 += val3.damage / val3.dotDef.interval * val3.timer;
									val2.RemoveDotStackAtServer(num3);
								}
							}
						}
						DamageInfo val4 = new DamageInfo
						{
							damage = num2,
							damageColorIndex = (DamageColorIndex)4,
							damageType = (DamageType)0,
							attacker = damageInfo.attacker,
							crit = damageInfo.crit,
							force = Vector3.zero,
							inflictor = null,
							position = damageInfo.position,
							procChainMask = damageInfo.procChainMask,
							procCoefficient = 1f
						};
						GlobalEventManager.instance.OnHitEnemy(val4, ((Component)victim).gameObject);
						victim.healthComponent.TakeDamage(val4);
					}
				});
				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);
	}
}