Decompiled source of HIFUDevotionTweaks v1.0.0

HIFUDevotionTweaks.dll

Decompiled a month 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.Configuration;
using BepInEx.Logging;
using IL.RoR2;
using IL.RoR2.CharacterAI;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On;
using On.RoR2;
using RoR2;
using RoR2.CharacterAI;
using UnityEngine;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("HIFUDevotionTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HIFUDevotionTweaks")]
[assembly: AssemblyTitle("HIFUDevotionTweaks")]
[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 HIFUDevotionTweaks
{
	[BepInPlugin("HIFU.HIFUDevotionTweaks", "HIFUDevotionTweaks", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "HIFU.HIFUDevotionTweaks";

		public const string PluginAuthor = "HIFU";

		public const string PluginName = "HIFUDevotionTweaks";

		public const string PluginVersion = "1.0.0";

		public static ManualLogSource hdtLogger;

		public static ConfigEntry<bool> improveAI { get; set; }

		public static ConfigEntry<int> itemGainMultiplier { get; set; }

		public static ConfigEntry<bool> buffWeakMfs { get; set; }

		public static ConfigEntry<float> teleportDistance { get; set; }

		public static ConfigEntry<bool> slug { get; set; }

		public static ConfigEntry<bool> oob { get; set; }

		public void Awake()
		{
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			hdtLogger = ((BaseUnityPlugin)this).Logger;
			improveAI = ((BaseUnityPlugin)this).Config.Bind<bool>("The Lems", "Improve AI?", true, "Increases aimbot range and changes movement types");
			itemGainMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("The Lems", "Item gain multiplier", 1, "");
			buffWeakMfs = ((BaseUnityPlugin)this).Config.Bind<bool>("The Lems", "Buff The Small Lems?", true, "Gives them +200% max hp instead of +100%");
			teleportDistance = ((BaseUnityPlugin)this).Config.Bind<float>("The Lems", "Teleport distance", 150f, "");
			slug = ((BaseUnityPlugin)this).Config.Bind<bool>("The Lems", "Give Cautious Slug?", true, "");
			oob = ((BaseUnityPlugin)this).Config.Bind<bool>("The Lems", "Teleport back when out of bounds?", true, "");
			DevotedLemurianController.Start += new hook_Start(DevotedLemurianController_Start);
			DevotionInventoryController.Awake += new hook_Awake(DevotionInventoryController_Awake);
			if (buffWeakMfs.Value)
			{
				DevotionInventoryController.UpdateMinionInventory += new Manipulator(DevotionInventoryController_UpdateMinionInventory);
			}
			if (improveAI.Value)
			{
				CharacterMaster.onStartGlobal += CharacterMaster_onStartGlobal;
			}
			LemurianEggController.SummonLemurian += new Manipulator(LemurianEggController_SummonLemurian);
		}

		private void LemurianEggController_SummonLemurian(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((MoveType)0, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<DevotionInventoryController>(x, "GiveItem")
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				val.EmitDelegate<Func<int, int>>((Func<int, int>)((int useless) => itemGainMultiplier.Value));
			}
		}

		private void CharacterMaster_onStartGlobal(CharacterMaster master)
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody body = master.GetBody();
			DevotedLemurianController val = default(DevotedLemurianController);
			if (!Object.op_Implicit((Object)(object)body) || !((Component)master).TryGetComponent<DevotedLemurianController>(ref val))
			{
				return;
			}
			BaseAI component = ((Component)master).GetComponent<BaseAI>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.fullVision = true;
				component.aimVectorDampTime = Mathf.Max(0.001f, 0.03f);
				component.aimVectorMaxSpeed = 250f;
				component.enemyAttentionDuration = 1.5f;
			}
			string name = ((Object)master).name;
			string text = name;
			if (!(text == "LemurianBruiserMaster(Clone)"))
			{
				if (text == "LemurianMaster(Clone)")
				{
					AISkillDriver val2 = (from x in ((Component)master).GetComponents<AISkillDriver>()
						where x.customName == "StrafeAndShoot"
						select x).First();
					val2.minDistance = 10f;
					val2.maxDistance = 100f;
					AISkillDriver val3 = (from x in ((Component)master).GetComponents<AISkillDriver>()
						where x.customName == "StrafeIdley"
						select x).First();
					val3.minDistance = 10f;
					val3.maxDistance = 100f;
				}
			}
			else
			{
				AISkillDriver val4 = (from x in ((Component)master).GetComponents<AISkillDriver>()
					where x.customName == "StopAndShoot"
					select x).First();
				val4.movementType = (MovementType)1;
			}
		}

		private void DevotionInventoryController_UpdateMinionInventory(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((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 10)
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				val.EmitDelegate<Func<int, int>>((Func<int, int>)((int useless) => 20));
			}
			else
			{
				hdtLogger.LogError((object)"Failed to apply Health Boost hook");
			}
		}

		private void DevotionInventoryController_Awake(orig_Awake orig, DevotionInventoryController self)
		{
			orig.Invoke(self);
			if (oob.Value)
			{
				self._devotionMinionInventory.GiveItem(Items.TeleportWhenOob, 1);
			}
			if (slug.Value)
			{
				self._devotionMinionInventory.GiveItem(Items.HealWhileSafe, 1);
			}
		}

		private void DevotedLemurianController_Start(orig_Start orig, DevotedLemurianController self)
		{
			orig.Invoke(self);
			self._leashDistSq = teleportDistance.Value * teleportDistance.Value;
		}
	}
}