using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EquinoxsDebugTools;
using EquinoxsModUtils;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MapHotkey")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MapHotkey")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("48f798f5-24c9-4bc9-8d48-dc06a0dbee9a")]
[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")]
namespace MapHotkey;
public class MapHotkeyConfig
{
internal static ConfigEntry<KeyCode> hotkey;
public static void CreateConfigEntries(BaseUnityPlugin plugin)
{
hotkey = plugin.Config.Bind<KeyCode>("General", "Hotkey", (KeyCode)109, "The button to press to set the camera to map zoom level");
}
}
[BepInPlugin("com.equinox.MapHotkey", "MapHotkey", "1.0.0")]
public class MapHotkeyPlugin : BaseUnityPlugin
{
internal const string MyGUID = "com.equinox.MapHotkey";
private const string PluginName = "MapHotkey";
private const string VersionString = "1.0.0";
private static readonly Harmony Harmony = new Harmony("com.equinox.MapHotkey");
internal static ManualLogSource Log = new ManualLogSource("MapHotkey");
private HUDCameraManager camera;
private void Awake()
{
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: MapHotkey, VersionString: 1.0.0 is loading...");
MapHotkeyConfig.CreateConfigEntries((BaseUnityPlugin)(object)this);
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: MapHotkey, VersionString: 1.0.0 has loaded.");
Log = ((BaseUnityPlugin)this).Logger;
}
public void Update()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (UnityInput.Current.GetKeyDown(MapHotkeyConfig.hotkey.Value) && (!((Object)(object)camera == (Object)null) || GetCamera()))
{
ToggleCameraZoomLevel();
}
}
private bool GetCamera()
{
HUDCameraManager[] array = Object.FindObjectsOfType<HUDCameraManager>();
if (array.Length == 0)
{
return false;
}
camera = array[0];
return Object.op_Implicit((Object)(object)((Component)this).transform);
}
private void ToggleCameraZoomLevel()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
FieldSearchInfo<HUDCameraManager> obj = new FieldSearchInfo<HUDCameraManager>("Viewport", camera, false, false);
Viewport val = (Viewport)Reflection.GetPrivateField<HUDCameraManager>(obj);
float targetZoom = val.TargetZoom;
if (val.TargetZoom < 400f || val.TargetZoom >= 6400f)
{
val.TargetZoom = 400f;
}
else if (val.TargetZoom < 1600f)
{
val.TargetZoom = 1600f;
}
else if (val.TargetZoom < 6400f)
{
val.TargetZoom = 6400f;
}
Reflection.SetPrivateField<HUDCameraManager>(obj, (object)val);
Logging.Log("Zoom Updates", $"Updated TargetZoom from '{targetZoom}' to '{val.TargetZoom}'");
}
}