Decompiled source of EarlyAccessBands v1.0.1

EarlyAccessBands.dll

Decompiled a month 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 R2API;
using R2API.Utils;
using RoR2;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.AddressableAssets;
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("EarlyAccessBands")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ca2d4a826ef30ef7662d7b729fed8df714d9cb30")]
[assembly: AssemblyProduct("EarlyAccessBands")]
[assembly: AssemblyTitle("EarlyAccessBands")]
[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 EarlyAccessBands
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Moffein.EarlyAccessBands", "EarlyAccessBands", "1.0.1")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class EarlyAccessBandsPlugin : BaseUnityPlugin
	{
		public static float iceBaseDamage = 2.5f;

		public static float iceStackDamage = 2.5f;

		public static float fireBaseDamage = 3f;

		public static float fireStackDamage = 3f;

		public static float procChance = 8f;

		public static GameObject iceRingExplosionEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ElementalRings/IceRingExplosion.prefab").WaitForCompletion();

		public static GameObject fireTornadoProjectilePrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ElementalRings/FireTornado.prefab").WaitForCompletion();

		public void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			ReadConfig();
			SetLanguage();
			ElementalRingsBehavior.FixedUpdate += new hook_FixedUpdate(RemoveRingBuff);
			GlobalEventManager.onServerDamageDealt += GlobalEventManager_onServerDamageDealt;
		}

		private void ReadConfig()
		{
			procChance = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Proc Chance", 8f, "Chance for this item to proc.").Value;
			iceBaseDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Runalds Band - Initial Damage", 2.5f, "Damage of the first stack of this item.").Value;
			iceStackDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Runalds Band - Stack Damage", 2.5f, "Damage of extra stacks of this item. Set to 1.25 for the original.").Value;
			fireBaseDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Kjaros Band - Initial Damage", 3f, "Damage of the first stack of this item. Set to 5 for the original. Default is set lower since the original Fire Tornado was a lot smaller than the current one.").Value;
			fireStackDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Kjaros Band - Stack Damage", 3f, "Damage of extra stacks of this item. Set to 2.5 for the original.").Value;
		}

		private void SetLanguage()
		{
			string text = $"<style=cIsDamage>{procChance}%</style> chance on hit to strike an enemy with a <style=cIsDamage>runic ice blast</style>, <style=cIsUtility>slowing</style> them by <style=cIsUtility>80%</style> and dealing <style=cIsDamage>{iceBaseDamage * 100f}%</style> <style=cStack>(+{iceStackDamage * 100f}% per stack)</style> TOTAL damage.";
			string text2 = $"<style=cIsDamage>{procChance}%</style> chance on hit to strike an enemy with a <style=cIsDamage>runic flame tornado</style>, dealing <style=cIsDamage>{fireBaseDamage * 100f}%</style> <style=cStack>(+{fireStackDamage * 100f}% per stack)</style> TOTAL damage.";
			LanguageAPI.Add("ITEM_ICERING_DESC", text);
			LanguageAPI.Add("ITEM_FIRERING_DESC", text2);
			LanguageAPI.Add("ITEM_ICERING_PICKUP", "Chance to blast enemies with runic ice.");
			LanguageAPI.Add("ITEM_FIRERING_PICKUP", "Chance to blast enemies with a runic flame tornado.");
		}

		private void GlobalEventManager_onServerDamageDealt(DamageReport damageReport)
		{
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			if (damageReport.damageInfo.rejected || damageReport.damageInfo.procCoefficient <= 0f || !Object.op_Implicit((Object)(object)damageReport.attackerBody) || !Object.op_Implicit((Object)(object)damageReport.victimBody) || ((ProcChainMask)(ref damageReport.damageInfo.procChainMask)).HasProc((ProcType)12))
			{
				return;
			}
			CharacterBody attackerBody = damageReport.attackerBody;
			int itemCount = attackerBody.inventory.GetItemCount(Items.IceRing);
			int itemCount2 = attackerBody.inventory.GetItemCount(Items.FireRing);
			DamageInfo damageInfo = damageReport.damageInfo;
			if (itemCount + itemCount2 <= 0 || !Util.CheckRoll(procChance * damageInfo.procCoefficient, attackerBody.master))
			{
				return;
			}
			((ProcChainMask)(ref damageInfo.procChainMask)).AddProc((ProcType)12);
			CharacterBody victimBody = damageReport.victimBody;
			if (itemCount > 0)
			{
				float num = iceBaseDamage + (float)(itemCount - 1) * iceStackDamage;
				float damage = Util.OnHitProcDamage(damageInfo.damage, attackerBody.damage, num);
				DamageInfo val = new DamageInfo
				{
					damage = damage,
					damageColorIndex = (DamageColorIndex)3,
					damageType = DamageTypeCombo.op_Implicit((DamageType)0),
					attacker = damageInfo.attacker,
					crit = damageInfo.crit,
					force = Vector3.zero,
					inflictor = null,
					position = damageInfo.position,
					procChainMask = damageInfo.procChainMask,
					procCoefficient = 1f
				};
				EffectManager.SimpleImpactEffect(iceRingExplosionEffectPrefab, damageInfo.position, Vector3.up, true);
				victimBody.AddTimedBuff(Buffs.Slow80, 3f * (float)itemCount);
				victimBody.healthComponent.TakeDamage(val);
			}
			if (itemCount2 > 0)
			{
				GameObject val2 = fireTornadoProjectilePrefab;
				float resetInterval = val2.GetComponent<ProjectileOverlapAttack>().resetInterval;
				float lifetime = val2.GetComponent<ProjectileSimple>().lifetime;
				float num2 = fireBaseDamage + (float)(itemCount2 - 1) * fireStackDamage;
				float damage2 = Util.OnHitProcDamage(damageInfo.damage, attackerBody.damage, num2) / lifetime * resetInterval;
				float speedOverride = 0f;
				Quaternion rotation = Quaternion.identity;
				Vector3 val3 = damageInfo.position - attackerBody.aimOrigin;
				val3.y = 0f;
				if (val3 != Vector3.zero)
				{
					speedOverride = -1f;
					rotation = Util.QuaternionSafeLookRotation(val3, Vector3.up);
				}
				ProjectileManager instance = ProjectileManager.instance;
				FireProjectileInfo val4 = new FireProjectileInfo
				{
					damage = damage2,
					crit = damageInfo.crit,
					damageColorIndex = (DamageColorIndex)3,
					position = damageInfo.position,
					procChainMask = damageInfo.procChainMask,
					force = 0f,
					owner = damageInfo.attacker,
					projectilePrefab = val2,
					rotation = rotation
				};
				((FireProjectileInfo)(ref val4)).speedOverride = speedOverride;
				val4.target = null;
				instance.FireProjectile(val4);
			}
		}

		private void RemoveRingBuff(orig_FixedUpdate orig, ElementalRingsBehavior self)
		{
			if (NetworkServer.active)
			{
				if (((ItemBehavior)self).body.HasBuff(Buffs.ElementalRingsReady))
				{
					((ItemBehavior)self).body.RemoveBuff(Buffs.ElementalRingsReady);
				}
				if (((ItemBehavior)self).body.HasBuff(Buffs.ElementalRingsCooldown))
				{
					((ItemBehavior)self).body.ClearTimedBuffs(Buffs.ElementalRingsCooldown);
				}
				Object.Destroy((Object)(object)this);
			}
		}
	}
}