Decompiled source of NoCompassOrKnownLocations v1.0.2

ValheimModNoCompass.dll

Decompiled a week ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("ValheimModNoCompass")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ValheimModNoCompass")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("305a4283-94bd-43a0-88de-ab05174a1f29")]
[assembly: AssemblyFileVersion("1.0.0.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.2")]
namespace ValheimModNoCompass;

[HarmonyPatch(typeof(Chat), "SendPing")]
public class ChatPing
{
	[HarmonyPrefix]
	public static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(Minimap), "UpdatePlayerMarker")]
internal class MinimapUpdatePlayerMarkers
{
	public static Minimap mapInstance;

	[HarmonyPrefix]
	public static bool UpdatePlayerMarkerPrefix(ref Minimap __instance)
	{
		mapInstance = __instance;
		__instance.m_smallRoot.SetActive(false);
		((Component)__instance.m_largeMarker).gameObject.SetActive(false);
		((Component)__instance.m_smallMarker).gameObject.SetActive(false);
		((Component)__instance.m_smallShipMarker).gameObject.SetActive(false);
		((Component)__instance.m_largeShipMarker).gameObject.SetActive(false);
		return false;
	}
}
[HarmonyPatch(typeof(Minimap), "CenterMap")]
internal class MinimapCenterMap
{
	public static bool inMouseDrag;

	[HarmonyPrefix]
	public static bool UpdatePrefix(ref Minimap __instance, ref Vector3 centerPoint)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		FieldInfo fieldInfo = AccessTools.Field(typeof(Minimap), "m_dragView");
		bool flag = (bool)fieldInfo.GetValue(__instance);
		FieldInfo fieldInfo2 = AccessTools.Field(typeof(Minimap), "m_mapOffset");
		Vector3 val = (Vector3)fieldInfo2.GetValue(__instance);
		if (flag)
		{
			inMouseDrag = true;
			centerPoint.x = val.x;
			centerPoint.y = val.y;
			centerPoint.z = val.z;
		}
		else
		{
			if (LargeMapSetActive.triggerOnActive)
			{
				LargeMapSetActive.triggerOnActive = false;
				centerPoint = new Vector3(311.53f, 41.46f, -39.9f);
			}
			_ = MinimapUpdateMap.playerLocation;
			if (true && centerPoint.x == MinimapUpdateMap.playerLocation.x && centerPoint.y == MinimapUpdateMap.playerLocation.y && centerPoint.z == MinimapUpdateMap.playerLocation.z)
			{
				centerPoint = new Vector3(311.53f, 41.46f, -39.9f);
			}
			if (inMouseDrag)
			{
				centerPoint = new Vector3(311.53f, 41.46f, -39.9f);
				inMouseDrag = false;
				fieldInfo2.SetValue(__instance, centerPoint);
			}
		}
		return true;
	}
}
[HarmonyPatch(typeof(Minimap), "AddPin")]
internal class MinimapPatchAddPin
{
	[HarmonyPrefix]
	public static bool AddPinPrefix(ref Minimap __instance, ref Vector3 pos, ref PinType type, ref string name, ref bool save, ref bool isChecked, ref long ownerID, ref string author)
	{
		__instance.m_smallRoot.SetActive(false);
		if ((int)type == 0 || (int)type == 1 || (int)type == 2 || (int)type == 3 || (int)type == 6)
		{
			return true;
		}
		return false;
	}
}
[HarmonyPatch(typeof(Minimap), "DiscoverLocation")]
public class MinimapPatchDiscoverLocation
{
	[HarmonyPrefix]
	public static bool DiscoverLocationPrefix(ref Minimap __instance, ref Vector3 pos, ref PinType type, ref string name, ref bool showMap)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		if ((int)type == 9)
		{
			((Character)Player.m_localPlayer).SetLookDir(pos - ((Component)Player.m_localPlayer).transform.position, 3.5f);
		}
		return false;
	}
}
[HarmonyPatch(typeof(GameObject), "SetActive")]
public class LargeMapSetActive
{
	public static bool triggerOnActive;

	[HarmonyPrefix]
	public static void Prefix(GameObject __instance, bool value)
	{
		if ((Object)(object)MinimapUpdatePlayerMarkers.mapInstance != (Object)null && (Object)(object)__instance == (Object)(object)MinimapUpdatePlayerMarkers.mapInstance.m_largeRoot)
		{
			if (value)
			{
				triggerOnActive = true;
			}
			else
			{
				triggerOnActive = false;
			}
		}
	}
}
[HarmonyPatch(typeof(Minimap), "UpdateDynamicPins")]
internal class MinimapPatchUpdateDynamicPins
{
	[HarmonyPrefix]
	public static bool UpdateDynamicPins()
	{
		return false;
	}
}
[HarmonyPatch(typeof(Minimap), "UpdateMap")]
internal class MinimapUpdateMap
{
	public static Vector3 playerLocation;

	[HarmonyPrefix]
	public static void Prefix(Minimap __instance, Player player, ref Vector3 ___m_mapOffset)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		playerLocation = ((Component)player).transform.position;
	}
}
[BepInPlugin("connorcacy.valheim.nocompass", "Valheim Mod for no compass and markers", "1.0.0")]
[BepInProcess("valheim.exe")]
public class ModNoCompass : BaseUnityPlugin
{
	private Harmony _harmony;

	public static ManualLogSource StaticLogger;

	public void Awake()
	{
		StaticLogger = ((BaseUnityPlugin)this).Logger;
		_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "connorcacy.valheim.nocompass");
	}
}