Decompiled source of BlightBurstBuff v1.1.0

BlightBurstBuff.dll

Decompiled 3 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 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 = "")]
[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;

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.0")]
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.0";

	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_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_1);
				val.EmitDelegate<Action<DamageInfo, CharacterBody>>((Action<DamageInfo, CharacterBody>)delegate(DamageInfo damageInfo, CharacterBody victim)
				{
					//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_00e7: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f0: 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_00fa: 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_0121: Unknown result type (might be due to invalid IL or missing references)
					//IL_0122: Unknown result type (might be due to invalid IL or missing references)
					//IL_0127: Unknown result type (might be due to invalid IL or missing references)
					//IL_012c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0133: Unknown result type (might be due to invalid IL or missing references)
					//IL_0135: Unknown result type (might be due to invalid IL or missing references)
					//IL_013a: Unknown result type (might be due to invalid IL or missing references)
					//IL_013f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0141: Unknown result type (might be due to invalid IL or missing references)
					//IL_0146: Unknown result type (might be due to invalid IL or missing references)
					//IL_014b: Unknown result type (might be due to invalid IL or missing references)
					//IL_015d: Expected O, but got Unknown
					//IL_0183: Unknown result type (might be due to invalid IL or missing references)
					//IL_0188: Unknown result type (might be due to invalid IL or missing references)
					//IL_018a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0195: Unknown result type (might be due to invalid IL or missing references)
					//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
					//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
					//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
					//IL_01cc: Expected O, but got Unknown
					//IL_007b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0081: Invalid comparison between Unknown and I4
					int buffCount = victim.GetBuffCount(Buffs.Blight);
					if (buffCount >= AcridConfig.targetBuffCount.Value)
					{
						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 = 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);
					}
				});
				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);
	}
}