Decompiled source of NoHammerZoom v1.0.0

NoHammerZoom.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoHammerZoom")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Disables zooming while the hammer is equipped.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoHammerZoom")]
[assembly: AssemblyTitle("NoHammerZoom")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 NoHammerZoom
{
	[BepInPlugin("com.babelthuap.nohammerzoom", "NoHammerZoom", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.babelthuap.nohammerzoom";

		public const string PluginName = "NoHammerZoom";

		public const string PluginVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("com.babelthuap.nohammerzoom");

		private void Awake()
		{
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"NoHammerZoom loaded");
		}
	}
	[HarmonyPatch(typeof(GameCamera), "LateUpdate")]
	public static class GameCamera_LateUpdate_Patch
	{
		private static float _tempMin;

		private static float _tempMax;

		private static bool _modified;

		private static readonly MethodInfo GetRightItemMethod = AccessTools.Method(typeof(Humanoid), "GetRightItem", (Type[])null, (Type[])null);

		public static void Prefix(GameCamera __instance, ref float ___m_distance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			_modified = false;
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				ItemData val = (ItemData)GetRightItemMethod.Invoke(Player.m_localPlayer, null);
				if (val != null && val.m_shared.m_name == "$item_hammer")
				{
					_tempMin = __instance.m_minDistance;
					_tempMax = __instance.m_maxDistance;
					__instance.m_minDistance = ___m_distance;
					__instance.m_maxDistance = ___m_distance;
					_modified = true;
				}
			}
		}

		public static void Postfix(GameCamera __instance)
		{
			if (_modified)
			{
				__instance.m_minDistance = _tempMin;
				__instance.m_maxDistance = _tempMax;
			}
		}
	}
}