Decompiled source of BetterVoidBands v1.0.0

BetterVoidBands.dll

Decompiled 5 hours ago
using System;
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 On.RoR2;
using R2API;
using RoR2;
using RoR2.Projectile;
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("ExamplePlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExamplePlugin")]
[assembly: AssemblyTitle("ExamplePlugin")]
[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 ExamplePlugin
{
	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);
		}
	}
}
namespace myVoidBandTweaks
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("IrrationalIntegral.myVoidBandTweaks", "myVoidBandTweaks", "1.0.0")]
	public class myVoidBandTweaks : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_ProcessHitEnemy <0>__OnProcessHitEnemy;

			public static Manipulator <1>__IlProcessHitEnemy;
		}

		public const string PluginGUID = "IrrationalIntegral.myVoidBandTweaks";

		public const string PluginAuthor = "IrrationalIntegral";

		public const string PluginName = "myVoidBandTweaks";

		public const string PluginVersion = "1.0.0";

		public static float BlackHoleCooldown;

		public static float BlackHoleDuration;

		public static float BlackHoleDamage;

		public static float BlackHoleDOT;

		public static float BlackHoleBaseRadius;

		public static float BlackHoleRadiusPerStack;

		public static float BlackHoleBasePull;

		public static float BlackHolePullForcePerStack;

		public void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			LoadConfig();
			object obj = <>O.<0>__OnProcessHitEnemy;
			if (obj == null)
			{
				hook_ProcessHitEnemy val = OnProcessHitEnemy;
				<>O.<0>__OnProcessHitEnemy = val;
				obj = (object)val;
			}
			GlobalEventManager.ProcessHitEnemy += (hook_ProcessHitEnemy)obj;
			object obj2 = <>O.<1>__IlProcessHitEnemy;
			if (obj2 == null)
			{
				Manipulator val2 = IlProcessHitEnemy;
				<>O.<1>__IlProcessHitEnemy = val2;
				obj2 = (object)val2;
			}
			GlobalEventManager.ProcessHitEnemy += (Manipulator)obj2;
		}

		private static void OnProcessHitEnemy(orig_ProcessHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			//IL_00e6: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, damageInfo, victim);
			if (!Object.op_Implicit((Object)(object)damageInfo.attacker))
			{
				return;
			}
			CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
			CharacterMaster master = component.master;
			if (!Object.op_Implicit((Object)(object)master))
			{
				return;
			}
			Inventory inventory = master.inventory;
			if (Object.op_Implicit((Object)(object)damageInfo.attacker) && damageInfo.procCoefficient > 0f && !((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)12) && damageInfo.damage / component.damage >= 4f && component.HasBuff(Buffs.ElementalRingVoidReady))
			{
				int itemCount = inventory.GetItemCount(Items.ElementalRingVoid);
				component.RemoveBuff(Buffs.ElementalRingVoidReady);
				for (int i = 1; (float)i <= BlackHoleCooldown; i++)
				{
					component.AddTimedBuff(Buffs.ElementalRingVoidCooldown, (float)i);
				}
				ProcChainMask procChainMask = damageInfo.procChainMask;
				((ProcChainMask)(ref procChainMask)).AddProc((ProcType)12);
				if (itemCount > 0)
				{
					GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/ElementalRingVoidBlackHole");
					GameObject val2 = LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/FireTornado");
					GameObject val3 = Object.Instantiate<GameObject>(val2);
					val3.GetComponent<ProjectileController>().ghostPrefab = null;
					float resetInterval = val3.GetComponent<ProjectileOverlapAttack>().resetInterval;
					float num = BlackHoleDamage * (float)itemCount;
					float num2 = BlackHoleDOT * (float)itemCount;
					float damage = Util.OnHitProcDamage(damageInfo.damage, component.damage, num);
					float damage2 = Util.OnHitProcDamage(damageInfo.damage, component.damage, num2) / BlackHoleDuration * resetInterval;
					val.GetComponent<ProjectileFuse>().fuse = BlackHoleDuration;
					val3.GetComponent<ProjectileSimple>().lifetime = BlackHoleDuration;
					float num3 = (BlackHoleBaseRadius + BlackHoleRadiusPerStack * (float)(itemCount - 1)) / 15f;
					val.transform.localScale = new Vector3(num3, num3, num3);
					val3.transform.localScale = new Vector3(num3, num3, num3);
					val.GetComponent<ProjectileExplosion>().blastRadius = BlackHoleBaseRadius + BlackHoleRadiusPerStack + (float)(itemCount - 1);
					val.GetComponent<RadialForce>().radius = BlackHoleBaseRadius + BlackHoleRadiusPerStack + (float)(itemCount - 1);
					val.GetComponent<RadialForce>().forceMagnitude = 0f - (BlackHoleBasePull * 100f + BlackHolePullForcePerStack * 10f * (float)(itemCount - 1));
					((Component)val3.GetComponent<ProjectileOverlapAttack>()).transform.localScale = new Vector3(num3, num3, num3);
					ProjectileManager.instance.FireProjectile(new FireProjectileInfo
					{
						damage = damage,
						crit = damageInfo.crit,
						damageColorIndex = (DamageColorIndex)9,
						position = damageInfo.position,
						procChainMask = procChainMask,
						force = 6000f,
						owner = damageInfo.attacker,
						projectilePrefab = val,
						rotation = Quaternion.identity,
						target = null
					});
					ProjectileManager.instance.FireProjectile(new FireProjectileInfo
					{
						damage = damage2,
						crit = damageInfo.crit,
						damageColorIndex = (DamageColorIndex)9,
						position = damageInfo.position,
						procChainMask = procChainMask,
						force = 0f,
						owner = damageInfo.attacker,
						projectilePrefab = val3,
						rotation = Quaternion.identity,
						target = null
					});
				}
			}
		}

		private static void IlProcessHitEnemy(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel val2 = val.DefineLabel();
			ILLabel val3 = default(ILLabel);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "RoR2.DLC1Content/Buffs", "ElementalRingVoidReady"),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, "RoR2.CharacterBody", "HasBuff"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val3)
			}))
			{
				val.Index += 4;
				val.Emit(OpCodes.Br, (object)val2);
				if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 5)
				}))
				{
					val.MarkLabel(val2);
				}
			}
			else
			{
				Debug.LogWarning((object)"Failed to apply ProcessHitEnemy il Hook");
			}
		}

		private void UpdateText()
		{
			ReplaceString("ITEM_ELEMENTALRINGVOID_DESC", "Hits that deal <style=cIsDamage>More than 400% Damage</style> also fire a black hole that <style=cIsUtility>draws enemies within 15m into its center.</style> Lasts <style=cIsUtility>" + d(BlackHoleDuration) + "</style> seconds before collapsing. Dealing <style=cIsDamage>" + d(BlackHoleDOT) + "</style> <style=cStack>(+" + d(BlackHoleDOT) + " per stack)</style> TOTAL damage over time. Plus an additional <style=cIsDamage>" + d(BlackHoleDamage) + "</style> <style=cStack>(+" + d(BlackHoleDamage) + " per stack)</style> TOTAL damage when collapsing. Recharges every <style=cIsUtility>" + d(BlackHoleCooldown) + "</style> seconds. <style=cIsVoid>Corrupts all Runand's and Kjaro's Bands</style>.");
		}

		private void ReplaceString(string token, string newText)
		{
			LanguageAPI.Add(token, newText);
		}

		public static string d(float dmgMod)
		{
			return dmgMod * 100f + "%";
		}

		private void LoadConfig()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0030: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0069: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00a2: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00db: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_0114: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_014d: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			//IL_0186: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Expected O, but got Unknown
			//IL_01bf: Expected O, but got Unknown
			BlackHoleDamage = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Singularity Band", "Damage Modifier"), 1f, new ConfigDescription("Modify blackhole damage. Vanilla value: 1", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			BlackHoleDOT = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Singularity Band", "Damage Over Time Modifier"), 1f, new ConfigDescription("Modify blackhole damage. Vanilla value: 1", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			BlackHoleCooldown = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Singularity Band", "Cooldown"), 10f, new ConfigDescription("Modify band cooldown. Vanilla value: 20", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			BlackHoleDuration = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Singularity Band", "Black Hole Duration"), 3f, new ConfigDescription("Modify blackhole duration. Vanilla value: 5", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			BlackHoleBaseRadius = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Singularity Band", "Black Hole Radius"), 12f, new ConfigDescription("Modify blackhole radius. Vanilla value: 15", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			BlackHoleRadiusPerStack = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Singularity Band", "Black Hole Radius Increase Per Stack"), 2f, new ConfigDescription("Modify blackhole radius increment per stack. Default value: 2", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			BlackHoleBasePull = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Singularity Band", "Black Hole Pull Force"), 10f, new ConfigDescription("Modify blackhole pull force. Default value: 10", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			BlackHolePullForcePerStack = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Singularity Band", "Black Hole Pull Force Increase Per Stack"), 5f, new ConfigDescription("Modify blackhole pull force increment per stack. Default value: 5", (AcceptableValueBase)null, Array.Empty<object>())).Value;
		}
	}
}