Decompiled source of AutoPin v1.0.1

AutoPin.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
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 HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AutoPin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AutoPin")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("30f56239-4c33-45e6-9e71-86f71e306eb0")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace AutoPin;

[BepInPlugin("org.ssmvc.autopin", "AutoPin", "1.0.1")]
[BepInProcess("valheim.exe")]
public class AutoPin : BaseUnityPlugin
{
	public const string PluginGUID = "org.ssmvc.autopin";

	public const string PluginName = "AutoPin";

	public const string PluginVersion = "1.0.1";

	private static Harmony _harmony;

	public static ConfigEntry<bool> Enabled { get; set; }

	private ConfigEntry<KeyboardShortcut> AddPointKey { get; set; }

	private ConfigEntry<PinType> AddPointType { get; set; }

	private ConfigEntry<string> AddPointName { get; set; }

	private ConfigEntry<bool> AddDay { get; set; }

	public void Awake()
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "org.ssmvc.autopin");
		Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable this mod.");
		AddPointKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ShortcutKey", new KeyboardShortcut((KeyCode)39, Array.Empty<KeyCode>()), "Shortcut Key");
		AddPointType = ((BaseUnityPlugin)this).Config.Bind<PinType>("General", "Icon", (PinType)3, "Pin Type");
		AddPointName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Text", "AutoPin", "Text to use for AutoPin");
		AddDay = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AppendDay", true, "Append day to pin");
	}

	public void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	private void Update()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		if (!Enabled.Value)
		{
			return;
		}
		KeyboardShortcut value = AddPointKey.Value;
		if (((KeyboardShortcut)(ref value)).IsDown() && Object.op_Implicit((Object)(object)Minimap.instance))
		{
			string text = AddPointName.Value;
			if (AddDay.Value)
			{
				text += $"\r\n$hud_mapday {EnvMan.instance.GetDay(ZNet.instance.GetTimeSeconds())}";
			}
			Minimap.instance.AddPin(((Component)Player.m_localPlayer).transform.position, AddPointType.Value, text, true, false, Player.m_localPlayer.GetPlayerID(), "AutoPin");
		}
	}
}