Decompiled source of BetterSonLaser v1.0.0

plugins/BetterSonLaser.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConcentricContent;
using EntityStates;
using EntityStates.FalseSon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Skills;
using RoR2.UI;
using RoR2.WwiseUtils;
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("BetterSonLaser")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f1239f3276c2cb451c3fb97e22082ce5cf6fa0cc")]
[assembly: AssemblyProduct("BetterSonLaser")]
[assembly: AssemblyTitle("BetterSonLaser")]
[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 BetterSonLaser
{
	public class BetterLaserCharge : BaseSkillState
	{
		public float baseChargeDuration = 2f;

		public GameObject chargeCompletePrefab;

		public static float minChargeForChargedAttack = 0f;

		public static GameObject chargeVfxPrefab;

		public static string chargeVfxChildLocatorName = "HandL";

		public static GameObject crosshairOverridePrefab;

		public static float walkSpeedCoefficient = 0.55f;

		public static string startChargeLoopSFXString = "Play_falseson_skill4_laser_charge_loop";

		public static string endChargeLoopSFXString = "Stop_falseson_skill4_laser_charge_loop";

		public static string enterSFXString = "";

		private OverrideRequest crosshairOverrideRequest;

		private Transform chargeVfxInstanceTransform;

		private int gauntlet;

		private uint soundID;

		public static float baseDuration = 3f;

		public static float laserMaxWidth = 0.2f;

		public static GameObject effectPrefab;

		public static GameObject laserPrefab;

		public static string attackSoundString = "";

		private float duration;

		private uint chargePlayID;

		private GameObject chargeEffect;

		private GameObject laserEffect;

		private LineRenderer laserLineComponent;

		private Vector3 laserDirection;

		private Vector3 visualEndPosition;

		private float flashTimer;

		private bool laserOn;

		private bool chargeAnimPlayed;

		private bool chargeFinished;

		private bool chargeStarted;

		private bool cancellingAttack;

		public static GameObject doneChargingEffect;

		protected float chargeDuration { get; private set; }

		protected float charge { get; private set; }

		public override void OnEnter()
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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)
			((BaseState)this).OnEnter();
			chargeDuration = baseChargeDuration / ((BaseState)this).attackSpeedStat;
			soundID = Util.PlaySound(startChargeLoopSFXString, ((EntityState)this).gameObject);
			duration = baseDuration / ((BaseState)this).attackSpeedStat;
			Transform modelTransform = ((EntityState)this).GetModelTransform();
			chargePlayID = Util.PlayAttackSpeedSound(attackSoundString, ((EntityState)this).gameObject, ((BaseState)this).attackSpeedStat);
			if (Object.op_Implicit((Object)(object)modelTransform))
			{
				ChildLocator component = ((Component)modelTransform).GetComponent<ChildLocator>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Transform val = component.FindChild("MuzzleLaser");
					if (Object.op_Implicit((Object)(object)val))
					{
						if (Object.op_Implicit((Object)(object)effectPrefab))
						{
							chargeEffect = Object.Instantiate<GameObject>(effectPrefab, val.position, val.rotation);
							chargeEffect.transform.parent = val;
							ScaleParticleSystemDuration component2 = chargeEffect.GetComponent<ScaleParticleSystemDuration>();
							if (Object.op_Implicit((Object)(object)component2))
							{
								component2.newDuration = duration;
							}
						}
						if (Object.op_Implicit((Object)(object)laserPrefab))
						{
							laserEffect = Object.Instantiate<GameObject>(laserPrefab, val.position, val.rotation);
							laserEffect.transform.parent = val;
							laserLineComponent = laserEffect.GetComponent<LineRenderer>();
						}
					}
				}
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
			{
				((EntityState)this).characterBody.SetAimTimer(duration);
			}
			flashTimer = 0f;
			laserOn = true;
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)2;
		}

		public override void ModifyNextState(EntityState nextState)
		{
			((EntityState)this).ModifyNextState(nextState);
			LaserFatherCharged val = (LaserFatherCharged)(object)((nextState is LaserFatherCharged) ? nextState : null);
			cancellingAttack = val == null;
		}

		public override void OnExit()
		{
			if (Object.op_Implicit((Object)(object)chargeVfxInstanceTransform))
			{
				EntityState.Destroy((Object)(object)((Component)chargeVfxInstanceTransform).gameObject);
				OverrideRequest obj = crosshairOverrideRequest;
				if (obj != null)
				{
					obj.Dispose();
				}
				chargeVfxInstanceTransform = null;
			}
			((EntityState)this).PlayAnimation("Gesture, Additive", "Empty");
			((EntityState)this).PlayAnimation("Gesture, Override", "Empty");
			if (cancellingAttack)
			{
				((EntityState)this).PlayAnimation("Gesture, Head, Additive", "Empty");
				((EntityState)this).PlayAnimation("Gesture, Head, Override", "Buffer Empty");
			}
			((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = 1f;
			Util.PlaySound(endChargeLoopSFXString, ((EntityState)this).gameObject);
			AkSoundEngine.StopPlayingID(chargePlayID);
			Util.PlaySound("Stop_falseson_skill4_laser_loop", ((EntityState)this).gameObject);
			Util.PlaySound("Stop_falseson_skill4_laser_charge_loop", ((EntityState)this).gameObject);
			((EntityState)this).OnExit();
			if (Object.op_Implicit((Object)(object)chargeEffect))
			{
				EntityState.Destroy((Object)(object)chargeEffect);
			}
			if (Object.op_Implicit((Object)(object)laserEffect))
			{
				EntityState.Destroy((Object)(object)laserEffect);
			}
		}

		public override void FixedUpdate()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			((EntityState)this).FixedUpdate();
			charge = Mathf.Clamp01(((EntityState)this).fixedAge / chargeDuration);
			AkSoundEngine.SetRTPCValueByPlayingID("charFalseSon_skill4_chargeAmount", charge * 100f, soundID);
			((EntityState)this).characterBody.SetSpreadBloom(charge, true);
			((EntityState)this).characterBody.SetAimTimer(3f);
			if (charge >= minChargeForChargedAttack && !chargeStarted)
			{
				chargeStarted = true;
				((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = walkSpeedCoefficient;
				((EntityState)this).PlayCrossfade("Gesture, Head, Additive", "LaserChargeIntro", "LaserChargeIntro.playbackRate", 0.2f * chargeDuration, 0.1f);
				((EntityState)this).PlayCrossfade("Gesture, Head, Override", "LaserChargeIntro", "LaserChargeIntro.playbackRate", 0.2f * chargeDuration, 0.1f);
			}
			if (((EntityState)this).isAuthority)
			{
				AuthorityFixedUpdate();
			}
			if (!(charge > 0.85f) || chargeFinished)
			{
				return;
			}
			ChildLocator component = ((Component)((EntityState)this).GetModelTransform()).GetComponent<ChildLocator>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Transform val = component.FindChild("MuzzleLaser");
				if (Object.op_Implicit((Object)(object)val))
				{
					EffectManager.SpawnEffect(doneChargingEffect, new EffectData
					{
						origin = ((Component)val).transform.position,
						scale = 1f
					}, true);
					chargeFinished = true;
				}
			}
		}

		public override void Update()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			//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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).Update();
			Mathf.Clamp01(((EntityState)this).age / chargeDuration);
			if (!BetterLaserSkill.enableTracer.Value || !Object.op_Implicit((Object)(object)laserEffect) || !Object.op_Implicit((Object)(object)laserLineComponent))
			{
				return;
			}
			float num = 1000f;
			Ray aimRay = ((BaseState)this).GetAimRay();
			Vector3 position = laserEffect.transform.parent.position;
			Vector3 point = ((Ray)(ref aimRay)).GetPoint(num);
			laserDirection = point - position;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(aimRay, ref val, num, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask)))
			{
				point = ((RaycastHit)(ref val)).point;
			}
			laserLineComponent.SetPosition(0, position);
			laserLineComponent.SetPosition(1, point);
			float num2;
			if (duration - ((EntityState)this).age > 0.5f)
			{
				num2 = ((EntityState)this).age / duration;
			}
			else
			{
				flashTimer -= Time.deltaTime;
				if (flashTimer <= 0f)
				{
					laserOn = !laserOn;
					flashTimer = 1f / 30f;
				}
				num2 = (laserOn ? 1f : 0f);
			}
			num2 *= 0.2f;
			laserLineComponent.startWidth = num2;
			laserLineComponent.endWidth = num2;
		}

		private void AuthorityFixedUpdate()
		{
			if (!((BaseSkillState)this).IsKeyDownAuthority())
			{
				((EntityState)this).outer.SetNextState(GetNextStateAuthority());
			}
		}

		protected virtual EntityState GetNextStateAuthority()
		{
			if (charge < 0.175f)
			{
				charge = 0.175f;
			}
			return (EntityState)(object)new BetterLaserFire
			{
				charge = charge,
				walkSpeedCoefficient = walkSpeedCoefficient
			};
		}
	}
	public class BetterLaserFire : BaseSkillState
	{
		public static GameObject effectPrefab;

		public GameObject hitEffectPrefab = null;

		public static GameObject laserPrefab;

		public static string playAttackSoundString = "Play_falseson_skill4_laser_start";

		public static string playLoopSoundString = "Play_falseson_skill4_laser_charge_loop";

		public static string stopLoopSoundString = "Stop_falseson_skill4_laser_charge_loop";

		public static float damageCoefficient = 1.75f;

		public static float force = 100f;

		public static float minSpread = 0f;

		public static float maxSpread = 0f;

		public static int bulletCount = 1;

		public static float fireFrequency = 12f;

		public static float maxDistance = 2000f;

		public static float minimumDuration = 3f;

		public static float maximumDuration = 4f;

		public static float lockOnAngle = 3f;

		public static float procCoefficientPerTick = 0.45f;

		private HurtBox lockedOnHurtBox;

		private float fireStopwatch;

		private float stopwatch;

		private float refillSecondaryStopwatch;

		private float maxSecondaryStock;

		private float secondaryStock;

		private Ray aimRay;

		private Transform modelTransform;

		private GameObject laserEffect;

		private ChildLocator laserChildLocator;

		private Transform laserEffectEnd;

		public float charge;

		protected Transform muzzleTransform;

		private float bonusDuration;

		protected AimRequest aimRequest;

		public static int abilityAimType = 2;

		private float duration;

		public float walkSpeedCoefficient = 1f;

		private int lunarSpikeCount;

		public static event Action<float> laserTracking;

		public override void OnEnter()
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			duration = maximumDuration;
			aimRequest = ((EntityState)this).cameraTargetParams.RequestAimType((AimType)abilityAimType);
			((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = walkSpeedCoefficient;
			FalseSonController component = ((EntityState)this).GetComponent<FalseSonController>();
			if (Object.op_Implicit((Object)(object)component))
			{
				lunarSpikeCount = component.GetTotalSpikeCount();
			}
			else
			{
				lunarSpikeCount = 0;
			}
			Util.PlaySound("Play_falseson_skill4_laser_start", ((EntityState)this).gameObject);
			((EntityState)this).PlayCrossfade("Gesture, Head, Override", "FireLaserLoop", 0.25f);
			((EntityState)this).PlayCrossfade("Gesture, Head, Additive", "FireLaserLoop", 0.25f);
			aimRay = ((BaseState)this).GetAimRay();
			TrajectoryAimAssist.ApplyTrajectoryAimAssist(ref aimRay, maxDistance, ((EntityState)this).gameObject, 1f);
			modelTransform = ((EntityState)this).GetModelTransform();
			if (Object.op_Implicit((Object)(object)modelTransform))
			{
				ChildLocator component2 = ((Component)modelTransform).GetComponent<ChildLocator>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					muzzleTransform = component2.FindChild("MuzzleLaser");
					if (Object.op_Implicit((Object)(object)muzzleTransform) && Object.op_Implicit((Object)(object)laserPrefab))
					{
						laserEffect = Object.Instantiate<GameObject>(laserPrefab, muzzleTransform.position, muzzleTransform.rotation);
						laserEffect.transform.parent = muzzleTransform;
						laserChildLocator = laserEffect.GetComponent<ChildLocator>();
						laserEffectEnd = laserChildLocator.FindChild("LaserEnd");
					}
				}
			}
			bonusDuration = 0f;
			for (int i = 1; i <= lunarSpikeCount; i++)
			{
				bonusDuration += 1f / (0.5f * (float)i + 1f);
			}
			if (bonusDuration < 0f)
			{
				bonusDuration = 0f;
			}
			duration += bonusDuration;
			((EntityState)this).characterBody.SetAimTimer(duration);
			float num = ((EntityState)this).characterBody.attackSpeed - ((EntityState)this).characterBody.baseAttackSpeed;
			fireFrequency += num * 0.3f;
			maxSecondaryStock = ((EntityState)this).skillLocator.GetSkill((SkillSlot)1).maxStock;
			secondaryStock = ((EntityState)this).skillLocator.GetSkill((SkillSlot)1).maxStock;
		}

		public override void OnExit()
		{
			AimRequest obj = aimRequest;
			if (obj != null)
			{
				obj.Dispose();
			}
			if (Object.op_Implicit((Object)(object)laserEffect))
			{
				EntityState.Destroy((Object)(object)laserEffect);
			}
			((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = 1f;
			((EntityState)this).characterBody.SetAimTimer(2f);
			Util.PlaySound("Stop_falseson_skill4_laser_loop", ((EntityState)this).gameObject);
			Util.PlaySound("Stop_falseson_skill4_laser_charge_loop", ((EntityState)this).gameObject);
			Util.PlaySound("Play_falseson_skill4_laser_end", ((EntityState)this).gameObject);
			((EntityState)this).PlayAnimation("Gesture, Head, Override", "FireLaserLoopEnd");
			((EntityState)this).PlayAnimation("Gesture, Head, Additive", "FireLaserLoopEnd");
			((EntityState)this).OnExit();
		}

		public override void FixedUpdate()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: 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_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: 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_01ce: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: 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_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).FixedUpdate();
			float deltaTime = ((EntityState)this).GetDeltaTime();
			fireStopwatch += deltaTime;
			stopwatch += deltaTime;
			refillSecondaryStopwatch += deltaTime;
			if (refillSecondaryStopwatch > 1f)
			{
				maxSecondaryStock = ((EntityState)this).skillLocator.GetSkill((SkillSlot)1).maxStock;
				secondaryStock = ((EntityState)this).skillLocator.GetSkill((SkillSlot)1).stock;
				if (secondaryStock < maxSecondaryStock)
				{
					GenericSkill skill = ((EntityState)this).skillLocator.GetSkill((SkillSlot)1);
					int stock = skill.stock;
					skill.stock = stock + 1;
					refillSecondaryStopwatch = 0f;
				}
			}
			aimRay = ((BaseState)this).GetAimRay();
			Vector3 val = ((Ray)(ref aimRay)).origin;
			if (Object.op_Implicit((Object)(object)muzzleTransform))
			{
				val = muzzleTransform.position;
			}
			Vector3 val2;
			if (Object.op_Implicit((Object)(object)lockedOnHurtBox))
			{
				val2 = ((Component)lockedOnHurtBox).transform.position;
			}
			else
			{
				TrajectoryAimAssist.ApplyTrajectoryAimAssist(ref aimRay, maxDistance, ((EntityState)this).gameObject, 1f);
				RaycastHit val3 = default(RaycastHit);
				val2 = ((!Util.CharacterRaycast(((EntityState)this).gameObject, aimRay, ref val3, maxDistance, LayerMask.op_Implicit(LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask)), (QueryTriggerInteraction)1)) ? ((Ray)(ref aimRay)).GetPoint(maxDistance) : ((RaycastHit)(ref val3)).point);
			}
			Ray val4 = default(Ray);
			((Ray)(ref val4))..ctor(val, val2 - val);
			bool flag = false;
			Vector3 val6;
			if (Object.op_Implicit((Object)(object)laserEffect) && Object.op_Implicit((Object)(object)laserChildLocator))
			{
				GameObject gameObject = ((EntityState)this).gameObject;
				Ray val5 = val4;
				val6 = val2 - val;
				RaycastHit val7 = default(RaycastHit);
				if (Util.CharacterRaycast(gameObject, val5, ref val7, ((Vector3)(ref val6)).magnitude, LayerMask.op_Implicit(LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask)), (QueryTriggerInteraction)0))
				{
					val2 = ((RaycastHit)(ref val7)).point;
					RaycastHit val8 = default(RaycastHit);
					if (Util.CharacterRaycast(((EntityState)this).gameObject, new Ray(val2 - ((Ray)(ref val4)).direction * 0.1f, -((Ray)(ref val4)).direction), ref val8, ((RaycastHit)(ref val7)).distance, LayerMask.op_Implicit(LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask)), (QueryTriggerInteraction)0))
					{
						val2 = ((Ray)(ref val4)).GetPoint(0.1f);
						flag = true;
					}
				}
				laserEffect.transform.rotation = Util.QuaternionSafeLookRotation(val2 - val);
				((Component)laserEffectEnd).transform.position = val2;
			}
			if (fireStopwatch > 1f / fireFrequency)
			{
				string targetMuzzle = "MuzzleLaser";
				if (!flag)
				{
					Transform obj = modelTransform;
					Ray val9 = val4;
					val6 = val2 - ((Ray)(ref val4)).origin;
					FireBullet(obj, val9, targetMuzzle, ((Vector3)(ref val6)).magnitude + 0.1f);
				}
				fireStopwatch -= 1f / fireFrequency;
			}
			if (((EntityState)this).isAuthority && stopwatch > duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)1;
		}

		private void FireBullet(Transform modelTransform, Ray aimRay, string targetMuzzle, float maxDistance)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)effectPrefab))
			{
				EffectManager.SimpleMuzzleFlash(effectPrefab, ((EntityState)this).gameObject, targetMuzzle, false);
			}
			if (((EntityState)this).isAuthority)
			{
				if (charge > 0.85f)
				{
					charge = 1f;
				}
				BulletAttack val = new BulletAttack();
				val.owner = ((EntityState)this).gameObject;
				val.weapon = ((EntityState)this).gameObject;
				val.origin = ((Ray)(ref aimRay)).origin;
				val.aimVector = ((Ray)(ref aimRay)).direction;
				val.minSpread = minSpread;
				val.maxSpread = maxSpread;
				val.bulletCount = 1u;
				val.damage = damageCoefficient * ((BaseState)this).damageStat * charge;
				val.force = force;
				val.muzzleName = targetMuzzle;
				val.hitEffectPrefab = hitEffectPrefab;
				val.isCrit = Util.CheckRoll(((BaseState)this).critStat, ((EntityState)this).characterBody.master);
				val.procCoefficient = procCoefficientPerTick;
				val.HitEffectNormal = false;
				val.radius = 1f;
				val.maxDistance = maxDistance;
				val.damageType.damageSource = (DamageSource)8;
				val.Fire();
			}
		}

		public override void OnSerialize(NetworkWriter writer)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			((BaseSkillState)this).OnSerialize(writer);
			NetworkExtensions.Write(writer, HurtBoxReference.FromHurtBox(lockedOnHurtBox));
			writer.Write(stopwatch);
		}

		public override void OnDeserialize(NetworkReader reader)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			((BaseSkillState)this).OnDeserialize(reader);
			HurtBoxReference val = NetworkExtensions.ReadHurtBoxReference(reader);
			stopwatch = reader.ReadSingle();
			GameObject obj = ((HurtBoxReference)(ref val)).ResolveGameObject();
			lockedOnHurtBox = ((obj != null) ? obj.GetComponent<HurtBox>() : null);
		}
	}
	public class BetterLaserSkill : Concentric, ISkill, IGenericObject, IGameObject
	{
		private SkillFamily sonSpecial;

		public static ConfigEntry<bool> enableTracer = ((BaseUnityPlugin)BetterSonLaserPlugin.instance).Config.Bind<bool>("Settings", "Enable Tracer", true, "Enable the golem-tracer when charging the skill");

		public override async Task Initialize()
		{
			await <>n__0();
			sonSpecial = await BetterSonLaserPlugin.LoadAsset<SkillFamily>("RoR2/DLC2/FalseSon/FalseSonBodySpecialFamily.asset");
			Variant[] variants = sonSpecial.variants;
			variants[0] = await AssetExtensionMethods.GetSkillFamilyVariant<BetterLaserSkill>(this);
			BetterLaserCharge.laserPrefab = await AssetExtensionMethods.GetGenericObject<BetterLaserSkill>(this);
			BetterLaserCharge.effectPrefab = await Concentric.GetGenericObject<BetterLaserChargeEffect>();
			BetterLaserCharge.crosshairOverridePrefab = await BetterSonLaserPlugin.LoadAsset<GameObject>("RoR2/Base/UI/StraightBracketCrosshair.prefab");
			BetterLaserCharge.chargeVfxPrefab = await BetterSonLaserPlugin.LoadAsset<GameObject>("RoR2/DLC2/FalseSon/FalseSonFistCharge.prefab");
			BetterLaserCharge.doneChargingEffect = await Concentric.GetEffect<WhyDoesGearboxUseLegacyResourcesAPI>();
			BetterLaserFire.laserPrefab = await Concentric.GetGenericObject<BetterLaserFirePrefab>();
			BetterLaserFire.effectPrefab = await Concentric.GetEffect<BetterLaserFireMuzzleFlash>();
		}

		async Task<SkillDef> ISkill.BuildObject()
		{
			SkillDef skill = ScriptableObject.CreateInstance<SkillDef>();
			skill.skillName = "Special 1";
			skill.skillNameToken = "FALSESON_SPECIAL_NAME";
			skill.skillDescriptionToken = "FALSESON_SPECIAL_DESCRIPTION";
			SkillDef val = skill;
			val.icon = await BetterSonLaserPlugin.LoadAsset<Sprite>("sondle:texFalseSonSkillIcons_3");
			skill.activationStateMachineName = "Weapon";
			skill.interruptPriority = (InterruptPriority)2;
			skill.baseRechargeInterval = 15f;
			skill.resetCooldownTimerOnUse = true;
			skill.fullRestockOnAssign = false;
			skill.dontAllowPastMaxStocks = false;
			skill.beginSkillCooldownOnSkillEnd = true;
			skill.cancelSprintingOnActivation = true;
			skill.isCombatSkill = true;
			skill.mustKeyPress = true;
			skill.autoHandleLuminousShot = true;
			skill.keywordTokens = new string[1] { "KEYWORD_GROWTH" };
			return skill;
		}

		async Task<GameObject> IGenericObject.BuildObject()
		{
			Material sonTracer = new Material(await BetterSonLaserPlugin.LoadAsset<Material>("RoR2/Base/Common/VFX/matGolemLaserIndicator.mat"));
			Material val = sonTracer;
			val.SetTexture("_RemapTex", (Texture)(object)(await BetterSonLaserPlugin.LoadAsset<Texture2D>("RoR2/Base/Common/ColorRamps/texRampBombOrb.png")));
			sonTracer.SetFloat("_Boost", 5f);
			GameObject laserTracer = PrefabAPI.InstantiateClone(await BetterSonLaserPlugin.LoadAsset<GameObject>("RoR2/DLC2/FalseSon/FalseSonPreLaser.prefab"), "FalseSonCustomLaserTracer", false);
			LineRenderer line = laserTracer.GetComponent<LineRenderer>();
			line.startColor = Color32.op_Implicit(new Color32((byte)0, (byte)6, byte.MaxValue, byte.MaxValue));
			line.endColor = new Color(0f, 255f, 203f, 255f);
			((Renderer)line).materials = (Material[])(object)new Material[1] { sonTracer };
			return laserTracer;
		}

		public IEnumerable<Type> GetEntityStates()
		{
			return new Type[2]
			{
				typeof(BetterLaserCharge),
				typeof(BetterLaserFire)
			};
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private Task <>n__0()
		{
			return ((Concentric)this).Initialize();
		}
	}
	public class BetterLaserChargeEffect : Concentric, IGenericObject, IGameObject
	{
		async Task<GameObject> IGenericObject.BuildObject()
		{
			GameObject effect = PrefabAPI.InstantiateClone(await BetterSonLaserPlugin.LoadAsset<GameObject>("RoR2/DLC2/FalseSonBoss/LunarGazePlusChargeEffect.prefab"), "BetterSonLaserChargeEffect", false);
			GameObject sparks = ((Component)effect.transform.GetChild(1)).gameObject;
			sparks.transform.localScale = Vector3.one * 0.5f;
			GameObject rocks = ((Component)sparks.transform.GetChild(2)).gameObject;
			ParticleSystem system = rocks.GetComponent<ParticleSystem>();
			ShapeModule shapeModule = system.shape;
			((ShapeModule)(ref shapeModule)).scale = Vector3.one * 0.6f;
			system.emissionRate = 25f;
			GameObject flare = ((Component)sparks.transform.GetChild(1)).gameObject;
			flare.transform.localScale = Vector3.one * 0.7f;
			return effect;
		}
	}
	public class BetterLaserFirePrefab : Concentric, IGenericObject, IGameObject
	{
		async Task<GameObject> IGenericObject.BuildObject()
		{
			GameObject effect = PrefabAPI.InstantiateClone(await BetterSonLaserPlugin.LoadAsset<GameObject>("RoR2/DLC2/FalseSonBoss/LunarGazePlusFireLaser.prefab"), "BetterSonLaserFirePrefab", false);
			GameObject eyeFlare = ((Component)effect.transform.Find("LaserTitan 3 (1)/Start/Flare/Flare (1)")).gameObject;
			eyeFlare.transform.localScale = Vector3.one * 0.5f;
			GameObject lightshaftThing = ((Component)effect.transform.Find("LaserTitan 3 (1)/Start/Flare/Flare (3)")).gameObject;
			lightshaftThing.transform.localScale = Vector3.one * 0.6f;
			GameObject blueThing = ((Component)effect.transform.Find("LaserTitan 3 (1)/Start/Flare")).gameObject;
			blueThing.transform.localScale = Vector3.one * 0.5f;
			return effect;
		}
	}
	public class BetterLaserFireMuzzleFlash : Concentric, IEffect, IGameObject
	{
		async Task<GameObject> IEffect.BuildObject()
		{
			GameObject effect = PrefabAPI.InstantiateClone(await BetterSonLaserPlugin.LoadAsset<GameObject>("RoR2/DLC2/FalseSonBoss/LunarGazeFireEffect.prefab"), "BetterSonLaserFireMuzzleFlash", false);
			GameObject sparks = ((Component)effect.transform.GetChild(0)).gameObject;
			sparks.transform.localScale = Vector3.one * 0.5f;
			return effect;
		}
	}
	public class WhyDoesGearboxUseLegacyResourcesAPI : Concentric, IEffect, IGameObject
	{
		async Task<GameObject> IEffect.BuildObject()
		{
			return PrefabAPI.InstantiateClone(await BetterSonLaserPlugin.LoadAsset<GameObject>("RoR2/DLC2/FalseSonBoss/LunarRainExplosionVFX.prefab"), "BetterSonLaserDoneChargingEffect", false);
		}
	}
	[BepInPlugin("com.Nines.BetterSonLaser", "BetterSonLaser", "1.0.0")]
	public class BetterSonLaserPlugin : BaseUnityPlugin
	{
		private class ContentPackProvider : IContentPackProvider
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static CollectContentPackProvidersDelegate <>9__7_0;

				internal void <Initialize>b__7_0(AddContentPackProviderDelegate provider)
				{
					provider.Invoke((IContentPackProvider)(object)new ContentPackProvider());
				}
			}

			private static Task<ContentPack> _contentPack;

			private static string _identifier;

			public string identifier => _identifier;

			public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
			{
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
			{
				while (!_contentPack.IsCompleted)
				{
					yield return null;
				}
				if (_contentPack.IsFaulted)
				{
					throw _contentPack.Exception;
				}
				ContentPack.Copy(_contentPack.Result, args.output);
				args.ReportProgress(1f);
			}

			public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
			{
				args.ReportProgress(1f);
				log.LogInfo((object)"Contentpack finished");
				yield break;
			}

			internal static void Initialize(string identifier, Task<ContentPack> pack)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				_identifier = identifier;
				_contentPack = pack;
				object obj = <>c.<>9__7_0;
				if (obj == null)
				{
					CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate provider)
					{
						provider.Invoke((IContentPackProvider)(object)new ContentPackProvider());
					};
					<>c.<>9__7_0 = val;
					obj = (object)val;
				}
				ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
			}
		}

		public const string AssetBundleName = "sondle";

		public const string SoundBankName = "";

		public static Dictionary<string, AssetBundle> bundles = new Dictionary<string, AssetBundle>();

		public static string? pluginPath;

		public static BetterSonLaserPlugin instance = null;

		public static ManualLogSource log = null;

		public static bool soundBankQueued;

		public const string Guid = "com.Nines.BetterSonLaser";

		public const string Name = "BetterSonLaser";

		public const string Version = "1.0.0";

		public void Awake()
		{
			instance = this;
			log = ((BaseUnityPlugin)this).Logger;
			log.LogDebug((object)"Getting Plugin Path");
			pluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? throw new InvalidOperationException("Failed to find path of plugin.");
			Language.collectLanguageRootFolders += delegate(List<string> folders)
			{
				folders.Add(Path.Combine(pluginPath, "Language"));
			};
			log.LogDebug((object)"Loading Concentric Bundle");
			string path2 = Path.Join((ReadOnlySpan<char>)pluginPath, (ReadOnlySpan<char>)"Assets");
			string[] bundlePaths = (from x in Directory.EnumerateFiles(path2)
				where !x.EndsWith("manifest")
				select x).ToArray();
			string[] array = bundlePaths;
			foreach (string path in array)
			{
				((AsyncOperation)AssetBundle.LoadFromFileAsync(path)).completed += delegate(AsyncOperation operation)
				{
					//IL_002a: Unknown result type (might be due to invalid IL or missing references)
					string fileName = Path.GetFileName(path);
					log.LogDebug((object)(fileName + " Bundle Loaded"));
					bundles[fileName] = ((AssetBundleCreateRequest)operation).assetBundle;
					if (bundles.Count == bundlePaths.Length)
					{
						log.LogDebug((object)"Loading ContentPack");
						ContentPackProvider.Initialize(((BaseUnityPlugin)this).Info.Metadata.GUID, Concentric.BuildContentPack(Assembly.GetExecutingAssembly()));
					}
				};
			}
			log.LogDebug((object)"Finished Awake");
		}

		public static Task<T> LoadAsset<T>(string assetPath) where T : Object
		{
			//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_007c: 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_00ac: 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)
			string text;
			int length;
			if (assetPath.StartsWith("addressable:"))
			{
				text = assetPath;
				length = "addressable:".Length;
				return Addressables.LoadAssetAsync<T>((object)text.Substring(length, text.Length - length)).Task;
			}
			if (assetPath.StartsWith("legacy:"))
			{
				text = assetPath;
				length = "legacy:".Length;
				return LegacyResourcesAPI.LoadAsync<T>(text.Substring(length, text.Length - length)).Task;
			}
			int num = assetPath.IndexOf(":", StringComparison.Ordinal);
			if (num <= 0)
			{
				return Addressables.LoadAssetAsync<T>((object)assetPath).Task;
			}
			TaskCompletionSource<T> source = new TaskCompletionSource<T>();
			AssetBundle obj = bundles[assetPath.Substring(0, num)];
			text = assetPath;
			length = num + 1;
			AssetBundleRequest handle = obj.LoadAssetAsync<T>(text.Substring(length, text.Length - length));
			((AsyncOperation)handle).completed += delegate
			{
				source.SetResult((T)(object)handle.asset);
			};
			return source.Task;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SoundbankLoader), "Start")]
		public static void AddSoundbankToLoader(SoundbankLoader __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!soundBankQueued)
			{
				log.LogDebug((object)"Soundbank Added To Queue");
				AkSoundEngine.AddBasePath(pluginPath);
				__instance.soundbankStrings = CollectionExtensions.AddItem<string>((IEnumerable<string>)__instance.soundbankStrings, "").ToArray();
				soundBankQueued = true;
			}
		}
	}
}