Decompiled source of ArtificerFrostSurge v1.5.0

ArtificerFrostSurge.dll

Decompiled 2 days ago
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AltArtificerExtended.Passive;
using ArtificerFrostSurge.MyEntityStates;
using ArtificerFrostSurge.Properties;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.Mage;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
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: AssemblyTitle("ArtificerFrostSurge")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ArtificerFrostSurge")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5f5a808c-f244-41a7-ab64-848f6b0ea409")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ArtificerFrostSurge
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.nugget.ArtificerFrostSurge", "Frost Surge", "1.5.0 ")]
	[R2APISubmoduleDependency(new string[] { "LanguageAPI" })]
	public class FrostSurge : BaseUnityPlugin
	{
		public static ConfigEntry<bool> MyConfigEntry { get; set; }

		public void Awake()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			MyConfigEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("ArtificerFrostSurge", "isSpecial", false, "Set to true to change Frost Surge to a Special instead of a Utility");
			Texture2D val = LoadTexture2D(Resources.FrostSurgeIcon);
			GameObject val2 = LegacyResourcesAPI.Load<GameObject>("prefabs/characterbodies/MageBody");
			LanguageAPI.Add("ARTI_FROSTSURGE_ICE", "Frost Surge");
			if (MyConfigEntry.Value)
			{
				LanguageAPI.Add("ARTI_SPECIAL_FROSTSURGE_DESCRIPTION", "<style=cIsUtility>Freezing</style>. Burst into the sky dealing <style=cIsDamage>350%</style> damage. If touching the ground leave behind a cluster of ice that hurts enemies for <style=cIsDamage>100%</style> damage.");
			}
			else
			{
				LanguageAPI.Add("ARTI_UTILITY_FROSTSURGE_DESCRIPTION", "<style=cIsUtility>Freezing</style>. Burst into the sky dealing <style=cIsDamage>350%</style> damage. If touching the ground leave behind a cluster of ice that hurts enemies for <style=cIsDamage>100%</style> damage.");
			}
			SkillDef val3 = ScriptableObject.CreateInstance<SkillDef>();
			val3.activationState = new SerializableEntityStateType(typeof(FrostSurgeState));
			val3.activationStateMachineName = "Body";
			val3.baseMaxStock = 1;
			val3.baseRechargeInterval = 8f;
			val3.beginSkillCooldownOnSkillEnd = true;
			val3.canceledFromSprinting = false;
			val3.fullRestockOnAssign = true;
			val3.interruptPriority = (InterruptPriority)7;
			val3.isCombatSkill = true;
			val3.mustKeyPress = true;
			val3.cancelSprintingOnActivation = false;
			val3.rechargeStock = 1;
			val3.requiredStock = 1;
			val3.stockToConsume = 1;
			val3.icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			val3.skillDescriptionToken = "ARTI_UTILITY_FROSTSURGE_DESCRIPTION";
			val3.skillName = "ARTI_FROSTSURGE_ICE";
			val3.skillNameToken = "ARTI_FROSTSURGE_ICE";
			val3.keywordTokens = new string[1] { "KEYWORD_FREEZING" };
			SkillLocator component = val2.GetComponent<SkillLocator>();
			SkillFamily skillFamily = component.utility.skillFamily;
			if (MyConfigEntry.Value)
			{
				skillFamily = component.special.skillFamily;
				val3.skillDescriptionToken = "ARTI_SPECIAL_FROSTSURGE_DESCRIPTION";
			}
			ContentAddition.AddSkillDef(val3);
			Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
			Variant[] variants = skillFamily.variants;
			int num = skillFamily.variants.Length - 1;
			Variant val4 = new Variant
			{
				skillDef = val3,
				unlockableDef = null
			};
			((Variant)(ref val4)).viewableNode = new Node(val3.skillNameToken, false, (Node)null);
			variants[num] = val4;
			static Texture2D LoadTexture2D(byte[] resourceBytes)
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Expected O, but got Unknown
				if (resourceBytes == null)
				{
					throw new ArgumentNullException("resourceBytes");
				}
				Texture2D val5 = new Texture2D(128, 128, (TextureFormat)4, false);
				ImageConversion.LoadImage(val5, resourceBytes, false);
				return val5;
			}
		}
	}
}
namespace ArtificerFrostSurge.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("ArtificerFrostSurge.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] FrostSurgeIcon
		{
			get
			{
				object obj = ResourceManager.GetObject("FrostSurgeIcon", resourceCulture);
				return (byte[])obj;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace ArtificerFrostSurge.MyEntityStates
{
	public class FrostSurgeState : MageCharacterMain
	{
		private Vector3 flyVector = Vector3.zero;

		private Transform modelTransform;

		private Vector3 blastPosition;

		public float baseDuration = 0.5f;

		private GameObject iceExplosionEffectPrefab = LegacyResourcesAPI.Load<GameObject>("prefabs/effects/impacteffects/MageIceExplosion");

		public GameObject wallPrefab = LegacyResourcesAPI.Load<GameObject>("prefabs/projectiles/MageIcewallPillarProjectile");

		public GameObject bigWallPrefab = LegacyResourcesAPI.Load<GameObject>("prefabs/projectiles/MageIcewallPillarProjectile");

		public override void OnEnter()
		{
			//IL_0052: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			//IL_0148: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_021f: 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_0234: 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_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			((MageCharacterMain)this).OnEnter();
			if (((BaseState)this).isGrounded)
			{
				flyVector = Vector3.Normalize(((EntityState)this).characterDirection.forward + Vector3.up / 1.15f) * 0.8f;
			}
			else
			{
				flyVector = Vector3.Normalize(((EntityState)this).characterDirection.forward + Vector3.up / 4f) * 0.8f;
			}
			Util.PlaySound(FlyUpState.beginSoundString, ((EntityState)this).gameObject);
			modelTransform = ((EntityState)this).GetModelTransform();
			CreateBlinkEffect(Util.GetCorePosition(((EntityState)this).gameObject));
			((EntityState)this).PlayCrossfade("Body", "FlyUp", "FlyUp.playbackRate", FlyUpState.duration, 0.1f);
			((EntityState)this).characterMotor.velocity = Vector3.zero;
			EffectManager.SimpleMuzzleFlash(FlyUpState.muzzleflashEffect, ((EntityState)this).gameObject, "MuzzleLeft", false);
			EffectManager.SimpleMuzzleFlash(FlyUpState.muzzleflashEffect, ((EntityState)this).gameObject, "MuzzleRight", false);
			if (((EntityState)this).isAuthority)
			{
				blastPosition = ((EntityState)this).characterBody.corePosition;
			}
			BlastAttack val = new BlastAttack();
			val.radius = FlyUpState.blastAttackRadius;
			val.procCoefficient = FlyUpState.blastAttackProcCoefficient;
			val.position = blastPosition;
			val.attacker = ((EntityState)this).gameObject;
			val.crit = Util.CheckRoll(((EntityState)this).characterBody.crit, ((EntityState)this).characterBody.master);
			val.baseDamage = ((EntityState)this).characterBody.damage * 3.5f;
			val.falloffModel = (FalloffModel)0;
			val.baseForce = FlyUpState.blastAttackForce;
			val.teamIndex = TeamComponent.GetObjectTeam(val.attacker);
			val.attackerFiltering = (AttackerFiltering)2;
			val.damageType = DamageTypeCombo.op_Implicit((DamageType)256);
			val.Fire();
			EffectManager.SimpleEffect(iceExplosionEffectPrefab, ((EntityState)this).transform.position + Vector3.up, Util.QuaternionSafeLookRotation(Vector3.forward), true);
			if (((BaseState)this).isGrounded)
			{
				ProjectileManager.instance.FireProjectile(bigWallPrefab, ((EntityState)this).transform.position, Util.QuaternionSafeLookRotation(Vector3.Normalize(((EntityState)this).characterDirection.forward / 2f + Vector3.up)), ((EntityState)this).gameObject, ((BaseState)this).damageStat * 1f, 0f, false, (DamageColorIndex)0, (GameObject)null, -1f, (DamageTypeCombo?)null);
				InstantiateCircle();
			}
			void InstantiateCircle()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//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_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: 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_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Unknown result type (might be due to invalid IL or missing references)
				float num = 2f;
				int num2 = 6;
				float num3 = 360f / (float)num2;
				for (int i = 0; i < num2; i++)
				{
					Quaternion val2 = Quaternion.AngleAxis((float)i * num3, Vector3.up);
					Vector3 val3 = val2 * (Vector3.forward * 0.3f);
					Vector3 val4 = ((EntityState)this).transform.position + val3 * num;
					ProjectileManager.instance.FireProjectile(wallPrefab, val4 + Vector3.down * 3f, Util.QuaternionSafeLookRotation(Vector3.Normalize(val3 + Vector3.up)), ((EntityState)this).gameObject, ((BaseState)this).damageStat * 1f, 0f, false, (DamageColorIndex)0, (GameObject)null, -1f, (DamageTypeCombo?)null);
				}
			}
		}

		public override void OnExit()
		{
			if (!((EntityState)this).outer.destroying)
			{
				Util.PlaySound(FlyUpState.endSoundString, ((EntityState)this).gameObject);
			}
			((MageCharacterMain)this).OnExit();
		}

		public override void FixedUpdate()
		{
			((GenericCharacterMain)this).FixedUpdate();
			if (((EntityState)this).fixedAge >= FlyUpState.duration && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		private void CreateBlinkEffect(Vector3 origin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			EffectData val = new EffectData();
			val.rotation = Util.QuaternionSafeLookRotation(flyVector);
			val.origin = origin;
			EffectManager.SpawnEffect(FlyUpState.blinkPrefab, val, false);
		}

		public override void OnSerialize(NetworkWriter writer)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).OnSerialize(writer);
			writer.Write(blastPosition);
		}

		public override void OnDeserialize(NetworkReader reader)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).OnDeserialize(reader);
			blastPosition = reader.ReadVector3();
		}

		public override void HandleMovements()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			((GenericCharacterMain)this).HandleMovements();
			CharacterMotor characterMotor = ((EntityState)this).characterMotor;
			characterMotor.rootMotion += flyVector * (((BaseState)this).moveSpeedStat * FlyUpState.speedCoefficientCurve.Evaluate(((EntityState)this).fixedAge / FlyUpState.duration) * Time.fixedDeltaTime);
			((EntityState)this).characterMotor.velocity.y = 0f;
		}

		protected override void UpdateAnimationParameters()
		{
			((BaseCharacterMain)this).UpdateAnimationParameters();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public void SkillCast()
		{
			GameObject gameObject = ((Component)((EntityState)this).outer).gameObject;
			if (AltArtiPassive.instanceLookup.TryGetValue(gameObject, out var value))
			{
				value.SkillCast((BatchHandle)null);
			}
		}
	}
}