Decompiled source of FreeCompass v1.0.0

FreeCompass.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GlobalSettings;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FreeCompass")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FreeCompass")]
[assembly: AssemblyTitle("FreeCompass")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace FreeCompass;

[BepInPlugin("x753.FreeCompass", "FreeCompass", "1.0.0")]
public class FreeCompassMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(GameMap), "PositionCompassAndCorpse")]
	private class GameMap_PositionCompassAndCorpse_Patch
	{
		[HarmonyPostfix]
		public static void GameMap_PositionCompassAndCorpse_Postfix(GameMap __instance)
		{
			if (!RequiresCompassEquipped && (Object)(object)__instance.currentSceneObj != (Object)null && (Gameplay.CompassTool.IsUnlocked || !RequiresCompassPurchased))
			{
				__instance.compassIcon.SetActive(true);
				__instance.displayingCompass = true;
			}
		}
	}

	[HarmonyPatch(typeof(ShopItem), "get_Cost")]
	private class ShopItem_Cost_Patch
	{
		[HarmonyPrefix]
		public static bool ShopItem_Cost_Prefix(ShopItem __instance, ref int __result)
		{
			if (((Object)__instance).name == "Mapper Compass Tool")
			{
				__result = CompassPrice;
				return false;
			}
			return true;
		}
	}

	private const string modGUID = "x753.FreeCompass";

	private const string modName = "FreeCompass";

	private const string modVersion = "1.0.0";

	private readonly Harmony harmony = new Harmony("x753.FreeCompass");

	internal static ManualLogSource ModLogger;

	public static FreeCompassMod Instance;

	public static bool RequiresCompassPurchased;

	public static bool RequiresCompassEquipped;

	public static int CompassPrice;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		harmony.PatchAll();
		ModLogger = Logger.CreateLogSource("FreeCompass");
		ModLogger.LogInfo((object)"Plugin FreeCompass is loaded!");
		InitializeConfigs();
	}

	public void InitializeConfigs()
	{
		RequiresCompassPurchased = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Requires Compass Purchased", false, "Do you need to purchase the compass?").Value;
		RequiresCompassEquipped = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Requires Compass Equipped", false, "Do you need to equip the compass?").Value;
		CompassPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Compass Price", 0, "How much does the compass cost?").Value;
	}
}