Decompiled source of AntroHiddenMapEnabler v1.0.0

Antro.HiddenMapEnabler.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.IL2CPP;
using BepInEx.Logging;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnhollowerBaseLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Antro.HiddenMapEnabler")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.HiddenMapEnabler")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("Antro.HiddenMapEnabler")]
[assembly: AssemblyTitle("Antro.HiddenMapEnabler")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Antro.HiddenMapEnabler
{
	[BepInPlugin("Antro.HiddenMapEnabler", "Hidden Map Enabler", "2.2.0")]
	public class Plugin : BasePlugin
	{
		public static Plugin Instance;

		private bool _injected = false;

		public override void Load()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			Instance = this;
			SceneManager.sceneLoaded += UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)OnSceneLoaded);
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Antro.HiddenMapEnabler v2.2 loaded.");
			}
			log.LogInfo(val);
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if ((((Scene)(ref scene)).name == "Menu" || ((Scene)(ref scene)).name == "Lobby") && !_injected)
			{
				InjectMaps();
				_injected = true;
			}
			if (((Scene)(ref scene)).name != "Menu" && ((Scene)(ref scene)).name != "Lobby")
			{
				_injected = false;
			}
		}

		private void InjectMaps()
		{
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				MonoBehaviourPublicObInMamaLi1plMadeMaUnique val = Object.FindObjectOfType<MonoBehaviourPublicObInMamaLi1plMadeMaUnique>();
				MonoBehaviourPublicGadealGaLi1pralObInUnique val2 = Object.FindObjectOfType<MonoBehaviourPublicGadealGaLi1pralObInUnique>();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				List<Map> list = new List<Map>();
				if (val.maps != null)
				{
					foreach (Map item in (Il2CppArrayBase<Map>)(object)val.maps)
					{
						list.Add(item);
					}
				}
				HashSet<string> hashSet = new HashSet<string>();
				foreach (Map item2 in list)
				{
					hashSet.Add(item2.mapName);
				}
				List<Map> list2 = new List<Map>();
				int sceneCountInBuildSettings = SceneManager.sceneCountInBuildSettings;
				for (int i = 0; i < sceneCountInBuildSettings; i++)
				{
					string scenePathByBuildIndex = SceneUtility.GetScenePathByBuildIndex(i);
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(scenePathByBuildIndex);
					if (!IsSystemScene(fileNameWithoutExtension) && !hashSet.Contains(fileNameWithoutExtension))
					{
						Map val3 = ScriptableObject.CreateInstance<Map>();
						((Object)val3).name = fileNameWithoutExtension;
						val3.mapName = fileNameWithoutExtension;
						val3.mapSize = (EnumNPublicSealedvasmmelaan5vUnique)3;
						list2.Add(val3);
						ManualLogSource log = ((BasePlugin)this).Log;
						BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[HiddenMap] Added: ");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(fileNameWithoutExtension);
						}
						log.LogInfo(val4);
					}
				}
				if (list2.Count == 0)
				{
					return;
				}
				foreach (Map item3 in list2)
				{
					item3.id = list.Count;
					list.Add(item3);
				}
				val.maps = Il2CppReferenceArray<Map>.op_Implicit(list.ToArray());
				if (val.playableMaps != null)
				{
					foreach (Map item4 in list2)
					{
						bool flag2 = false;
						Enumerator<Map> enumerator5 = val.playableMaps.GetEnumerator();
						while (enumerator5.MoveNext())
						{
							Map current5 = enumerator5.Current;
							if (current5.mapName == item4.mapName)
							{
								flag2 = true;
							}
						}
						if (!flag2)
						{
							val.playableMaps.Add(item4);
						}
					}
				}
				if (!((Object)(object)val2 != (Object)null) || val2.allGameModes == null)
				{
					return;
				}
				foreach (GameModeData item5 in (Il2CppArrayBase<GameModeData>)(object)val2.allGameModes)
				{
					List<Map> list3 = new List<Map>();
					if (item5.compatibleMaps != null)
					{
						foreach (Map item6 in (Il2CppArrayBase<Map>)(object)item5.compatibleMaps)
						{
							list3.Add(item6);
						}
					}
					bool flag3 = false;
					foreach (Map item7 in list2)
					{
						bool flag4 = false;
						foreach (Map item8 in list3)
						{
							if (item8.mapName == item7.mapName)
							{
								flag4 = true;
							}
						}
						if (!flag4)
						{
							list3.Add(item7);
							flag3 = true;
						}
					}
					if (flag3)
					{
						item5.compatibleMaps = Il2CppReferenceArray<Map>.op_Implicit(list3.ToArray());
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = ((BasePlugin)this).Log;
				BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Error InjectMaps: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Exception>(ex);
				}
				log2.LogError(val5);
			}
		}

		private bool IsSystemScene(string name)
		{
			string text = name.ToLower();
			int result;
			switch (text)
			{
			default:
				if (!text.Contains("test") && !text.Contains("lavaclimb"))
				{
					result = (text.Contains("dani") ? 1 : 0);
					break;
				}
				goto case "menu";
			case "menu":
			case "lobby":
			case "boot":
			case "splash":
			case "skybox":
			case "loading":
			case "game":
				result = 1;
				break;
			}
			return (byte)result != 0;
		}
	}
}