Decompiled source of SecretMap v1.0.0

SecretMap.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Globalization;
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 Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SecretMap")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SecretMap")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9494f260-ef8b-4506-8cdc-5a76762af043")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 SecretMap
{
	public static class PluginConfig
	{
		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			IsModEnabled = config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable the mod.");
		}
	}
	internal class PlayerPatches
	{
		[HarmonyPatch(typeof(Player))]
		private static class PlayerOnSpawnedPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnSpawned")]
			private static void OnSpawnedPostFix()
			{
				if (!PluginConfig.IsModEnabled.Value)
				{
					return;
				}
				Transform val = Minimap.m_instance.m_largeRoot.transform.Find("SharedPanel");
				if ((Object)(object)val == (Object)null)
				{
					SecretMap.LogError("Could not find SharedPanel.  SecretMap will not run.");
					return;
				}
				Toggle componentInChildren = ((Component)val).GetComponentInChildren<Toggle>();
				if ((Object)(object)componentInChildren == (Object)null)
				{
					SecretMap.LogError("Could not find Toggle component of SharedPanel.  SecretMap will not run.");
				}
				else if (componentInChildren.isOn)
				{
					componentInChildren.isOn = false;
					((Component)val).gameObject.SetActive(true);
				}
			}
		}
	}
	[BepInPlugin("EardwulfC.valheim.secretmap", "SecretMap", "1.0.0")]
	public sealed class SecretMap : BaseUnityPlugin
	{
		public const string PluginGuid = "EardwulfC.valheim.secretmap";

		public const string PluginName = "SecretMap";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource _logger;

		private void Awake()
		{
			_logger = ((BaseUnityPlugin)this).Logger;
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "EardwulfC.valheim.secretmap");
			_logger.LogInfo((object)"Keeping your map secret since 2025.");
		}

		public static void LogInfo(object obj)
		{
			_logger.LogInfo((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}");
		}

		public static void LogError(object obj)
		{
			_logger.LogError((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}");
		}
	}
}