Decompiled source of HexMapDiscovery v1.0.0

Plugins/HexMapDiscovery.dll

Decompiled a day ago
using System;
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 HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HexMapDiscovery")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HexMapDiscovery")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e53ae2bc-c77e-4f27-bf71-bd03232cf52c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HexMapDiscovery;

[BepInPlugin("com.hex.mapdiscovery", "HexMapDiscovery", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Minimap), "Explore", new Type[]
	{
		typeof(Vector3),
		typeof(float)
	})]
	internal static class PatchMinimapExplore
	{
		private static readonly FieldInfo AttachedField = typeof(Player).GetField("m_attached", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo AttachedToShipField = typeof(Player).GetField("m_attachedToShip", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static void Prefix(ref float radius)
		{
			if (IsModEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && IsAttachedToShip(Player.m_localPlayer))
			{
				float num = Mathf.Clamp(ExplorationRadiusMultiplier, 1f, 10f);
				radius *= num;
			}
		}

		private static bool IsAttachedToShip(Player player)
		{
			if ((Object)(object)player == (Object)null || AttachedField == null || AttachedToShipField == null)
			{
				return false;
			}
			bool num = (bool)AttachedField.GetValue(player);
			bool flag = (bool)AttachedToShipField.GetValue(player);
			return num && flag;
		}
	}

	private const string PluginGuid = "com.hex.mapdiscovery";

	private const string PluginName = "HexMapDiscovery";

	private const string PluginVersion = "1.0.0";

	private const float DefaultExplorationRadiusMultiplier = 3f;

	private Harmony _harmonyInstance;

	private ConfigEntry<bool> _isModEnabled;

	private ConfigEntry<float> _explorationRadiusMultiplier;

	internal static ManualLogSource Log;

	internal static Plugin Instance;

	internal static bool IsModEnabled
	{
		get
		{
			if ((Object)(object)Instance != (Object)null)
			{
				return Instance._isModEnabled?.Value ?? false;
			}
			return false;
		}
	}

	internal static float ExplorationRadiusMultiplier
	{
		get
		{
			if (!((Object)(object)Instance != (Object)null))
			{
				return 1f;
			}
			return Instance._explorationRadiusMultiplier?.Value ?? 1f;
		}
	}

	private void Awake()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		_isModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable the mod.");
		_explorationRadiusMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Exploration", "ExplorationRadiusMultiplier", 3f, new ConfigDescription("Multiplier for the exploration radius while piloting a ship.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
		_harmonyInstance = new Harmony("com.hex.mapdiscovery");
		_harmonyInstance.PatchAll();
		Log.LogInfo((object)"HexMapDiscovery v1.0.0 loaded.");
	}

	private void OnDestroy()
	{
		Log.LogInfo((object)"HexMapDiscovery v1.0.0 unloaded.");
		Harmony harmonyInstance = _harmonyInstance;
		if (harmonyInstance != null)
		{
			harmonyInstance.UnpatchSelf();
		}
		_harmonyInstance = null;
		Instance = null;
		Log = null;
	}
}