Decompiled source of Cyphers Uncapped Bleed And Crit Stats v1.0.0

UncappedStats.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[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("UncappedStats")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UncappedStats")]
[assembly: AssemblyTitle("UncappedStats")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace UncappedStatsMod
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.YourName.UncappedStats", "Uncapped Stats", "1.0.0")]
	public class UncappedStatsPlugin : BaseUnityPlugin
	{
		public void Awake()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			HealthComponent.TakeDamage += new hook_TakeDamage(UncapCritDamage);
			GlobalEventManager.ProcessHitEnemy += new hook_ProcessHitEnemy(UncapBleedStacks);
		}

		private void UncapCritDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && Object.op_Implicit((Object)(object)damageInfo.attacker) && damageInfo.crit)
			{
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component))
				{
					float crit = component.crit;
					if (crit > 100f)
					{
						float num = (crit - 100f) / 100f;
						int num2 = Mathf.FloorToInt(num);
						float num3 = num - (float)num2;
						float num4 = 1f + (float)num2;
						if (Util.CheckRoll(num3 * 100f, 0f, (CharacterMaster)null))
						{
							num4 += 1f;
						}
						damageInfo.damage *= num4;
						if (num4 > 1f)
						{
							damageInfo.damageColorIndex = (DamageColorIndex)8;
						}
					}
				}
			}
			orig.Invoke(self, damageInfo);
		}

		private void UncapBleedStacks(orig_ProcessHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			//IL_00ed: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, damageInfo, victim);
			if (!NetworkServer.active || damageInfo.procCoefficient == 0f || !Object.op_Implicit((Object)(object)damageInfo.attacker))
			{
				return;
			}
			CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			float bleedChance = component.bleedChance;
			if (!(bleedChance > 100f))
			{
				return;
			}
			float num = bleedChance - 100f;
			float num2 = num * damageInfo.procCoefficient;
			int num3 = 0;
			while (num2 > 0f)
			{
				if (num2 >= 100f)
				{
					num3++;
					num2 -= 100f;
					continue;
				}
				if (Util.CheckRoll(num2, 0f, (CharacterMaster)null))
				{
					num3++;
				}
				break;
			}
			if (num3 > 0)
			{
				InflictDotInfo val = default(InflictDotInfo);
				val.victimObject = victim;
				val.attackerObject = damageInfo.attacker;
				val.dotIndex = (DotIndex)0;
				val.duration = 3f * damageInfo.procCoefficient;
				val.damageMultiplier = 1f;
				InflictDotInfo val2 = val;
				for (int i = 0; i < num3; i++)
				{
					DotController.InflictDot(ref val2);
				}
			}
		}
	}
}