Decompiled source of EarlyAccessBands v1.0.2

EarlyAccessBands.dll

Decompiled 17 hours 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+084784cf6ef92962c559afa1c158f33b37a25f3b")]
[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.2")]
	[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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0135: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: 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_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: 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)
			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 itemCountEffective = attackerBody.inventory.GetItemCountEffective(Items.IceRing);
			int itemCountEffective2 = attackerBody.inventory.GetItemCountEffective(Items.FireRing);
			DamageInfo damageInfo = damageReport.damageInfo;
			if (itemCountEffective + itemCountEffective2 <= 0 || (!((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)26) && !Util.CheckRoll(procChance * damageInfo.procCoefficient, attackerBody.master)))
			{
				return;
			}
			((ProcChainMask)(ref damageInfo.procChainMask)).AddProc((ProcType)12);
			CharacterBody victimBody = damageReport.victimBody;
			if (itemCountEffective > 0)
			{
				float num = iceBaseDamage + (float)(itemCountEffective - 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)itemCountEffective);
				victimBody.healthComponent.TakeDamage(val);
			}
			if (itemCountEffective2 > 0)
			{
				GameObject val2 = fireTornadoProjectilePrefab;
				float resetInterval = val2.GetComponent<ProjectileOverlapAttack>().resetInterval;
				float lifetime = val2.GetComponent<ProjectileSimple>().lifetime;
				float num2 = fireBaseDamage + (float)(itemCountEffective2 - 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);
			}
		}
	}
}