Decompiled source of HuntressAutoaimFix v1.2.0

HuntressAutoaimFix.dll

Decompiled 2 months 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 Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HuntressAutoaimFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HuntressAutoaimFix")]
[assembly: AssemblyTitle("HuntressAutoaimFix")]
[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 HuntressAutoaimFix
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("HIFU.HuntressAutoaimFix", "HuntressAutoaimFix", "1.2.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "HIFU.HuntressAutoaimFix";

		public const string PluginAuthor = "HIFU";

		public const string PluginName = "HuntressAutoaimFix";

		public const string PluginVersion = "1.2.0";

		public AssetBundle huntressautoaimfix;

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

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

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

		public void Awake()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			huntressautoaimfix = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("HuntressAutoaimFix.dll", "huntressautoaimfix"));
			maxTrackingAngle = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Max Tracking Angle", 30f, "Vanilla is 30");
			maxTrackingDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Max Tracking Distance", 60f, "Vanilla is 60");
			maxTrackingDistanceLevelScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Max Tracking Distance Gain Per Level", 0f, "Vanilla is 0");
			ModSettingsManager.SetModIcon(huntressautoaimfix.LoadAsset<Sprite>("texModIconHAF.png"));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(maxTrackingAngle, new StepSliderConfig
			{
				increment = 1f,
				min = 1f,
				max = 360f,
				formatString = "{0}°"
			}));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(maxTrackingDistance, new StepSliderConfig
			{
				increment = 5f,
				min = 5f,
				max = 1000f,
				formatString = "{0}m"
			}));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(maxTrackingDistanceLevelScale, new StepSliderConfig
			{
				increment = 0.5f,
				min = 0f,
				max = 20f,
				formatString = "{0}m"
			}));
			HuntressTracker.SearchForTarget += new hook_SearchForTarget(HuntressTracker_SearchForTarget);
		}

		private void HuntressTracker_SearchForTarget(orig_SearchForTarget orig, HuntressTracker self, Ray aimRay)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			if (Object.op_Implicit((Object)(object)self.characterBody))
			{
				num = maxTrackingDistanceLevelScale.Value * (self.characterBody.level - 1f);
			}
			self.search.teamMaskFilter = TeamMask.GetUnprotectedTeams(self.teamComponent.teamIndex);
			self.search.filterByLoS = true;
			self.search.searchOrigin = ((Ray)(ref aimRay)).origin;
			self.search.searchDirection = ((Ray)(ref aimRay)).direction;
			self.search.sortMode = (SortMode)2;
			self.search.maxDistanceFilter = maxTrackingDistance.Value + num;
			self.search.maxAngleFilter = maxTrackingAngle.Value;
			self.search.RefreshCandidates();
			self.search.FilterOutGameObject(((Component)self).gameObject);
			self.trackingTarget = self.search.GetResults().FirstOrDefault();
		}
	}
}