Decompiled source of ValheimPin v1.0.0

Plugin.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Splatform;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ExampleMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ExampleMod")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9287ffcb-44c7-4f80-a6ca-341e0c1df059")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: AssemblyInformationalVersion("1.0.0+c66a1e40c6abad90ccde5dbb7d17ad967ef920a6")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ExampleMod;

internal static class Log
{
	internal static ManualLogSource _logSource;

	internal static void Init(ManualLogSource logSource)
	{
		_logSource = logSource;
	}

	internal static void LogDebug(object data)
	{
		_logSource.LogDebug(data);
	}

	internal static void LogError(object data)
	{
		_logSource.LogError(data);
	}

	internal static void LogFatal(object data)
	{
		_logSource.LogFatal(data);
	}

	internal static void LogInfo(object data)
	{
		_logSource.LogInfo(data);
	}

	internal static void LogMessage(object data)
	{
		_logSource.LogMessage(data);
	}

	internal static void LogWarning(object data)
	{
		_logSource.LogWarning(data);
	}
}
[BepInPlugin("Sucrettae.ValheimPin", "ValheimPin", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Minimap))]
	[HarmonyPatch("UpdateDynamicPins")]
	internal class Minimap_UpdateDynamicPins_Patch
	{
		private static void AddInworldText(GameObject go, long senderID, Vector3 position, Type type, UserInfo user, string text)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			MethodInfo methodInfo = AccessTools.Method(typeof(Chat), "AddInworldText", new Type[6]
			{
				typeof(GameObject),
				typeof(long),
				typeof(Vector3),
				typeof(Type),
				typeof(UserInfo),
				typeof(string)
			}, (Type[])null);
			object[] parameters = new object[6] { go, senderID, position, type, user, text };
			methodInfo.Invoke(Chat.instance, parameters);
		}

		private static void Postfix(ref Minimap __instance)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			List<PinData> list = (List<PinData>)AccessTools.Field(typeof(Minimap), "m_pins").GetValue(__instance);
			foreach (PinData item in list)
			{
				if (!item.m_checked && item.m_name.Length > 0)
				{
					AddInworldText(null, item.m_name.GetHashCode(), item.m_pos, (Type)1, new UserInfo
					{
						Name = Localization.instance.Localize(item.m_name),
						UserId = default(PlatformUserID)
					}, Localization.instance.Localize(item.m_name));
				}
			}
		}
	}

	public const string ModGuid = "Sucrettae.ValheimPin";

	private const string AuthorName = "Sucrettae";

	private const string ModName = "ValheimPin";

	private const string ModVer = "1.0.0";

	internal static Harmony HarmonyInstance;

	internal static Plugin Instance { get; private set; }

	private void Awake()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		Instance = this;
		HarmonyInstance = new Harmony("ValheimPin");
		HarmonyInstance.PatchAll();
		Log.Init(((BaseUnityPlugin)this).Logger);
	}
}