Decompiled source of CaveFinder v1.0.1

CaveFinder.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using SSSGame;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CaveFinder")]
[assembly: AssemblyTitle("CaveFinder")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace CaveFinder;

[BepInPlugin("blacks7ar.CaveFinder", "CaveFinder", "1.0.1")]
public class Plugin : BasePlugin
{
	[HarmonyPatch]
	private static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(CavesManager), "UpdateDataAsync")]
		private static void UpdateDataAsync_Postfix(CavesManager __instance)
		{
			RevealAllCavesLocation(__instance, "UpdateDataAsync");
		}

		private static void RevealAllCavesLocation(CavesManager manager, string source)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Enumerator<int, CaveExplorationHandler> enumerator = manager._explorationHandlers.GetEnumerator();
				while (enumerator.MoveNext())
				{
					KeyValuePair<int, CaveExplorationHandler> current = enumerator.Current;
					int key = current.Key;
					CaveExplorationHandler value = current.Value;
					if (value == null || value.data == null)
					{
						continue;
					}
					value.data.explored = true;
					value._OnCaveExplorationChanged(true);
					value._RefreshMarkerState();
					if (RevealedCaves.Contains(key))
					{
						continue;
					}
					RevealedCaves.Add(key);
					try
					{
						string text = "A Cave has spawned on the map!";
						string text2 = "CaveFinder";
						NotificationMenu.DisplayImportant(key, ref text, ref text2, (Sprite)null, 5f, (NotificationType)3);
					}
					catch (Exception ex)
					{
						ManualLogSource cFLogger = CFLogger;
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to show notification: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
						}
						cFLogger.LogError(val);
					}
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource cFLogger2 = CFLogger;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(9, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(source);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Error: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex2);
				}
				cFLogger2.LogError(val);
			}
		}

		private static void DebugCave(CavesManager manager)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				int num = ((manager._dataMap != null) ? manager._dataMap.Count : (-1));
				int num2 = ((manager._residentCaves != null) ? manager._residentCaves.Count : (-1));
				int num3 = ((manager._explorationHandlers != null) ? manager._explorationHandlers.Count : (-1));
				CFLogger.LogDebug((object)"UpdateDataAsync fired.");
				ManualLogSource cFLogger = CFLogger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(66, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DataMap count: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ResidentCaves count: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ExplorationHandler count: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num3);
				}
				cFLogger.LogDebug(val);
			}
			catch (Exception ex)
			{
				ManualLogSource cFLogger2 = CFLogger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(17, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("DebugCave error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				cFLogger2.LogError(val2);
			}
		}
	}

	private const string modGUID = "blacks7ar.CaveFinder";

	public const string modName = "CaveFinder";

	public const string modAuthor = "blacks7ar";

	public const string modVersion = "1.0.1";

	private static ManualLogSource CFLogger;

	private static readonly HashSet<int> RevealedCaves = new HashSet<int>();

	public override void Load()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		CFLogger = ((BasePlugin)this).Log;
		CFLogger.LogInfo((object)"Mod loaded!");
		new Harmony("blacks7ar.CaveFinder").PatchAll();
	}
}