Decompiled source of IonSurgeRework v1.0.0

IonSurgeRework.dll

Decompiled 3 weeks 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 EntityStates;
using EntityStates.Mage;
using EntityStates.Mage.Weapon;
using IL.EntityStates.Mage;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.Mage;
using On.EntityStates.Mage.Weapon;
using R2API;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;

[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("IonSurgeRework")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+01dabd3420d0ebc2d2384d3ebc2f1937e0b2f617")]
[assembly: AssemblyProduct("IonSurgeRework")]
[assembly: AssemblyTitle("IonSurgeRework")]
[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 IonSurgeRework
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("HIFU.IonSurgeRework", "IonSurgeRework", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "HIFU.IonSurgeRework";

		public const string PluginAuthor = "HIFU";

		public const string PluginName = "IonSurgeRework";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<float> ionSurgeAoe;

		public static ConfigEntry<float> ionSurgeCooldown;

		public static ConfigEntry<float> ionSurgeDamage;

		public static ConfigEntry<float> ionSurgeDashSpeed;

		public static ConfigEntry<float> ionSurgeDuration;

		public static ConfigEntry<bool> ionSurgeScaleWithSpeed;

		public static ConfigEntry<int> ionSurgeBaseMaxStock;

		public static ConfigEntry<int> ionSurgeRechargeStock;

		public static ConfigEntry<float> flamethrowerDamage;

		public static ConfigEntry<float> flamethrowerIgniteChance;

		public static ConfigEntry<float> flamethrowerRange;

		public static ManualLogSource logger;

		public void Awake()
		{
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Expected O, but got Unknown
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			ionSurgeAoe = ((BaseUnityPlugin)this).Config.Bind<float>("Ion Surge", "Area of Effect", 14f, "Vanilla is 14");
			ionSurgeCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Ion Surge", "Cooldown", 5f, "Vanilla is 8");
			ionSurgeDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Ion Surge", "Damage", 8f, "Decimal. Vanilla is 8");
			ionSurgeDashSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Ion Surge", "Dash Speed Multiplier", 3.5f, "");
			ionSurgeDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Ion Surge", "Skill Duration", 0.3f, "This affects how high you go. Vanilla is 1.66");
			ionSurgeScaleWithSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("Ion Surge", "Make height scale with movement speed?", false, "Vanilla is true");
			ionSurgeBaseMaxStock = ((BaseUnityPlugin)this).Config.Bind<int>("Ion Surge", "Maximum Stock", 1, "");
			ionSurgeRechargeStock = ((BaseUnityPlugin)this).Config.Bind<int>("Ion Surge", "Stock to Recharge", 1, "");
			flamethrowerDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Flamethrower", "Damage", 20f, "Decimal. Vanilla is 20");
			flamethrowerIgniteChance = ((BaseUnityPlugin)this).Config.Bind<float>("Flamethrower", "Ignite Chance", 50f, "Decimal. Vanilla is 50");
			flamethrowerRange = ((BaseUnityPlugin)this).Config.Bind<float>("Flamethrower", "Range", 20f, "Vanilla is 20");
			LanguageAPI.Add("MAGE_SPECIAL_LIGHTNING_DESCRIPTION", "<style=cIsDamage>Stunning</style>. Soar and dash, dealing <style=cIsDamage>" + ionSurgeDamage.Value * 100f + "% damage</style> in a large area." + ((ionSurgeBaseMaxStock.Value > 1) ? (" <style=cIsUtility>Can dash up to " + ionSurgeBaseMaxStock.Value + "times</style>.") : ""));
			LanguageAPI.Add("MAGE_SPECIAL_FIRE_DESCRIPTION", "<style=cIsDamage>Ignite</style>. Burn all enemies in front of you for <style=cIsDamage>" + (flamethrowerDamage.Value + flamethrowerDamage.Value / (1f / (flamethrowerIgniteChance.Value / 100f))) * 100f + "% damage</style>.");
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"fc060d4c1b29e1445b355c9e3e4925d1").WaitForCompletion();
			val.baseRechargeInterval = ionSurgeCooldown.Value;
			val.baseMaxStock = ionSurgeBaseMaxStock.Value;
			val.rechargeStock = ionSurgeRechargeStock.Value;
			FlyUpState.OnEnter += new hook_OnEnter(IonSurgeOnEnter);
			if (!ionSurgeScaleWithSpeed.Value)
			{
				FlyUpState.HandleMovements += new Manipulator(IonSurgeHandleMovements);
			}
			Flamethrower.OnEnter += new hook_OnEnter(FlamethrowerOnEnter);
		}

		private void FlamethrowerOnEnter(orig_OnEnter orig, Flamethrower self)
		{
			Flamethrower.ignitePercentChance = flamethrowerIgniteChance.Value;
			Flamethrower.totalDamageCoefficient = flamethrowerDamage.Value;
			self.maxDistance = flamethrowerRange.Value;
			orig.Invoke(self);
		}

		private void IonSurgeHandleMovements(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<BaseState>(x, "moveSpeedStat")
			}))
			{
				logger.LogError((object)"Failed to IL hook Ion Surge Handle Movements");
				return;
			}
			val.EmitDelegate<Func<float, float>>((Func<float, float>)((float orig) => 10.15f));
		}

		private void IonSurgeOnEnter(orig_OnEnter orig, FlyUpState self)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			FlyUpState.blastAttackRadius = ionSurgeAoe.Value;
			FlyUpState.blastAttackDamageCoefficient = ionSurgeDamage.Value;
			FlyUpState.duration = ionSurgeDuration.Value;
			orig.Invoke(self);
			if (((EntityState)self).isAuthority)
			{
				Vector3 val = ((((EntityState)self).inputBank.moveVector == Vector3.zero) ? Vector3.zero : ((Vector3)(ref ((EntityState)self).inputBank.moveVector)).normalized);
				Vector3 velocity = ((Vector3)(ref val)).normalized * ionSurgeDashSpeed.Value * ((BaseState)self).moveSpeedStat;
				((BaseCharacterController)((EntityState)self).characterMotor).Motor.ForceUnground(0.1f);
				((EntityState)self).characterMotor.velocity = velocity;
			}
		}
	}
}