Decompiled source of Autoshoot v1.0.2

BepInEx/plugins/Autoshoot/AutoShoot.dll

Decompiled 9 months 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 AutoShoot;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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: BuildDateTime("2024-02-25T02:40:26")]
[assembly: AssemblyCompany("AutoShoot")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AutoShoot")]
[assembly: AssemblyTitle("AutoShoot")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Template
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AutoShoot";

		public const string PLUGIN_NAME = "AutoShoot";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace AutoShoot
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class BuildDateTimeAttribute : Attribute
	{
		public DateTime Built { get; }

		public BuildDateTimeAttribute(string date)
		{
			Built = DateTime.Parse(date);
		}
	}
	[HarmonyPatch(typeof(PlayerAutoFireWhileFarming), "Update")]
	internal class PlayerAutoFireWhileFarming_Update_Patch
	{
		private static FieldRef<PlayerAutoFireWhileFarming, bool> hasEnemyInRange = AccessTools.FieldRefAccess<PlayerAutoFireWhileFarming, bool>("_hasEnemyInRange");

		private static FieldRef<PlayerAutoFireWhileFarming, float> isFiring = AccessTools.FieldRefAccess<PlayerAutoFireWhileFarming, float>("_isFiring");

		private static FieldRef<PlayerAutoFireWhileFarming, bool> isWaitingForReload = AccessTools.FieldRefAccess<PlayerAutoFireWhileFarming, bool>("_isWaitingForReload");

		private static FieldRef<PlayerAutoFireWhileFarming, float> triggerPressTimer = AccessTools.FieldRefAccess<PlayerAutoFireWhileFarming, float>("_triggerPressTimer");

		private static void Postfix(PlayerAutoFireWhileFarming __instance)
		{
			WorkingMethod_Traverse(__instance);
		}

		private static void WorkingMethod1(PlayerAutoFireWhileFarming __instance)
		{
			if (hasEnemyInRange.Invoke(__instance))
			{
				isFiring.Invoke(__instance) = 1f;
				return;
			}
			isWaitingForReload.Invoke(__instance) = false;
			isFiring.Invoke(__instance) = -1f;
			triggerPressTimer.Invoke(__instance) = -1f;
		}

		private static void WorkingMethod_Traverse(PlayerAutoFireWhileFarming __instance)
		{
			Traverse val = Traverse.Create((object)__instance);
			val.Field<float>("_isFiring").Value = 1f;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "fhghaha.plugin.AutoShoot";

		public const string PLUGIN_NAME = "AutoShoot";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("fhghaha.plugin.AutoShoot", "AutoShoot", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		private void Awake()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogMessage((object)"---------------Plugin fhghaha.plugin.AutoShoot is loaded!---------------");
			((BaseUnityPlugin)this).Logger.LogMessage((object)$"---------------{GetBuildDateTime()}---------------");
			Harmony val = new Harmony("fhghaha.plugin.AutoShoot");
			val.PatchAll();
		}

		private static DateTime? GetBuildDateTime()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			return (Attribute.GetCustomAttribute(executingAssembly, typeof(BuildDateTimeAttribute)) is BuildDateTimeAttribute buildDateTimeAttribute) ? new DateTime?(buildDateTimeAttribute.Built) : null;
		}
	}
	public static class TransformExtensions
	{
		public static IEnumerable<Transform> GetTopLevelChildren(this Transform parent)
		{
			foreach (Transform item in parent)
			{
				yield return item;
			}
		}
	}
}