Decompiled source of HalcyonFixes v1.1.0

HalcyonFixes.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Halcyonite;
using Microsoft.CodeAnalysis;
using On.EntityStates.Halcyonite;
using RoR2;
using RoR2.Skills;
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("HalcyonFixes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3a9d38d0d9de0760904aae5bf99a184495cb911f")]
[assembly: AssemblyProduct("HalcyonFixes")]
[assembly: AssemblyTitle("HalcyonFixes")]
[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 HalcyonFixes
{
	[BepInPlugin("Onyx.HalcyonFixes", "HalcyonFixes", "1.1.0")]
	public class HalcyonFixes : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_OnEnter <>9__4_0;

			public static hook_OnEnter <>9__4_1;

			internal void <Awake>b__4_0(orig_OnEnter orig, WhirlwindWarmUp self)
			{
				if (((EntityState)self).isAuthority)
				{
					((EntityState)self).outer.SetNextState((EntityState)(object)new Whirlwind());
				}
			}

			internal void <Awake>b__4_1(orig_OnEnter orig, SpawnState self)
			{
				SpawnState.duration = 2f;
				orig.Invoke(self);
				SpawnState.duration = 2.3f;
			}
		}

		public const string PluginGUID = "Onyx.HalcyonFixes";

		public const string PluginAuthor = "Onyx";

		public const string PluginName = "HalcyonFixes";

		public const string PluginVersion = "1.1.0";

		public void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0060: Expected O, but got Unknown
			//IL_007a: 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_0085: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC2/Halcyonite/HalcyoniteMonsterTriLaser.asset").WaitForCompletion();
			val.interruptPriority = (InterruptPriority)0;
			val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC2/Halcyonite/HalcyoniteMonsterWhirlwindRush.asset").WaitForCompletion();
			val.interruptPriority = (InterruptPriority)0;
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				hook_OnEnter val2 = delegate(orig_OnEnter orig, WhirlwindWarmUp self)
				{
					if (((EntityState)self).isAuthority)
					{
						((EntityState)self).outer.SetNextState((EntityState)(object)new Whirlwind());
					}
				};
				<>c.<>9__4_0 = val2;
				obj = (object)val2;
			}
			WhirlwindWarmUp.OnEnter += (hook_OnEnter)obj;
			object obj2 = <>c.<>9__4_1;
			if (obj2 == null)
			{
				hook_OnEnter val3 = delegate(orig_OnEnter orig, SpawnState self)
				{
					SpawnState.duration = 2f;
					orig.Invoke(self);
					SpawnState.duration = 2.3f;
				};
				<>c.<>9__4_1 = val3;
				obj2 = (object)val3;
			}
			SpawnState.OnEnter += (hook_OnEnter)obj2;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public class Whirlwind : BaseState
	{
		public enum PersuitState
		{
			None,
			Warmup,
			Dash,
			Decelerate,
			Land
		}

		public static GameObject whirlWindVortexVFXPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Halcyonite/WhirlWindHalcyoniteVortexVFX.prefab").WaitForCompletion();

		public const float maxSearchDist = 100f;

		public const float dashSpeedCoefficient = 20f;

		public const float attackInterval = 0.2f;

		public const float attackRadius = 10f;

		public const float decelerateDuration = 1f;

		public const float baseForce = 1500f;

		public const float dashSafeExitDuration = 5f;

		private PersuitState state;

		private CharacterBody targetBody;

		private Vector3 targetPos;

		private float attackTimeStamp;

		private float startDecelerateTimeStamp;

		private Vector3 targetMoveDirt;

		private bool startedLand;

		private float dashSafeOutTime;

		private GameObject whirlwindVortexInstance;

		public override void OnEnter()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			Animator modelAnimator = ((EntityState)this).GetModelAnimator();
			ChildLocator component = ((Component)modelAnimator).GetComponent<ChildLocator>();
			((EntityState)this).PlayCrossfade("FullBody Override", "WhirlwindRushEnter", "WhirlwindRush.playbackRate", 0.5f, 0.1f);
			Util.PlaySound("Play_halcyonite_skill3_start", ((EntityState)this).gameObject);
			((BaseState)this).SmallHop(((EntityState)this).characterMotor, 9f);
			CharacterGravityParameters gravityParameters = ((EntityState)this).characterMotor.gravityParameters;
			gravityParameters.channeledAntiGravityGranterCount++;
			((EntityState)this).characterMotor.gravityParameters = gravityParameters;
			CharacterFlightParameters flightParameters = ((EntityState)this).characterMotor.flightParameters;
			flightParameters.channeledFlightGranterCount++;
			((EntityState)this).characterMotor.flightParameters = flightParameters;
			((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = 0f;
			state = PersuitState.Warmup;
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (NetworkServer.active)
			{
				switch (state)
				{
				case PersuitState.None:
					break;
				case PersuitState.Dash:
					UpdateDash();
					UpdateAttack();
					break;
				case PersuitState.Decelerate:
					UpdateDecelerate();
					UpdateAttack();
					break;
				case PersuitState.Land:
					UpdateLand();
					UpdateAttack();
					break;
				case PersuitState.Warmup:
					update_warmup();
					break;
				}
			}
		}

		public void update_warmup()
		{
			//IL_0075: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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)
			if (((EntityState)this).fixedAge > 0.5f)
			{
				Util.PlaySound("Play_halcyonite_skill3_loop", ((EntityState)this).gameObject);
				((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = 1f;
				ChildLocator modelChildLocator = ((EntityState)this).GetModelChildLocator();
				if ((Object)(object)whirlWindVortexVFXPrefab != (Object)null)
				{
					Transform val = modelChildLocator.FindChild("WhirlWindPoint");
					whirlwindVortexInstance = Object.Instantiate<GameObject>(whirlWindVortexVFXPrefab, val);
				}
				FindTarget();
				Vector3 val2 = targetPos - ((EntityState)this).transform.position;
				targetMoveDirt = ((Vector3)(ref val2)).normalized;
				((EntityState)this).characterDirection.moveVector = targetMoveDirt;
				attackTimeStamp = ((EntityState)this).fixedAge;
			}
		}

		private void FindTarget()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			Ray aimRay = ((BaseState)this).GetAimRay();
			BullseyeSearch val = new BullseyeSearch();
			val.viewer = ((EntityState)this).characterBody;
			val.maxDistanceFilter = 100f;
			val.searchOrigin = ((Ray)(ref aimRay)).origin;
			val.searchDirection = ((Ray)(ref aimRay)).direction;
			val.filterByLoS = false;
			val.sortMode = (SortMode)2;
			val.teamMaskFilter = TeamMask.allButNeutral;
			if (Object.op_Implicit((Object)(object)((EntityState)this).teamComponent))
			{
				((TeamMask)(ref val.teamMaskFilter)).RemoveTeam(((EntityState)this).teamComponent.teamIndex);
			}
			val.RefreshCandidates();
			HurtBox val2 = val.GetResults().FirstOrDefault();
			if ((Object)(object)val2 != (Object)null)
			{
				targetBody = val2.healthComponent.body;
				Vector3 footPosition = targetBody.footPosition;
				Vector3 val3 = ((EntityState)this).transform.position - targetBody.footPosition;
				targetPos = footPosition + ((Vector3)(ref val3)).normalized * 2f;
			}
			else
			{
				targetPos = ((Ray)(ref aimRay)).origin + ((Ray)(ref aimRay)).direction;
			}
			state = PersuitState.Dash;
		}

		private void UpdateAttack()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0065: 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_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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_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_00e5: Unknown result type (might be due to invalid IL or missing references)
			if (((EntityState)this).fixedAge > attackTimeStamp && NetworkServer.active)
			{
				attackTimeStamp = ((EntityState)this).fixedAge + 0.2f;
				BlastAttack val = new BlastAttack();
				val.attacker = ((Component)((EntityState)this).characterBody).gameObject;
				val.inflictor = ((Component)((EntityState)this).characterBody).gameObject;
				val.teamIndex = ((EntityState)this).characterBody.teamComponent.teamIndex;
				val.position = ((EntityState)this).transform.position;
				val.procCoefficient = 0f;
				val.radius = 10f;
				val.baseForce = 1500f;
				val.baseDamage = ((EntityState)this).characterBody.damage * 0.2f;
				val.bonusForce = Vector3.zero;
				val.crit = false;
				val.damageType = DamageTypeCombo.op_Implicit((DamageType)0);
				val.falloffModel = (FalloffModel)0;
				val.attackerFiltering = (AttackerFiltering)0;
				val.Fire();
			}
		}

		private void UpdateLand()
		{
			//IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			if (!startedLand)
			{
				CharacterGravityParameters gravityParameters = ((EntityState)this).characterMotor.gravityParameters;
				gravityParameters.channeledAntiGravityGranterCount--;
				((EntityState)this).characterMotor.gravityParameters = gravityParameters;
				CharacterFlightParameters flightParameters = ((EntityState)this).characterMotor.flightParameters;
				flightParameters.channeledFlightGranterCount--;
				((EntityState)this).characterMotor.flightParameters = flightParameters;
				startedLand = true;
			}
			if (((EntityState)this).characterMotor.isGrounded)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		private void UpdateDecelerate()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (((EntityState)this).fixedAge > startDecelerateTimeStamp + 1f)
			{
				state = PersuitState.Land;
			}
			((EntityState)this).characterMotor.velocity = ((Vector3)(ref targetMoveDirt)).normalized * 20f * Mathf.Lerp(1f, 0f, (((EntityState)this).fixedAge - startDecelerateTimeStamp) / 1f);
		}

		private void UpdateDash()
		{
			//IL_0048: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			dashSafeOutTime += Time.deltaTime;
			if (dashSafeOutTime > 5f)
			{
				state = PersuitState.Decelerate;
				startDecelerateTimeStamp = ((EntityState)this).fixedAge;
			}
			else
			{
				((EntityState)this).characterMotor.velocity = ((Vector3)(ref targetMoveDirt)).normalized * 20f;
				CheckIfArrived();
			}
		}

		private void CheckIfArrived()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			Ray aimRay = ((BaseState)this).GetAimRay();
			if (Vector3.Dot(((Ray)(ref aimRay)).direction, targetMoveDirt) < 0f)
			{
				state = PersuitState.Decelerate;
				startDecelerateTimeStamp = ((EntityState)this).fixedAge;
			}
		}

		public override void OnExit()
		{
			//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)
			DisableAntiGravity();
			((EntityState)this).characterMotor.walkSpeedPenaltyCoefficient = 1f;
			((EntityState)this).characterMotor.velocity = Vector3.zero;
			((EntityState)this).PlayCrossfade("FullBody Override", "WhirlwindRushExit", "WhirlwindRush.playbackRate", 1f, 0.1f);
			Util.PlaySound("Play_halcyonite_skill3_end", ((EntityState)this).gameObject);
			Util.PlaySound("Stop_halcyonite_skill3_loop", ((EntityState)this).gameObject);
			((EntityState)this).characterBody.RecalculateStats();
			if ((Object)(object)whirlwindVortexInstance != (Object)null)
			{
				EntityState.Destroy((Object)(object)whirlwindVortexInstance);
			}
		}

		private void DisableAntiGravity()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			CharacterGravityParameters gravityParameters = ((EntityState)this).characterMotor.gravityParameters;
			gravityParameters.channeledAntiGravityGranterCount = 0;
			((EntityState)this).characterMotor.gravityParameters = gravityParameters;
			CharacterFlightParameters flightParameters = ((EntityState)this).characterMotor.flightParameters;
			flightParameters.channeledFlightGranterCount = 0;
			((EntityState)this).characterMotor.flightParameters = flightParameters;
		}

		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;
		}
	}
}