Decompiled source of BlightBuffDeluxe v3.0.0

BlightBuffDeluxe.dll

Decompiled a month ago
using System;
using System.Collections.ObjectModel;
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 Microsoft.CodeAnalysis;
using On.RoR2;
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("BlightBuffDeluxe")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BlightBuffDeluxe")]
[assembly: AssemblyTitle("BlightBuffDeluxe")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 BlightBuffDeluxe
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("aanon.BlightBuffDeluxe", "BlightBuffDeluxe", "3.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "aanon.BlightBuffDeluxe";

		public const string PluginAuthor = "aanon";

		public const string PluginName = "BlightBuffDeluxe";

		public const string PluginVersion = "3.0.0";

		public static BuffDef blightOnHit;

		public void Awake()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			blightOnHit = ScriptableObject.CreateInstance<BuffDef>();
			blightOnHit.canStack = true;
			blightOnHit.isHidden = true;
			blightOnHit.isDebuff = true;
			blightOnHit.isDOT = true;
			blightOnHit.isCooldown = false;
			ContentAddition.AddBuffDef(blightOnHit);
			DamageInfo.ModifyDamageInfo += new hook_ModifyDamageInfo(DamageInfo_ModifyDamageInfo);
			DotController.onDotInflictedServerGlobal += new OnDotInflictedServerGlobalDelegate(DotController_onDotInflictedServerGlobal);
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
		}

		private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
		{
			if (sender.HasBuff(blightOnHit))
			{
				args.armorAdd -= 10f * (float)sender.GetBuffCount(blightOnHit);
				args.attackSpeedMultAdd -= 0.05f * (float)sender.GetBuffCount(blightOnHit);
				args.baseCurseAdd += 5f * (sender.level - 1f) * (float)sender.GetBuffCount(blightOnHit);
				args.baseRegenAdd -= 0.2f * (sender.level - 1f) * (float)sender.GetBuffCount(blightOnHit);
				args.damageMultAdd -= 0.05f * (float)sender.GetBuffCount(blightOnHit);
				args.moveSpeedReductionMultAdd += 0.1f * (float)sender.GetBuffCount(blightOnHit);
			}
		}

		private void DamageInfo_ModifyDamageInfo(orig_ModifyDamageInfo orig, DamageInfo self, DamageModifier damageModifier)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)self.attacker) && !((ProcChainMask)(ref self.procChainMask)).HasProc((ProcType)0) && DamageTypeCombo.op_Implicit(self.damageType & DamageTypeCombo.op_Implicit((DamageType)1048576)) != 0)
			{
				self.procCoefficient = 0.5f;
				self.procChainMask = default(ProcChainMask);
			}
			orig.Invoke(self, damageModifier);
		}

		private void DotController_onDotInflictedServerGlobal(DotController dotController, ref InflictDotInfo inflictDotInfo)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			if ((int)inflictDotInfo.dotIndex != 5)
			{
				return;
			}
			GameObject victimObject = inflictDotInfo.victimObject;
			GameObject attackerObject = inflictDotInfo.attackerObject;
			if (!Object.op_Implicit((Object)(object)victimObject) || !Object.op_Implicit((Object)(object)attackerObject))
			{
				return;
			}
			CharacterBody component = victimObject.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			component.AddBuff(blightOnHit);
			inflictDotInfo.duration = (1f + (float)dotController.dotStackList.Count) * (float)component.GetBuffCount(blightOnHit);
			inflictDotInfo.damageMultiplier = (1f + (float)dotController.dotStackList.Count) * (float)component.GetBuffCount(blightOnHit);
			inflictDotInfo.totalDamage = (1f + (float)dotController.dotStackList.Count) * (float)component.GetBuffCount(blightOnHit);
			if (Util.CheckRoll(10f, 0f, (CharacterMaster)null) && (Object)(object)component.healthComponent != (Object)null)
			{
				DamageInfo val = new DamageInfo();
				val.damage = inflictDotInfo.damageMultiplier * inflictDotInfo.totalDamage.Value;
				val.inflictor = inflictDotInfo.attackerObject;
				val.attacker = inflictDotInfo.attackerObject;
				val.crit = true;
				val.procCoefficient = 2f;
				val.force = new Vector3(0f, 6000f, 0f);
				val.position = dotController.victimBody.corePosition;
				val.procChainMask = default(ProcChainMask);
				val.damageColorIndex = (DamageColorIndex)4;
				val.rejected = false;
				DamageReport val2 = new DamageReport(val, component.healthComponent, inflictDotInfo.damageMultiplier * inflictDotInfo.totalDamage.Value, component.healthComponent.combinedHealth);
				GlobalEventManager.instance.OnCharacterDeath(val2);
				CharacterBody component2 = attackerObject.GetComponent<CharacterBody>();
				if ((Object)(object)component2 != (Object)null)
				{
					Inventory inventory = component2.inventory;
					if ((Object)(object)inventory != (Object)null)
					{
						inventory.GiveItem(Items.ScrapWhite, 1);
					}
					foreach (TimedBuff timedBuff in component2.timedBuffs)
					{
						timedBuff.timer += 2f;
					}
				}
			}
			uint num = (uint)(3f * Run.instance.difficultyCoefficient);
			int num2 = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.livingPlayerCount : 0);
			if (num2 != 0)
			{
				num = (uint)Mathf.CeilToInt((float)num / (float)num2);
			}
			ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers((TeamIndex)1);
			for (int i = 0; i < teamMembers.Count; i++)
			{
				CharacterBody component3 = ((Component)teamMembers[i]).GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component3) && component3.isPlayerControlled)
				{
					CharacterMaster master = component3.master;
					if (Object.op_Implicit((Object)(object)master))
					{
						master.GiveMoney(num);
					}
				}
			}
		}
	}
}