Decompiled source of SeekerRevert v1.0.0

SeekerRevert.dll

Decompiled 12 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using EntityStates.Seeker;
using HG.GeneralSerializer;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using RoR2;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SeekerRevert")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ead5fd7923f0a46d22b39512e1b3c060055229c4")]
[assembly: AssemblyProduct("SeekerRevert")]
[assembly: AssemblyTitle("SeekerRevert")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 SeekerRevert
{
	[BepInPlugin("com.SHODAN.SeekerRevert", "SeekerRevert", "1.0.0")]
	public class SeekerRevertPlugin : BaseUnityPlugin
	{
		private const string Seeker = "RoR2/DLC2/Seeker/";

		private ILHook meditateHook;

		private void Awake()
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			CharacterBody component = Load<GameObject>("RoR2/DLC2/Seeker/SeekerBody.prefab").GetComponent<CharacterBody>();
			component.baseMaxHealth = 115f;
			component.levelMaxHealth = 34f;
			component.baseArmor = 20f;
			component.baseDamage = 12f;
			component.levelDamage = 2.4f;
			SetStateField("EntityStates.Seeker.Meditate.asset", "blastRadius", "10");
			SetStateField("EntityStates.Seeker.Meditate.asset", "blastRadiusScaling", "1");
			SetStateField("EntityStates.Seeker.UnseenHand.asset", "fistDamageCoefficient", "6");
			UnseenHandHealingProjectile component2 = Load<GameObject>("RoR2/DLC2/Seeker/UnseenHandMovingProjectile.prefab").GetComponent<UnseenHandHealingProjectile>();
			component2.fractionOfDamage = 0.035f;
			component2.chakraIncrease = 0.04f;
			meditateHook = new ILHook((MethodBase)typeof(Meditate).GetMethod("Update"), (Manipulator)delegate(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				if (val.TryGotoNext(new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStfld<BlastAttack>(x, "losType")
				}))
				{
					val.Emit(OpCodes.Pop);
					val.Emit(OpCodes.Ldc_I4, 0);
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Meditate line of sight hook failed");
				}
			});
			Language.onCurrentLanguageChanged += FixUnseenHandText;
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Seeker reverted: {component.baseMaxHealth} HP, {component.baseArmor} armor, {component.baseDamage} damage, Unseen Hand heal {component2.fractionOfDamage}");
		}

		private static T Load<T>(string key)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<T>((object)key).WaitForCompletion();
		}

		private void SetStateField(string asset, string field, string value)
		{
			SerializedField[] serializedFields = Load<EntityStateConfiguration>("RoR2/DLC2/Seeker/" + asset).serializedFieldsCollection.serializedFields;
			for (int i = 0; i < serializedFields.Length; i++)
			{
				if (!(serializedFields[i].fieldName != field))
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)(asset + " " + field + ": " + serializedFields[i].fieldValue.stringValue + " -> " + value));
					serializedFields[i].fieldValue.stringValue = value;
					return;
				}
			}
			((BaseUnityPlugin)this).Logger.LogError((object)(asset + " has no field " + field));
		}

		private static void FixUnseenHandText()
		{
			Language currentLanguage = Language.currentLanguage;
			if (currentLanguage != null && currentLanguage.TokenIsRegistered("SEEKER_SECONDARY_DESCRIPTION"))
			{
				string localizedStringByToken = currentLanguage.GetLocalizedStringByToken("SEEKER_SECONDARY_DESCRIPTION");
				currentLanguage.SetStringByToken("SEEKER_SECONDARY_DESCRIPTION", localizedStringByToken.Replace("750", "600").Replace("2.6", "3.5").Replace("2,6", "3,5"));
			}
		}
	}
}