Decompiled source of RiskySeeker v1.0.2

RiskySeeker.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
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.Configuration;
using EntityStates;
using EntityStates.Seeker;
using IL.EntityStates.Seeker;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using RoR2;
using RoR2.Projectile;
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("RiskySeeker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dfdd1c81cea4e920476c54447e92e7b901284b63")]
[assembly: AssemblyProduct("RiskySeeker")]
[assembly: AssemblyTitle("RiskySeeker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}
namespace RiskySeeker
{
	[BepInPlugin("com.RiskyLives.RiskySeeker", "RiskySeeker", "1.0.2")]
	public class RiskySeeker : BaseUnityPlugin
	{
		public static class ConfigOptions
		{
			public static bool buffSpiritPunch;

			public static bool buffUnseenHand;

			public static bool buffMeditate;
		}

		private static GameObject cleanseEffect = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Seeker/SpiritPunchMuzzleFlashVFX.prefab").WaitForCompletion();

		private void Awake()
		{
			ReadConfig();
			BuffSpiritPunch();
			BuffUnseenHand();
			BuffMeditate();
		}

		private void ReadConfig()
		{
			//IL_0011: 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: Expected O, but got Unknown
			//IL_002c: Expected O, but got Unknown
			//IL_0046: 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)
			//IL_0061: Expected O, but got Unknown
			//IL_0061: Expected O, but got Unknown
			//IL_007b: 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_0096: Expected O, but got Unknown
			//IL_0096: Expected O, but got Unknown
			ConfigOptions.buffSpiritPunch = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Spirit Punch"), true, new ConfigDescription("Increase fire rate.", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			ConfigOptions.buffUnseenHand = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Unseen Hand"), true, new ConfigDescription("Damage scales with Tranquility stacks.", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			ConfigOptions.buffMeditate = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Meditate"), true, new ConfigDescription("Stun and increase damage.", (AcceptableValueBase)null, Array.Empty<object>())).Value;
		}

		private void BuffSpiritPunch()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//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)
			if (ConfigOptions.buffSpiritPunch)
			{
				SpiritPunch.OnEnter += new Manipulator(SpiritPunch_OnEnter);
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Seeker/SpiritPunchFinisherProjectile.prefab").WaitForCompletion();
				ProjectileImpactExplosion component = val.GetComponent<ProjectileImpactExplosion>();
				((ProjectileExplosion)component).blastProcCoefficient = 1f;
			}
		}

		private void SpiritPunch_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_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(SpiritPunch), "baseDuration")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<float, SpiritPunch, float>>((Func<float, SpiritPunch, float>)((float duration, SpiritPunch self) => duration * (((int)self.gauntlet != 2) ? 0.5f : 1f)));
			}
			else
			{
				Debug.LogError((object)"RiskySeeker: Spirit Punch IL Hook failed.");
			}
		}

		private void BuffUnseenHand()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//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)
			if (ConfigOptions.buffUnseenHand)
			{
				UnseenHand.FixedUpdate += new Manipulator(UnseenHand_FixedUpdate);
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Seeker/UnseenHandMovingProjectile.prefab").WaitForCompletion();
				UnseenHandHealingProjectile component = val.GetComponent<UnseenHandHealingProjectile>();
				component.chakraIncrease = 0f;
			}
		}

		private void UnseenHand_FixedUpdate(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(BaseState), "damageStat")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<float, UnseenHand, float>>((Func<float, UnseenHand, float>)delegate(float damage, UnseenHand self)
				{
					float num = 1f;
					if (Object.op_Implicit((Object)(object)((EntityState)self).characterBody))
					{
						num += (float)((EntityState)self).characterBody.GetBuffCount(Buffs.ChakraBuff) / 6f;
					}
					return damage * num;
				});
			}
			else
			{
				Debug.LogError((object)"RiskySeeker: Unseen Hand IL Hook failed.");
			}
		}

		private void BuffMeditate()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			if (ConfigOptions.buffMeditate)
			{
				MeditationUI.Update += new Manipulator(MeditationUI_Update);
				SetAddressableEntityStateField("RoR2/DLC2/Seeker/EntityStates.Seeker.Meditate2.asset", "damageCoefficient", "9");
				Language.SetCurrentLanguage += new hook_SetCurrentLanguage(Language_SetCurrentLanguage);
				SeekerController.CmdTriggerHealPulse += new hook_CmdTriggerHealPulse(SeekerController_CmdTriggerHealPulse);
			}
		}

		private void SeekerController_CmdTriggerHealPulse(orig_CmdTriggerHealPulse orig, SeekerController self, float value, Vector3 corePosition, float blastRadius)
		{
			//IL_0004: 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_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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_0095: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, value, corePosition, blastRadius);
			if (!NetworkServer.active)
			{
				return;
			}
			List<ProjectileController> instancesList = InstanceTracker.GetInstancesList<ProjectileController>();
			List<GameObject> list = new List<GameObject>();
			foreach (ProjectileController item in instancesList)
			{
				TeamIndex val = (TeamIndex)((!Object.op_Implicit((Object)(object)self.characterBody.teamComponent)) ? (-1) : ((int)self.characterBody.teamComponent.teamIndex));
				if (!item.cannotBeDeleted && item.teamFilter.teamIndex != val)
				{
					Vector3 val2 = ((Component)item).transform.position - ((Component)self).transform.position;
					if (!(((Vector3)(ref val2)).sqrMagnitude >= blastRadius * blastRadius))
					{
						list.Add(((Component)item).gameObject);
					}
				}
			}
			GameObject[] array = list.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				EffectManager.SimpleEffect(cleanseEffect, array[i].transform.position, array[i].transform.rotation, true);
				Object.Destroy((Object)(object)array[i]);
			}
		}

		private void MeditationUI_Update(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<BlastAttack>(x, "Fire")
			}))
			{
				val.EmitDelegate<Func<BlastAttack, BlastAttack>>((Func<BlastAttack, BlastAttack>)delegate(BlastAttack blast)
				{
					ref DamageType damageType = ref blast.damageType.damageType;
					damageType = (DamageType)((uint)damageType | 0x20u);
					return blast;
				});
			}
			else
			{
				Debug.LogError((object)"RiskySeeker: Meditate IL Hook failed.");
			}
		}

		private void Language_SetCurrentLanguage(orig_SetCurrentLanguage orig, string newCurrentLanguageName)
		{
			orig.Invoke(newCurrentLanguageName);
			string text = Language.GetString("SEEKER_SPECIAL_DESCRIPTION", newCurrentLanguageName).Replace("450", "900");
			Language.currentLanguage.SetStringByToken("SEEKER_SPECIAL_DESCRIPTION", text);
		}

		internal static bool SetAddressableEntityStateField(string fullEntityStatePath, string fieldName, string value)
		{
			//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)
			EntityStateConfiguration val = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)fullEntityStatePath).WaitForCompletion();
			for (int i = 0; i < val.serializedFieldsCollection.serializedFields.Length; i++)
			{
				if (val.serializedFieldsCollection.serializedFields[i].fieldName == fieldName)
				{
					val.serializedFieldsCollection.serializedFields[i].fieldValue.stringValue = value;
					return true;
				}
			}
			return false;
		}
	}
}