Decompiled source of HallowedEnemiesTweaks v1.0.0

HallowedEnemiesTweaks.dll

Decompiled 6 hours 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 HG.GeneralSerializer;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.CharacterAI;
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("HallowedEnemiesTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HallowedEnemiesTweaks")]
[assembly: AssemblyTitle("HallowedEnemiesTweaks")]
[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 HallowedEnemiesTweaks
{
	[BepInPlugin("CrypticAuthor.HallowedEnemiesTweaks", "HallowedEnemiesTweaks", "1.0.0")]
	public class HallowedEnemiesTweaks : BaseUnityPlugin
	{
		public const string PluginGUID = "CrypticAuthor.HallowedEnemiesTweaks";

		public const string PluginAuthor = "CrypticAuthor";

		public const string PluginName = "HallowedEnemiesTweaks";

		public const string PluginVersion = "1.0.0";

		public GameObject archerBody = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC4_LynxArcher.LynxArcherBody_prefab).WaitForCompletion();

		public GameObject assassinBody = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC4_LynxAmbusher.LynxAmbusherBody_prefab).WaitForCompletion();

		public GameObject berserkerBody = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC4_Lynx2.Lynx2Body_prefab).WaitForCompletion();

		public SpawnCard archerCredit = Addressables.LoadAssetAsync<SpawnCard>((object)RoR2_DLC4_LynxArcher.cscLynxArcher_asset).WaitForCompletion();

		public static bool TryModifyFieldValue<T>(EntityStateConfiguration entityStateConfiguration, string fieldName, T value)
		{
			ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName);
			Type typeFromHandle = typeof(T);
			if (Object.op_Implicit(orCreateField.fieldValue.objectValue) && ((object)orCreateField.fieldValue.objectValue).GetType().IsAssignableFrom(typeFromHandle))
			{
				ref Object objectValue = ref orCreateField.fieldValue.objectValue;
				object obj = value;
				objectValue = (Object)((obj is Object) ? obj : null);
				return true;
			}
			if (orCreateField.fieldValue.stringValue != null && StringSerializer.CanSerializeType(typeFromHandle))
			{
				orCreateField.fieldValue.stringValue = StringSerializer.Serialize(typeFromHandle, (object)value);
				return true;
			}
			return false;
		}

		public void Awake()
		{
			//IL_0060: 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_00b5: 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)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			BerserkerMaster();
			ArcherMaster();
			FireArrows();
			FrenziedPound();
			ShruumRegrowth();
			Swiping();
			CharacterBody val = default(CharacterBody);
			if (Object.op_Implicit((Object)(object)assassinBody) && assassinBody.TryGetComponent<CharacterBody>(ref val))
			{
				val.baseMoveSpeed = 12f;
			}
			EntityStateConfiguration entityStateConfiguration = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)RoR2_DLC4_LynxAmbusher.EntityStates_LynxAmbusher_HunterCloak_asset).WaitForCompletion();
			TryModifyFieldValue(entityStateConfiguration, "doFixedDuration", 1f);
			CharacterBody val2 = default(CharacterBody);
			if (Object.op_Implicit((Object)(object)berserkerBody) && berserkerBody.TryGetComponent<CharacterBody>(ref val2))
			{
				val2.baseMoveSpeed = 11f;
			}
			EntityStateConfiguration entityStateConfiguration2 = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)RoR2_DLC4_Lynx2.EntityStates_Lynx2Monster_TwoSwipes_asset).WaitForCompletion();
			EntityStateConfiguration entityStateConfiguration3 = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)RoR2_DLC4_Lynx2.EntityStates_Lynx2Monster_FrenziedUpsetPoundJump_asset).WaitForCompletion();
			EntityStateConfiguration entityStateConfiguration4 = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)RoR2_DLC4_Lynx2.EntityStates_Lynx2Monster_FrenziedUpsetPoundSlam_asset).WaitForCompletion();
			TryModifyFieldValue(entityStateConfiguration2, "baseDuration", 1.6f);
			TryModifyFieldValue(entityStateConfiguration2, "walkSpeedPenaltyCoefficient", 0.8f);
			TryModifyFieldValue(entityStateConfiguration2, "selfForce", 4000f);
			TryModifyFieldValue(entityStateConfiguration3, "swipeRange", 7f);
			TryModifyFieldValue(entityStateConfiguration3, "landingDelay", 2f);
			TryModifyFieldValue(entityStateConfiguration3, "jumpHeight", 26f);
			TryModifyFieldValue(entityStateConfiguration3, "jumpSpeed", 58f);
			TryModifyFieldValue(entityStateConfiguration3, "minJumpTime", 0.6f);
			TryModifyFieldValue(entityStateConfiguration3, "maxJumpCount", 1f);
			TryModifyFieldValue(entityStateConfiguration4, "animationDuration", 2f);
			TryModifyFieldValue(entityStateConfiguration4, "slamTerminalVelocity", 17f);
			TryModifyFieldValue(entityStateConfiguration4, "gravityCoefficient", 5f);
			TryModifyFieldValue(entityStateConfiguration4, "slamRadius", 4f);
			archerCredit.directorCreditCost = 35;
			CharacterBody val3 = default(CharacterBody);
			if (Object.op_Implicit((Object)(object)archerBody) && archerBody.TryGetComponent<CharacterBody>(ref val3))
			{
				val3.baseAcceleration = 35f;
				val3.moveSpeed = 13f;
			}
			EntityStateConfiguration entityStateConfiguration5 = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)RoR2_DLC4_LynxArcher.EntityStates_LynxArcher_AimArrow_asset).WaitForCompletion();
			EntityStateConfiguration entityStateConfiguration6 = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)RoR2_DLC4_LynxArcher.EntityStates_LynxArcher_FireArrow_asset).WaitForCompletion();
			TryModifyFieldValue(entityStateConfiguration5, "hopSpeed", 25f);
			TryModifyFieldValue(entityStateConfiguration5, "baseMinimumDuration", 0.4f);
			TryModifyFieldValue(entityStateConfiguration6, "baseDuration", 0.5f);
			TryModifyFieldValue(entityStateConfiguration6, "baseDelayBeforeFiringProjectile", 0.8f);
		}

		private void FireArrows()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<SkillDef> val = AssetAsyncReferenceManager<SkillDef>.LoadAsset(new AssetReferenceT<SkillDef>(RoR2_DLC4_LynxArcher.LynxArcherArrow_asset), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<SkillDef> x)
			{
				SkillDef result = x.Result;
				result.baseRechargeInterval = 4f;
			};
		}

		private void Swiping()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<SkillDef> val = AssetAsyncReferenceManager<SkillDef>.LoadAsset(new AssetReferenceT<SkillDef>(RoR2_DLC4_Lynx2.Lynx2BodyTwoSwipes_asset), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<SkillDef> x)
			{
				SkillDef result = x.Result;
				result.baseRechargeInterval = 0.7f;
			};
		}

		private void FrenziedPound()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<SkillDef> val = AssetAsyncReferenceManager<SkillDef>.LoadAsset(new AssetReferenceT<SkillDef>(RoR2_DLC4_Lynx2.Lynx2BodyFrenziedUpsetPound_asset), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<SkillDef> x)
			{
				SkillDef result = x.Result;
				result.baseRechargeInterval = 8f;
			};
		}

		private void ShruumRegrowth()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<SkillDef> val = AssetAsyncReferenceManager<SkillDef>.LoadAsset(new AssetReferenceT<SkillDef>(RoR2_DLC4_BigMush.BigMushBodyRegrowth_asset), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<SkillDef> x)
			{
				SkillDef result = x.Result;
				result.beginSkillCooldownOnSkillEnd = true;
			};
		}

		private void BerserkerMaster()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC4_Lynx2.Lynx2Master_prefab), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				AISkillDriver[] components = x.Result.GetComponents<AISkillDriver>();
				BaseAI[] components2 = x.Result.GetComponents<BaseAI>();
				AISkillDriver[] array = components;
				foreach (AISkillDriver val2 in array)
				{
					if (val2.customName == "TwoSwipes")
					{
						val2.aimVectorMaxSpeedOverride = 0.3f;
						val2.maxDistance = 13f;
						val2.movementType = (MovementType)1;
					}
					if (val2.customName == "FrenziedUpset")
					{
						val2.minDistance = 15f;
						val2.maxDistance = 30f;
					}
				}
				BaseAI[] array2 = components2;
				foreach (BaseAI val3 in array2)
				{
					val3.aimVectorMaxSpeed = 500f;
				}
			};
		}

		private void ArcherMaster()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC4_LynxArcher.LynxArcherMaster_prefab), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				AISkillDriver[] components = x.Result.GetComponents<AISkillDriver>();
				AISkillDriver[] array = components;
				foreach (AISkillDriver val2 in array)
				{
					if (val2.customName == "Fire")
					{
						val2.minDistance = 20f;
						val2.maxDistance = 45f;
					}
					if (val2.customName == "Prefire")
					{
						val2.minDistance = 0f;
						val2.maxDistance = 45f;
					}
					if (val2.customName == "PrefireButBlocked")
					{
						val2.minDistance = 0f;
						val2.maxDistance = 45f;
					}
				}
			};
		}
	}
	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);
		}
	}
}