Decompiled source of Firestorm v1.0.3

Firestorm.dll

Decompiled 4 days 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 EntityStates;
using EntityStates.Mage.Weapon;
using Microsoft.CodeAnalysis;
using On.EntityStates.Mage.Weapon;
using R2API;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("Firestorm")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Firestorm")]
[assembly: AssemblyTitle("Firestorm")]
[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 Firestorm
{
	public class ChargeFireBomb : BaseChargeBombState
	{
		public override BaseThrowBombState GetNextState()
		{
			return (BaseThrowBombState)(object)new ThrowFireBomb();
		}
	}
	public class ChargeFireMeteor : BaseState
	{
		public static float baseChargeDuration = 1.5f;

		public static float baseDuration = 1.5f;

		public static GameObject areaIndicatorPrefab;

		public static float minMeteorRadius = 0f;

		public static float maxMeteorRadius = 10f;

		public static GameObject meteorEffect = Firestorm.meteorEffect;

		public static float maxDamageCoefficient = 25f;

		public static float procCoefficient;

		public static float force;

		public static GameObject muzzleflashEffect;

		private float stopwatch;

		private GameObject areaIndicatorInstance;

		private bool fireMeteor;

		private float radius;

		private float chargeDuration;

		private float duration;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			chargeDuration = baseChargeDuration / base.attackSpeedStat;
			duration = baseDuration / base.attackSpeedStat;
			((EntityState)this).PlayAnimation("Gesture, Additive", "PrepWall", "PrepWall.playbackRate", duration);
			Util.PlayAttackSpeedSound("Play_captain_utility_variant_preImpact", ((EntityState)this).gameObject, base.attackSpeedStat);
			UpdateAreaIndicator();
		}

		private void UpdateAreaIndicator()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)areaIndicatorInstance))
			{
				float num = 1000f;
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(((BaseState)this).GetAimRay(), ref val, num, LayerMask.op_Implicit(CommonMasks.bullet)))
				{
					HurtBox component = ((Component)((RaycastHit)(ref val)).collider).GetComponent<HurtBox>();
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.healthComponent) && Object.op_Implicit((Object)(object)component.healthComponent.body))
					{
						if ((Object)(object)component.healthComponent.body != (Object)(object)((EntityState)this).characterBody)
						{
							areaIndicatorInstance.transform.position = ((RaycastHit)(ref val)).point;
							areaIndicatorInstance.transform.up = ((RaycastHit)(ref val)).normal;
						}
					}
					else
					{
						areaIndicatorInstance.transform.position = ((RaycastHit)(ref val)).point;
						areaIndicatorInstance.transform.up = ((RaycastHit)(ref val)).normal;
					}
				}
			}
			else
			{
				areaIndicatorInstance = Object.Instantiate<GameObject>(ChargeMeteor.areaIndicatorPrefab);
			}
			radius = Util.Remap(Mathf.Clamp01(stopwatch / chargeDuration), 0f, 1f, minMeteorRadius, maxMeteorRadius);
			areaIndicatorInstance.transform.localScale = new Vector3(radius, radius, radius);
		}

		public override void Update()
		{
			((EntityState)this).Update();
			UpdateAreaIndicator();
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			stopwatch += Time.fixedDeltaTime;
			if ((!((double)stopwatch < (double)duration) || ((ButtonState)(ref ((EntityState)this).inputBank.skill2)).justReleased) && ((EntityState)this).isAuthority)
			{
				fireMeteor = true;
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override void OnExit()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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)
			EffectManager.SimpleMuzzleFlash(ChargeMeteor.muzzleflashEffect, ((EntityState)this).gameObject, "Muzzle", false);
			if (Object.op_Implicit((Object)(object)areaIndicatorInstance))
			{
				if (fireMeteor)
				{
					((EntityState)this).PlayAnimation("Gesture, Additive", "FireWall");
					EffectManager.SpawnEffect(meteorEffect, new EffectData
					{
						origin = areaIndicatorInstance.transform.position,
						scale = radius
					}, true);
					BlastAttack val = new BlastAttack
					{
						radius = radius,
						procCoefficient = ChargeMeteor.procCoefficient,
						position = areaIndicatorInstance.transform.position,
						attacker = ((EntityState)this).gameObject,
						crit = Util.CheckRoll(((EntityState)this).characterBody.crit, ((EntityState)this).characterBody.master),
						baseDamage = ((EntityState)this).characterBody.damage * maxDamageCoefficient,
						falloffModel = (FalloffModel)2,
						baseForce = 3000f
					};
					val.teamIndex = TeamComponent.GetObjectTeam(val.attacker);
					val.Fire();
				}
				else
				{
					((EntityState)this).PlayCrossfade("Gesture, Additive", "BufferEmpty", 0.2f);
				}
				EntityState.Destroy((Object)(object)areaIndicatorInstance.gameObject);
			}
			else
			{
				((EntityState)this).PlayCrossfade("Gesture, Additive", "BufferEmpty", 0.2f);
			}
			((EntityState)this).OnExit();
		}
	}
	[BepInPlugin("com.Nuxlar.Firestorm", "Firestorm", "1.0.3")]
	public class Firestorm : BaseUnityPlugin
	{
		private GameObject fireMuzzleFlash = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mage/MuzzleflashMageFire.prefab").WaitForCompletion();

		private static GameObject fireBombChargeEffect = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Junk/Mage/ChargeMageFireBomb.prefab").WaitForCompletion();

		private static GameObject fireBombExplosionEffect = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/VFX/OmniExplosionVFX.prefab").WaitForCompletion(), "FireBombExplosion", false);

		private static GameObject fireBombGhost = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Junk/Mage/ChargeMageFireBomb.prefab").WaitForCompletion(), "FireBombCore", false);

		private static GameObject fireBombGhost2 = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Drones/PaladinRocketGhost.prefab").WaitForCompletion(), "FireBombGhost2", false);

		private static GameObject fireBombProjectile = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Toolbot/ToolbotGrenadeLauncherProjectile.prefab").WaitForCompletion(), "FireBombProjectile", true);

		private static SkillDef ionSecondarySkillDef = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Mage/MageBodyNovaBomb.asset").WaitForCompletion();

		private static SkillDef flamethrowerSkillDef = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Mage/MageBodyFlamethrower.asset").WaitForCompletion();

		public static GameObject meteorEffect = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Captain/CaptainAirstrikeAltImpact.prefab").WaitForCompletion(), "FireMeteorEffect", false);

		private static SkillDef fireBombSkillDef = ScriptableObject.CreateInstance<SkillDef>();

		private static SkillDef fireMeteorSkillDef = ScriptableObject.CreateInstance<SkillDef>();

		private GameObject arti = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mage/MageBody.prefab").WaitForCompletion();

		private Mesh meteorMesh = Addressables.LoadAssetAsync<Mesh>((object)"RoR2/Base/mdlMeteor.fbx").WaitForCompletion();

		private Material meteorMat = new Material(Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/matMeteorPurple.mat").WaitForCompletion());

		private Material fireBombMat3 = new Material(Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Mage/matMageMatrixTriFire.mat").WaitForCompletion());

		public void Awake()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Expected O, but got Unknown
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Expected O, but got Unknown
			bool flag = default(bool);
			ContentAddition.AddEntityState<ChargeFireMeteor>(ref flag);
			ContentAddition.AddEntityState<ChargeFireBomb>(ref flag);
			ContentAddition.AddEntityState<ThrowFireBomb>(ref flag);
			ContentAddition.AddEffect(fireBombExplosionEffect);
			ContentAddition.AddEffect(meteorEffect);
			((Component)meteorEffect.transform.GetChild(2)).gameObject.SetActive(false);
			ShakeEmitter[] components = meteorEffect.GetComponents<ShakeEmitter>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.Destroy((Object)(object)components[i]);
			}
			Transform child = meteorEffect.transform.GetChild(1).GetChild(0);
			child.localScale = Vector3.one;
			((Component)child).GetComponent<MeshFilter>().mesh = meteorMesh;
			((Renderer)((Component)fireBombExplosionEffect.transform.GetChild(9)).GetComponent<ParticleSystemRenderer>()).material = fireBombMat3;
			fireBombExplosionEffect.GetComponent<EffectComponent>().soundName = "Play_MULT_m1_grenade_launcher_explo";
			Object.Destroy((Object)(object)fireBombGhost.GetComponent<ObjectScaleCurve>());
			fireBombGhost.transform.localScale = new Vector3(2f, 2f, 2f);
			fireBombGhost2.transform.localScale = new Vector3(2f, 2f, 2f);
			fireBombGhost.transform.parent = fireBombGhost2.transform;
			fireBombGhost.transform.localPosition = new Vector3(0f, 0f, 0.5f);
			fireBombProjectile.transform.localScale = new Vector3(2f, 2f, 2f);
			ProjectileDamage component = fireBombProjectile.GetComponent<ProjectileDamage>();
			component.damageType = (DamageType)(component.damageType | 0x80);
			fireBombProjectile.GetComponent<ProjectileController>().ghostPrefab = fireBombGhost2;
			fireBombProjectile.GetComponent<ProjectileImpactExplosion>().impactEffect = fireBombExplosionEffect;
			ContentAddition.AddProjectile(fireBombProjectile);
			CreateFireSecondary();
			CreateFireSpecial();
			SkillFamily skillFamily = arti.GetComponent<SkillLocator>().secondary.skillFamily;
			Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
			Variant[] variants = skillFamily.variants;
			int num = skillFamily.variants.Length - 1;
			Variant val = new Variant
			{
				skillDef = fireBombSkillDef
			};
			((Variant)(ref val)).viewableNode = new Node(fireBombSkillDef.skillNameToken, false, (Node)null);
			variants[num] = val;
			SkillFamily skillFamily2 = arti.GetComponent<SkillLocator>().special.skillFamily;
			Array.Resize(ref skillFamily2.variants, skillFamily2.variants.Length + 1);
			Variant[] variants2 = skillFamily2.variants;
			int num2 = skillFamily2.variants.Length - 1;
			val = new Variant
			{
				skillDef = fireMeteorSkillDef
			};
			((Variant)(ref val)).viewableNode = new Node(fireMeteorSkillDef.skillNameToken, false, (Node)null);
			variants2[num2] = val;
			BaseChargeBombState.OnEnter += new hook_OnEnter(CheckValues1);
			BaseThrowBombState.OnEnter += new hook_OnEnter(CheckValues2);
		}

		private void CheckValues1(orig_OnEnter orig, BaseChargeBombState self)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (self is ChargeFireBomb)
			{
				self.chargeEffectPrefab = fireBombChargeEffect;
				self.chargeSoundString = Flamethrower.endAttackSoundString;
				self.baseDuration = 1.5f;
				self.minBloomRadius = 0.1f;
				self.maxBloomRadius = 0.5f;
				self.crosshairOverridePrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mage/MageCrosshair.prefab").WaitForCompletion();
				self.minChargeDuration = 0.5f;
			}
			orig.Invoke(self);
		}

		private void CheckValues2(orig_OnEnter orig, BaseThrowBombState self)
		{
			if (self is ThrowFireBomb)
			{
				self.projectilePrefab = fireBombProjectile;
				self.muzzleflashEffectPrefab = fireMuzzleFlash;
				self.baseDuration = 0.4f;
				self.minDamageCoefficient = 4f;
				self.maxDamageCoefficient = 16f;
				self.force = 1500f;
				self.selfForce = 500f;
				Util.PlaySound("Play_MULT_m1_grenade_launcher_shoot", ((Component)((EntityState)self).characterBody).gameObject);
			}
			orig.Invoke(self);
		}

		private void CreateFireSecondary()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			fireBombSkillDef.skillName = "FireBomb";
			((Object)fireBombSkillDef).name = "FireBomb";
			fireBombSkillDef.skillNameToken = "Charged Fire-Bomb";
			fireBombSkillDef.skillDescriptionToken = "<style=cIsDamage>Igniting</style>. Charge up an <style=cIsDamage>exploding</style> fire-bomb that deals <style=cIsDamage>400%-1600%</style> damage.";
			fireBombSkillDef.icon = ionSecondarySkillDef.icon;
			fireBombSkillDef.activationState = new SerializableEntityStateType(typeof(ChargeFireBomb));
			fireBombSkillDef.activationStateMachineName = "Weapon";
			fireBombSkillDef.interruptPriority = ionSecondarySkillDef.interruptPriority;
			fireBombSkillDef.baseMaxStock = 1;
			fireBombSkillDef.baseRechargeInterval = 5f;
			fireBombSkillDef.rechargeStock = 1;
			fireBombSkillDef.requiredStock = 1;
			fireBombSkillDef.stockToConsume = 1;
			fireBombSkillDef.dontAllowPastMaxStocks = true;
			fireBombSkillDef.beginSkillCooldownOnSkillEnd = ionSecondarySkillDef.beginSkillCooldownOnSkillEnd;
			fireBombSkillDef.canceledFromSprinting = ionSecondarySkillDef.canceledFromSprinting;
			fireBombSkillDef.forceSprintDuringState = false;
			fireBombSkillDef.fullRestockOnAssign = true;
			fireBombSkillDef.resetCooldownTimerOnUse = false;
			fireBombSkillDef.isCombatSkill = true;
			fireBombSkillDef.mustKeyPress = false;
			fireBombSkillDef.cancelSprintingOnActivation = ionSecondarySkillDef.cancelSprintingOnActivation;
			ContentAddition.AddSkillDef(fireBombSkillDef);
		}

		private void CreateFireSpecial()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			fireMeteorSkillDef.skillName = "FireMeteor";
			((Object)fireMeteorSkillDef).name = "FireMeteor";
			fireMeteorSkillDef.skillNameToken = "Flaming Meteor";
			fireMeteorSkillDef.skillDescriptionToken = "Channel for <style=cIsUtility>1.5 seconds</style> then summon a meteor that deals <style=cIsDamage>2500%</style> damage.";
			fireMeteorSkillDef.icon = flamethrowerSkillDef.icon;
			fireMeteorSkillDef.activationState = new SerializableEntityStateType(typeof(ChargeFireMeteor));
			fireMeteorSkillDef.activationStateMachineName = "Weapon";
			fireMeteorSkillDef.interruptPriority = (InterruptPriority)4;
			fireMeteorSkillDef.baseMaxStock = 1;
			fireMeteorSkillDef.baseRechargeInterval = 12f;
			fireMeteorSkillDef.rechargeStock = 1;
			fireMeteorSkillDef.requiredStock = 1;
			fireMeteorSkillDef.stockToConsume = 1;
			fireMeteorSkillDef.dontAllowPastMaxStocks = true;
			fireMeteorSkillDef.beginSkillCooldownOnSkillEnd = true;
			fireMeteorSkillDef.canceledFromSprinting = true;
			fireMeteorSkillDef.forceSprintDuringState = false;
			fireMeteorSkillDef.fullRestockOnAssign = true;
			fireMeteorSkillDef.resetCooldownTimerOnUse = false;
			fireMeteorSkillDef.isCombatSkill = true;
			fireMeteorSkillDef.mustKeyPress = true;
			fireMeteorSkillDef.cancelSprintingOnActivation = true;
			ContentAddition.AddSkillDef(fireMeteorSkillDef);
		}
	}
	public class ThrowFireBomb : BaseThrowBombState
	{
	}
}