Decompiled source of EaglesEye v2.0.0

plugins/EagleEye/PeakZoom.dll

Decompiled 14 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PeakZoom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PeakZoom")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9f791583-ddd7-4e17-8f38-fc57f4941031")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("mrbub.eagleseye", "EaglesEye", "1.5.0")]
public class EaglesEye : BaseUnityPlugin
{
	private FovSetting _fovSetting;

	private PropertyInfo _valueProp;

	private float _originalFov;

	private float _currentZoomFov;

	private ConfigEntry<float> _defaultZoomFov;

	private ConfigEntry<float> _minZoomFov;

	private ConfigEntry<float> _maxZoomFov;

	private ConfigEntry<float> _scrollSpeed;

	private ConfigEntry<KeyCode> _holdKey;

	private ConfigEntry<bool> _showOverlay;

	private bool _isZooming;

	private void Awake()
	{
		_defaultZoomFov = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "DefaultZoomFOV", 30f, "Default FOV to zoom to when holding the key");
		_minZoomFov = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "MinZoomFOV", 1f, "Minimum FOV when scrolling in");
		_maxZoomFov = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "MaxZoomFOV", 60f, "Maximum FOV when scrolling out");
		_scrollSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "ScrollSpeed", 2f, "Scroll speed when adjusting zoom");
		_holdKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Zoom", "HoldKey", (KeyCode)99, "Key to hold for zooming");
		_showOverlay = ((BaseUnityPlugin)this).Config.Bind<bool>("Zoom", "ShowBinocularOverlay", true, "Whether to show binocular overlay while zoomed");
	}

	private void Update()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		if (_fovSetting == null || _valueProp == null)
		{
			TryInitFovSetting();
			return;
		}
		if (Input.GetKeyDown(_holdKey.Value))
		{
			_originalFov = (float)_valueProp.GetValue(_fovSetting);
			_currentZoomFov = Mathf.Clamp(_defaultZoomFov.Value, _minZoomFov.Value, _maxZoomFov.Value);
			_valueProp.SetValue(_fovSetting, _currentZoomFov);
			_isZooming = true;
		}
		if (_isZooming && Input.GetKey(_holdKey.Value))
		{
			float y = Input.mouseScrollDelta.y;
			if (Mathf.Abs(y) > 0.01f)
			{
				_currentZoomFov = Mathf.Clamp(_currentZoomFov - y * _scrollSpeed.Value, _minZoomFov.Value, _maxZoomFov.Value);
				_valueProp.SetValue(_fovSetting, _currentZoomFov);
			}
			if (_showOverlay.Value)
			{
				GUIManager.instance.EnableBinocularOverlay();
			}
		}
		if (_isZooming && Input.GetKeyUp(_holdKey.Value))
		{
			_valueProp.SetValue(_fovSetting, _originalFov);
			_isZooming = false;
		}
	}

	private void TryInitFovSetting()
	{
		GameHandler instance = GameHandler.Instance;
		if (((instance != null) ? instance.SettingsHandler : null) != null)
		{
			_fovSetting = GameHandler.Instance.SettingsHandler.GetSetting<FovSetting>();
			if (_fovSetting != null)
			{
				_valueProp = ((object)_fovSetting).GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			}
		}
	}
}