Decompiled source of ManualArrows v1.0.1

ManualArrows.dll

Decompiled 5 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.Huntress.HuntressWeapon;
using ManualArrows.EntityStates;
using Microsoft.CodeAnalysis;
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("ManualArrows")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ManualArrows")]
[assembly: AssemblyTitle("ManualArrows")]
[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 ManualArrows
{
	[BepInPlugin("com.Nuxlar.ManualArrows", "ManualArrows", "1.0.1")]
	public class ManualArrows : BaseUnityPlugin
	{
		private GameObject huntress = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Huntress/HuntressBody.prefab").WaitForCompletion();

		private HuntressTrackingSkillDef strafe = Addressables.LoadAssetAsync<HuntressTrackingSkillDef>((object)"RoR2/Base/Huntress/HuntressBodyFireSeekingArrow.asset").WaitForCompletion();

		private HuntressTrackingSkillDef flurry = Addressables.LoadAssetAsync<HuntressTrackingSkillDef>((object)"RoR2/Base/Huntress/FireFlurrySeekingArrow.asset").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_005b: 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_007d: Expected O, but got Unknown
			//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_0096: 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_00b8: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			bool flag = default(bool);
			ContentAddition.AddEntityState<FireStrafe>(ref flag);
			ContentAddition.AddEntityState<FireFlurry>(ref flag);
			SkillDef val = CreateStrafeDef();
			SkillDef val2 = CreateFlurryDef();
			SkillFamily skillFamily = huntress.GetComponent<SkillLocator>().primary.skillFamily;
			Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 2);
			Variant[] variants = skillFamily.variants;
			int num = skillFamily.variants.Length - 2;
			Variant val3 = new Variant
			{
				skillDef = val
			};
			((Variant)(ref val3)).viewableNode = new Node(val.skillNameToken, false, (Node)null);
			variants[num] = val3;
			Variant[] variants2 = skillFamily.variants;
			int num2 = skillFamily.variants.Length - 1;
			val3 = new Variant
			{
				skillDef = val2
			};
			((Variant)(ref val3)).viewableNode = new Node(val2.skillNameToken, false, (Node)null);
			variants2[num2] = val3;
		}

		public SkillDef CreateStrafeDef()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			SkillDef obj = ScriptableObject.CreateInstance<SkillDef>();
			obj.skillName = "Manual Strafe";
			((Object)obj).name = "Manual Strafe";
			obj.skillNameToken = "Manual Strafe";
			obj.skillDescriptionToken = "<style=cIsUtility>Agile</style>. Quickly fire an arrow for <style=cIsDamage>150% damage</style>.";
			obj.icon = ((SkillDef)strafe).icon;
			obj.activationState = new SerializableEntityStateType(typeof(FireStrafe));
			obj.activationStateMachineName = ((SkillDef)strafe).activationStateMachineName;
			obj.interruptPriority = ((SkillDef)strafe).interruptPriority;
			obj.baseMaxStock = ((SkillDef)strafe).baseMaxStock;
			obj.baseRechargeInterval = ((SkillDef)strafe).baseRechargeInterval;
			obj.rechargeStock = ((SkillDef)strafe).rechargeStock;
			obj.requiredStock = ((SkillDef)strafe).requiredStock;
			obj.stockToConsume = ((SkillDef)strafe).stockToConsume;
			obj.dontAllowPastMaxStocks = ((SkillDef)strafe).dontAllowPastMaxStocks;
			obj.beginSkillCooldownOnSkillEnd = ((SkillDef)strafe).beginSkillCooldownOnSkillEnd;
			obj.canceledFromSprinting = ((SkillDef)strafe).canceledFromSprinting;
			obj.forceSprintDuringState = ((SkillDef)strafe).forceSprintDuringState;
			obj.fullRestockOnAssign = ((SkillDef)strafe).fullRestockOnAssign;
			obj.resetCooldownTimerOnUse = ((SkillDef)strafe).resetCooldownTimerOnUse;
			obj.isCombatSkill = ((SkillDef)strafe).isCombatSkill;
			obj.mustKeyPress = ((SkillDef)strafe).mustKeyPress;
			obj.cancelSprintingOnActivation = ((SkillDef)strafe).cancelSprintingOnActivation;
			obj.keywordTokens = ((SkillDef)strafe).keywordTokens;
			ContentAddition.AddSkillDef(obj);
			return obj;
		}

		public SkillDef CreateFlurryDef()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			SkillDef obj = ScriptableObject.CreateInstance<SkillDef>();
			obj.skillName = "Manual Flurry";
			((Object)obj).name = "Manual Flurry";
			obj.skillNameToken = "Manual Flurry";
			obj.skillDescriptionToken = "<style=cIsUtility>Agile</style>. Draw back a volley of <style=cIsDamage>3</style> arrows that deal <style=cIsDamage>3x100%</style> damage each. Critical Strikes fire <style=cIsDamage>6</style> arrows.";
			obj.icon = ((SkillDef)flurry).icon;
			obj.activationState = new SerializableEntityStateType(typeof(FireFlurry));
			obj.activationStateMachineName = ((SkillDef)flurry).activationStateMachineName;
			obj.interruptPriority = ((SkillDef)flurry).interruptPriority;
			obj.baseMaxStock = ((SkillDef)flurry).baseMaxStock;
			obj.baseRechargeInterval = ((SkillDef)flurry).baseRechargeInterval;
			obj.rechargeStock = ((SkillDef)flurry).rechargeStock;
			obj.requiredStock = ((SkillDef)flurry).requiredStock;
			obj.stockToConsume = ((SkillDef)flurry).stockToConsume;
			obj.dontAllowPastMaxStocks = ((SkillDef)flurry).dontAllowPastMaxStocks;
			obj.beginSkillCooldownOnSkillEnd = ((SkillDef)flurry).beginSkillCooldownOnSkillEnd;
			obj.canceledFromSprinting = ((SkillDef)flurry).canceledFromSprinting;
			obj.forceSprintDuringState = ((SkillDef)flurry).forceSprintDuringState;
			obj.fullRestockOnAssign = ((SkillDef)flurry).fullRestockOnAssign;
			obj.resetCooldownTimerOnUse = ((SkillDef)flurry).resetCooldownTimerOnUse;
			obj.isCombatSkill = ((SkillDef)flurry).isCombatSkill;
			obj.mustKeyPress = ((SkillDef)flurry).mustKeyPress;
			obj.cancelSprintingOnActivation = ((SkillDef)flurry).cancelSprintingOnActivation;
			obj.keywordTokens = ((SkillDef)flurry).keywordTokens;
			ContentAddition.AddSkillDef(obj);
			return obj;
		}
	}
}
namespace ManualArrows.EntityStates
{
	public class FireFlurry : BaseState
	{
		public static GameObject effectPrefab = FireArrow.effectPrefab;

		public static GameObject hitEffectPrefab = FireArrow.hitEffectPrefab;

		public static GameObject projectilePrefab = FireArrow.projectilePrefab;

		public int arrowCountMax = 3;

		public float damageCoefficient = 1f;

		public static float fireDuration = 0.5f;

		public static float baseDuration = 1.5f;

		public static float arcAngle = 0f;

		public static float recoilAmplitude = 0.1f;

		public static string attackSoundString;

		public static float spreadBloomValue = 0.3f;

		public static float smallHopStrength = FireArrow.smallHopStrength;

		private Ray aimRay;

		private Transform modelTransform;

		private float duration;

		private float fireTimer;

		private int grenadeCount;

		private bool isCrit;

		private void FireGrenade(string targetMuzzle)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: 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_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			Util.PlayAttackSpeedSound("Play_huntress_m1_shoot", ((EntityState)this).gameObject, base.attackSpeedStat);
			aimRay = ((BaseState)this).GetAimRay();
			if (Object.op_Implicit((Object)(object)modelTransform))
			{
				ChildLocator component = ((Component)modelTransform).GetComponent<ChildLocator>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Transform val = component.FindChild(targetMuzzle);
					if (Object.op_Implicit((Object)(object)val))
					{
						((Ray)(ref aimRay)).origin = val.position;
					}
				}
			}
			((BaseState)this).AddRecoil(-1f * recoilAmplitude, -2f * recoilAmplitude, -1f * recoilAmplitude, 1f * recoilAmplitude);
			if (Object.op_Implicit((Object)(object)effectPrefab))
			{
				if (isCrit)
				{
					EffectManager.SimpleMuzzleFlash(FireFlurrySeekingArrow.critMuzzleflashEffectPrefab, ((EntityState)this).gameObject, targetMuzzle, false);
				}
				else
				{
					EffectManager.SimpleMuzzleFlash(effectPrefab, ((EntityState)this).gameObject, targetMuzzle, false);
				}
			}
			if (((EntityState)this).isAuthority)
			{
				float num = Random.Range(0f, ((EntityState)this).characterBody.spreadBloomAngle);
				float num2 = Random.Range(0f, 360f);
				Vector3 up = Vector3.up;
				Vector3 val2 = Vector3.Cross(up, ((Ray)(ref aimRay)).direction);
				Vector3 val3 = Quaternion.Euler(0f, 0f, num2) * (Quaternion.Euler(num, 0f, 0f) * Vector3.forward);
				float y = val3.y;
				val3.y = 0f;
				double num3 = (double)Mathf.Atan2(val3.z, val3.x) * 57.295780181884766 - 90.0;
				float num4 = Mathf.Atan2(y, ((Vector3)(ref val3)).magnitude) * 57.29578f + arcAngle;
				Vector3 val4 = up;
				Vector3 val5 = Quaternion.AngleAxis((float)num3, val4) * (Quaternion.AngleAxis(num4, val2) * ((Ray)(ref aimRay)).direction);
				ProjectileManager.instance.FireProjectile(projectilePrefab, ((Ray)(ref aimRay)).origin, Util.QuaternionSafeLookRotation(val5), ((EntityState)this).gameObject, base.damageStat * damageCoefficient, 0f, Util.CheckRoll(base.critStat, ((EntityState)this).characterBody.master), (DamageColorIndex)0, (GameObject)null, -1f);
			}
			((EntityState)this).characterBody.AddSpreadBloom(spreadBloomValue);
		}

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			duration = baseDuration / base.attackSpeedStat;
			modelTransform = ((EntityState)this).GetModelTransform();
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor) && (double)smallHopStrength != 0.0)
			{
				((EntityState)this).characterMotor.velocity.y = smallHopStrength;
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
			{
				((EntityState)this).characterBody.SetAimTimer(1.5f);
				isCrit = Util.CheckRoll(((EntityState)this).characterBody.crit, ((EntityState)this).characterBody.master);
				if (isCrit)
				{
					arrowCountMax = 6;
				}
			}
		}

		public override void OnExit()
		{
			((EntityState)this).OnExit();
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).isAuthority)
			{
				fireTimer -= Time.fixedDeltaTime;
				float num = fireDuration / base.attackSpeedStat / (float)arrowCountMax;
				if ((double)fireTimer <= 0.0 && grenadeCount < arrowCountMax)
				{
					((EntityState)this).PlayCrossfade("Gesture, Override", "FireSeekingShot", "FireSeekingShot.playbackRate", 0.1f, 0.1f / base.attackSpeedStat);
					((EntityState)this).PlayCrossfade("Gesture, Additive", "FireSeekingShot", "FireSeekingShot.playbackRate", 0.1f, 0.1f / base.attackSpeedStat);
					FireGrenade("Muzzle");
					fireTimer += num;
					grenadeCount++;
				}
				if (!((double)((EntityState)this).fixedAge < (double)duration))
				{
					((EntityState)this).outer.SetNextStateToMain();
				}
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)1;
		}
	}
	public class FireStrafe : BaseState
	{
		public static GameObject projectilePrefab = FireArrow.projectilePrefab;

		public static GameObject effectPrefab = FireArrow.effectPrefab;

		public static float baseDuration = 0.5f;

		public static float damageCoefficient = 1.5f;

		public static float force = 20f;

		private float duration;

		public override void OnEnter()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			duration = baseDuration / base.attackSpeedStat;
			Ray aimRay = ((BaseState)this).GetAimRay();
			((BaseState)this).StartAimMode(aimRay, 2f, false);
			string text = "Muzzle";
			if (Object.op_Implicit((Object)(object)effectPrefab))
			{
				EffectManager.SimpleMuzzleFlash(effectPrefab, ((EntityState)this).gameObject, text, false);
			}
			((EntityState)this).PlayCrossfade("Gesture, Override", "FireSeekingShot", "FireSeekingShot.playbackRate", duration, duration * 0.2f / base.attackSpeedStat);
			((EntityState)this).PlayCrossfade("Gesture, Additive", "FireSeekingShot", "FireSeekingShot.playbackRate", duration, duration * 0.2f / base.attackSpeedStat);
			if (((EntityState)this).isAuthority)
			{
				Util.PlayAttackSpeedSound("Play_huntress_m1_shoot", ((EntityState)this).gameObject, base.attackSpeedStat);
				ProjectileManager.instance.FireProjectile(projectilePrefab, ((Ray)(ref aimRay)).origin, Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction), ((EntityState)this).gameObject, base.damageStat * damageCoefficient, force, Util.CheckRoll(base.critStat, ((EntityState)this).characterBody.master), (DamageColorIndex)0, (GameObject)null, -1f);
			}
		}

		public override void OnExit()
		{
			((EntityState)this).OnExit();
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (!((double)((EntityState)this).fixedAge < (double)duration) && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)1;
		}
	}
}