Decompiled source of HalcyonFixes v1.3.0

plugins/HalcyonFixes.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Halcyonite;
using HG;
using IL.EntityStates.Halcyonite;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.Halcyonite;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;

[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+94e16bc375aeaba50f721ca6ef2c036ab7afa447")]
[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]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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.2.5")]
	public class HalcyonFixes : BaseUnityPlugin
	{
		public const string PluginGUID = "Onyx.HalcyonFixes";

		public const string PluginAuthor = "Onyx";

		public const string PluginName = "HalcyonFixes";

		public const string PluginVersion = "1.2.5";

		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_0023: 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_0070: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC2/Halcyonite/HalcyoniteMonsterWhirlwindRush.asset").WaitForCompletion();
			val.interruptPriority = (InterruptPriority)0;
			AssetReferenceT<GameObject> val2 = new AssetReferenceT<GameObject>(RoR2_DLC2.ShrineHalcyonite_prefab);
			AsyncOperationHandle<GameObject> val3 = AssetAsyncReferenceManager<GameObject>.LoadAsset(val2, (AsyncReferenceHandleUnloadType)2);
			val3.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				GameObject gameObject = ((Component)x.Result.transform.Find("RangeIndicator/RangeFX/CrystalLines/Particle SystemCollider Kill Trigger")).gameObject;
				gameObject.layer = (int)(ref LayerIndex.collideWithCharacterHullOnly);
				((Behaviour)((Component)x.Result.transform.Find("Camp 1 - Flavor Props (Inner Radius)")).GetComponent<CombatDirector>()).enabled = false;
				((Behaviour)((Component)x.Result.transform.Find("Camp 2 - Flavor Props (Outer Radius)")).GetComponent<CombatDirector>()).enabled = false;
			};
			AssetReferenceT<EntityStateConfiguration> val4 = new AssetReferenceT<EntityStateConfiguration>(RoR2_DLC2_Halcyonite.EntityStates_HalcyoniteMonster_GoldenSwipe_asset);
			AsyncOperationHandle<EntityStateConfiguration> val5 = AssetAsyncReferenceManager<EntityStateConfiguration>.LoadAsset(val4, (AsyncReferenceHandleUnloadType)2);
			val5.Completed += delegate(AsyncOperationHandle<EntityStateConfiguration> x)
			{
				//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)
				x.Result.targetType = (SerializableSystemType)typeof(FixedSwipe);
			};
			val4 = new AssetReferenceT<EntityStateConfiguration>(RoR2_DLC2_Halcyonite.EntityStates_HalcyoniteMonster_GoldenSlash_asset);
			val5 = AssetAsyncReferenceManager<EntityStateConfiguration>.LoadAsset(val4, (AsyncReferenceHandleUnloadType)2);
			val5.Completed += delegate(AsyncOperationHandle<EntityStateConfiguration> x)
			{
				//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)
				x.Result.targetType = (SerializableSystemType)typeof(FixedSlash);
			};
			AssetReferenceT<SkillDef> val6 = new AssetReferenceT<SkillDef>(RoR2_DLC2_Halcyonite.HalcyoniteMonsterGoldenSwipe_asset);
			AsyncOperationHandle<SkillDef> val7 = AssetAsyncReferenceManager<SkillDef>.LoadAsset(val6, (AsyncReferenceHandleUnloadType)2);
			val7.Completed += delegate(AsyncOperationHandle<SkillDef> x)
			{
				//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)
				x.Result.activationState = new SerializableEntityStateType(typeof(FixedSwipe));
			};
			val6 = new AssetReferenceT<SkillDef>(RoR2_DLC2_Halcyonite.HalcyoniteMonsterGoldenSlash_asset);
			val7 = AssetAsyncReferenceManager<SkillDef>.LoadAsset(val6, (AsyncReferenceHandleUnloadType)2);
			val7.Completed += delegate(AsyncOperationHandle<SkillDef> x)
			{
				//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)
				x.Result.activationState = new SerializableEntityStateType(typeof(FixedSlash));
			};
			bool flag = default(bool);
			ContentAddition.AddEntityState<FixedSlash>(ref flag);
			ContentAddition.AddEntityState<FixedSwipe>(ref flag);
			WhirlWindPersuitCycle.UpdateDecelerate += new hook_UpdateDecelerate(UpdateDecelerate);
			WhirlWindPersuitCycle.CheckIfArrived += new Manipulator(CheckIfArrived);
			TriLaser.FireTriLaser += new Manipulator(FireTriLaser);
			WhirlwindWarmUp.OnEnter += new Manipulator(WhirlwindWarmUp_OnEnter);
		}

		private void WhirlwindWarmUp_OnEnter(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int num = 0;
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(EntityState), "PlayCrossfade")
			}) && val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(WhirlwindWarmUp), "duration")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<float, WhirlwindWarmUp, float>>((Func<float, WhirlwindWarmUp, float>)fuck);
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " IL Hook failed!");
			}
			static float fuck(float f, WhirlwindWarmUp self)
			{
				Log.Info("oooooooooooooooooooooooooooooooooooo");
				return f * ((BaseState)self).attackSpeedStat * 2f;
			}
		}

		private void FireTriLaser(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			ILCursor val = new ILCursor(il);
			int laserVectorLoc = 0;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(RaycastHit), "get_point"),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref laserVectorLoc)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc, laserVectorLoc);
				val.EmitDelegate<Func<TriLaser, Vector3, Vector3>>((Func<TriLaser, Vector3, Vector3>)checkWallDistance);
				val.Emit(OpCodes.Stloc, laserVectorLoc);
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " IL Hook failed!");
			}
			static Vector3 checkWallDistance(TriLaser self, Vector3 laserVector)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: 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)
				//IL_001c: 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_002b: 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_0040: 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_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: 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)
				Vector3 origin = ((Ray)(ref self.modifiedAimRay)).origin;
				Vector3 direction = ((Ray)(ref self.modifiedAimRay)).direction;
				Ray val2 = default(Ray);
				((Ray)(ref val2))..ctor(origin + ((Vector3)(ref direction)).normalized * -1f, ((Ray)(ref self.modifiedAimRay)).direction);
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(val2, ref val3, 2f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask)))
				{
					return ((RaycastHit)(ref val3)).point;
				}
				return laserVector;
			}
		}

		private void CheckIfArrived(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(WhirlWindPersuitCycle), "targetPos")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<Vector3, WhirlWindPersuitCycle, Vector3>>((Func<Vector3, WhirlWindPersuitCycle, Vector3>)targetToCurrentPos);
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " IL Hook failed!");
			}
			static Vector3 targetToCurrentPos(Vector3 target, WhirlWindPersuitCycle self)
			{
				//IL_0014: 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_0032: 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_0035: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)self.targetBody))
				{
					_ = self.targetBody.footPosition;
					if (true)
					{
						return self.targetBody.footPosition;
					}
				}
				return target;
			}
		}

		private void UpdateDecelerate(orig_UpdateDecelerate orig, WhirlWindPersuitCycle self)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			float num = Mathf.Lerp(WhirlWindPersuitCycle.dashSpeedCoefficient, 0f, (((EntityState)self).fixedAge - self.startDecelerateTimeStamp) / WhirlWindPersuitCycle.decelerateDuration);
			((EntityState)self).characterMotor.velocity = ((Vector3)(ref self.targetMoveDirt)).normalized * num;
			((EntityState)self).characterDirection.moveVector = ((Vector3)(ref self.targetMoveDirt)).normalized;
		}
	}
	public class FixedSwipe : GoldenSwipe
	{
		public override bool allowExitFire => false;

		public override void OnEnter()
		{
			//IL_0013: 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_0032: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			((BasicMeleeAttack)this).pushAwayForce = 0f;
			((BasicMeleeAttack)this).forceVector = new Vector3(((EntityState)this).inputBank.aimDirection.x, 0.5f, ((EntityState)this).inputBank.aimDirection.z) * 5000f;
			((HalcyoniteBaseMeleeSkillState)this).OnEnter();
		}

		public override void FixedUpdate()
		{
			((BasicMeleeAttack)this).FixedUpdate();
		}
	}
	public class FixedSlash : GoldenSlash
	{
		public override bool allowExitFire => false;

		public override void OnEnter()
		{
			//IL_0013: 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_0032: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			((BasicMeleeAttack)this).pushAwayForce = 0f;
			((BasicMeleeAttack)this).forceVector = new Vector3(((EntityState)this).inputBank.aimDirection.x, 0.5f, ((EntityState)this).inputBank.aimDirection.z) * 5000f;
			((HalcyoniteBaseMeleeSkillState)this).OnEnter();
		}

		public override void FixedUpdate()
		{
			((BasicMeleeAttack)this).FixedUpdate();
		}
	}
	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);
		}
	}
}