Decompiled source of HoldToAimBows v1.0.1

plugins/HoldToAimBows.dll

Decompiled 4 hours ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
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: AssemblyTitle("HoldToAimBows")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HoldToAimBows")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HoldToAimBows;

[BepInPlugin("zenethian.holdtoaimbows", "Hold to Aim Bows", "1.0.0")]
public class HoldToAimBows : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ControlsInput), "Aim")]
	private class ControlsInput_Aim
	{
		[HarmonyPrefix]
		public static bool Patch(bool __result, int _playerID, Dictionary<int, RewiredInputs> ___m_playerInputManager)
		{
			if (localPlayerId == -1)
			{
				Log.LogMessage((object)$"AIM called {__result} {_playerID} {___m_playerInputManager}");
				return true;
			}
			if (_playerID != localPlayerId)
			{
				Log.LogMessage((object)$"AIM called {__result} {_playerID} {___m_playerInputManager}");
				return true;
			}
			if (!Object.op_Implicit((Object)(object)playerInput))
			{
				playerInput = ___m_playerInputManager[localPlayerId];
				actionNameAim = ControlsInput.GetGameplayActionName((GameplayActions)21);
			}
			bool button = playerInput.GetButton(actionNameAim);
			__result = button;
			return button;
		}
	}

	[HarmonyPatch(typeof(LocalCharacterControl), "UpdateWeapon")]
	private class LocalCharacterControl_UpdateWeapon
	{
		[HarmonyPostfix]
		public static void Patch(Character ___m_character)
		{
			localPlayerId = ___m_character.OwnerPlayerSys.PlayerID;
			if (Object.op_Implicit((Object)(object)playerInput) && Object.op_Implicit((Object)(object)___m_character.CurrentWeapon) && ___m_character.CurrentWeapon.SpecialIsZoom)
			{
				bool button = playerInput.GetButton(actionNameAim);
				if (button != ___m_character.CharacterCamera.InZoomMode)
				{
					___m_character.SetZoomMode(button);
				}
			}
		}
	}

	public const string GUID = "zenethian.holdtoaimbows";

	public const string NAME = "Hold to Aim Bows";

	public const string VERSION = "1.0.0";

	private static int localPlayerId = -1;

	private static RewiredInputs playerInput = null;

	private static string actionNameAim = "Aim";

	internal static ManualLogSource Log;

	public static ConfigEntry<bool> ExampleConfig;

	internal void Awake()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogMessage((object)"Loaded Hold to Aim Bows 1.0.0!");
		new Harmony("zenethian.holdtoaimbows").PatchAll();
	}
}