Decompiled source of WZC TabMapZoom v1.0.1

plugins\WZC_TabMapZoom.dll

Decompiled 19 hours 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.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("WZC_TabMapZoom")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+07e60932b4aa1813842b8a10df9f384c169abeea")]
[assembly: AssemblyProduct("WZC_TabMapZoom")]
[assembly: AssemblyTitle("WZC_TabMapZoom")]
[assembly: AssemblyVersion("1.0.0.0")]
[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;
		}
	}
}
[BepInPlugin("wzc.repo.tab_map_zoom", "A.WZC_TabMapZoom", "1.0.1")]
public sealed class WzcTabMapZoomPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "wzc.repo.tab_map_zoom";

	public const string PluginVersion = "1.0.1";

	public const string PluginName = "A.WZC_TabMapZoom";

	private const string ContactConfigSection = "模组信息";

	private const string TabMapConfigSection = "A.Tab地图缩放";

	private const string MinimapPluginGuid = "Minimap";

	private const string MinimapPackageFolder = "dig-Minimap";

	private static readonly string[] KnownTabMapConflictPluginIds = new string[2] { "Minimap", "dig-Minimap" };

	private static readonly string[] TabMapConflictKeywords = new string[12]
	{
		"minimap", "mini map", "mapzoom", "map zoom", "tabmapzoom", "tab map zoom", "mapscale", "map scale", "mapresize", "map resize",
		"地图缩放", "小地图"
	};

	private ConfigEntry<string> moduleNameInfo;

	private ConfigEntry<string> moduleVersionInfo;

	private ConfigEntry<string> contactInfo;

	private ConfigEntry<bool> tabMapZoomEnabled;

	private ConfigEntry<bool> tabMapZoomForceEnabled;

	private ConfigEntry<bool> tabMapRestoreOfficialOnOpen;

	private ConfigEntry<float> tabMapDefaultZoom;

	private ConfigEntry<float> tabMapMinZoom;

	private ConfigEntry<float> tabMapMaxZoom;

	private ConfigEntry<float> tabMapScrollSpeed;

	private float tabMapZoomMultiplier = 1f;

	private bool tabMapWasActive;

	private bool tabMapZoomBlockedByConflict;

	private Transform tabMapZoomTarget;

	private Vector3 tabMapOriginalScale = Vector3.one;

	private Vector3 tabMapOriginalLocalPosition = Vector3.zero;

	private Vector3 tabMapOriginalCenterLocal = Vector3.zero;

	private float tabMapOriginalMapScale = 1f;

	private bool tabMapHasOriginalCenter;

	private readonly Dictionary<int, TabMapTransformSnapshot> tabMapLayerSnapshots = new Dictionary<int, TabMapTransformSnapshot>();

	private void Awake()
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Expected O, but got Unknown
		MakePluginHostPersistent();
		moduleNameInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "模组名称", "WZC_Tab地图缩放", new ConfigDescription("当前模组的中文名称。此处只是提示,不影响功能。", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 1000,
				CustomDrawer = DrawContactInfo,
				ReadOnly = true
			}
		}));
		moduleNameInfo.Value = "WZC_Tab地图缩放";
		moduleVersionInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "模组版本号", "1.0.1", new ConfigDescription("当前模组版本号。此处只是提示,不影响功能。", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 990,
				CustomDrawer = DrawContactInfo,
				ReadOnly = true
			}
		}));
		moduleVersionInfo.Value = "1.0.1";
		contactInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "REPO交流QQ群", "824639225", new ConfigDescription("REPO游戏交流、BUG反馈、优化建议、功能请求请加QQ群。此处只是提示,不影响功能。", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 980,
				CustomDrawer = DrawContactInfo,
				ReadOnly = true
			}
		}));
		contactInfo.Value = "824639225";
		tabMapZoomEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("A.Tab地图缩放", "启用", true, ConfigDescriptionWithOrder("开启后,按 Tab 打开原版地图时可以用鼠标滚轮缩放地图内容。", 900));
		tabMapZoomForceEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("A.Tab地图缩放", "强制生效", false, ConfigDescriptionWithOrder("默认关闭。开启后会忽略启动时检测到的 Minimap、小地图、地图缩放等可能冲突的模组,强制让 Tab 地图缩放生效。", 890));
		tabMapRestoreOfficialOnOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("A.Tab地图缩放", "每次打开地图强制恢复官方状态", true, ConfigDescriptionWithOrder("开启后,每次关闭/重新打开 Tab 地图都会恢复官方默认地图状态,再应用默认缩放。关闭后,地图会保留上一次滚轮缩放后的状态。", 880));
		tabMapDefaultZoom = ((BaseUnityPlugin)this).Config.Bind<float>("A.Tab地图缩放", "默认缩放/倍率", 0.75f, ConfigDescriptionWithOrder("每次打开 Tab 地图时的默认缩放倍率。小于 1 可以看到更大范围,大于 1 会放大细节。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), 870));
		tabMapMinZoom = ((BaseUnityPlugin)this).Config.Bind<float>("A.Tab地图缩放", "最小缩放/倍率", 0.25f, ConfigDescriptionWithOrder("地图最多缩小到多少。数值越小,一次看到的范围越大;如果还有房间看不到,就继续调低这个值。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), 860));
		tabMapMaxZoom = ((BaseUnityPlugin)this).Config.Bind<float>("A.Tab地图缩放", "最大缩放/倍率", 2f, ConfigDescriptionWithOrder("地图最多放大到多少。这个控制的是放大看细节,不控制看到更多房间;要看到更多房间请调低最小缩放倍率。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), 850));
		tabMapScrollSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("A.Tab地图缩放", "滚轮缩放速度/倍率", 0.18f, ConfigDescriptionWithOrder("鼠标滚轮每格调整的缩放速度。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.02f, 0.5f), 840));
		tabMapZoomEnabled.SettingChanged += OnTabMapCompatibilitySettingChanged;
		tabMapZoomForceEnabled.SettingChanged += OnTabMapCompatibilitySettingChanged;
		ApplyTabMapConflictCompatibility();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"wzc_tab_map_zoom loaded.");
	}

	private void LateUpdate()
	{
		UpdateTabMapZoom();
	}

	private void OnDestroy()
	{
		if ((Object)(object)tabMapZoomTarget != (Object)null)
		{
			RestoreTabMapZoomTarget();
		}
	}

	private void OnTabMapCompatibilitySettingChanged(object sender, EventArgs e)
	{
		if (!IsTabMapZoomEnabledEffective())
		{
			ResetTabMapZoom();
		}
	}

	private void ApplyTabMapConflictCompatibility()
	{
		if (TryDetectTabMapConflictPlugin(out var detectedPlugin))
		{
			tabMapZoomBlockedByConflict = true;
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Detected possible map zoom/minimap conflict plugin '" + detectedPlugin + "'. Tab map zoom will stay inactive unless 强制生效 is enabled."));
		}
	}

	private bool IsTabMapZoomEnabledEffective()
	{
		if (tabMapZoomEnabled == null || !tabMapZoomEnabled.Value)
		{
			return false;
		}
		if (!tabMapZoomBlockedByConflict)
		{
			return true;
		}
		if (tabMapZoomForceEnabled != null)
		{
			return tabMapZoomForceEnabled.Value;
		}
		return false;
	}

	private static bool TryDetectTabMapConflictPlugin(out string detectedPlugin)
	{
		detectedPlugin = string.Empty;
		try
		{
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				PluginInfo value = pluginInfo.Value;
				object obj;
				if (value == null)
				{
					obj = null;
				}
				else
				{
					BepInPlugin metadata = value.Metadata;
					obj = ((metadata != null) ? metadata.GUID : null);
				}
				if (obj == null)
				{
					obj = pluginInfo.Key;
				}
				string text = (string)obj;
				object obj2;
				if (value == null)
				{
					obj2 = null;
				}
				else
				{
					BepInPlugin metadata2 = value.Metadata;
					obj2 = ((metadata2 != null) ? metadata2.Name : null);
				}
				if (obj2 == null)
				{
					obj2 = string.Empty;
				}
				string text2 = (string)obj2;
				string text3 = ((value != null) ? value.Location : null) ?? string.Empty;
				if (!IsSelfPlugin(text, text2, text3) && (IsKnownTabMapConflict(text) || IsKnownTabMapConflict(text2) || LooksLikeTabMapConflictPlugin(text) || LooksLikeTabMapConflictPlugin(text2) || LooksLikeTabMapConflictPlugin(text3) || LooksLikeTabMapConflictPlugin(Path.GetFileNameWithoutExtension(text3)) || LooksLikeTabMapConflictPlugin(Path.GetFileName(Path.GetDirectoryName(text3) ?? string.Empty))))
				{
					detectedPlugin = (string.IsNullOrWhiteSpace(text2) ? text : (text2 + " (" + text + ")"));
					return true;
				}
			}
		}
		catch
		{
		}
		try
		{
			string pluginPath = Paths.PluginPath;
			if (string.IsNullOrWhiteSpace(pluginPath) || !Directory.Exists(pluginPath))
			{
				return false;
			}
			if (Directory.Exists(Path.Combine(pluginPath, "dig-Minimap")))
			{
				detectedPlugin = "dig-Minimap";
				return true;
			}
			foreach (string item in Directory.EnumerateFiles(pluginPath, "*.dll", SearchOption.AllDirectories))
			{
				if (!IsSelfPlugin(string.Empty, string.Empty, item))
				{
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item);
					string fileName = Path.GetFileName(Path.GetDirectoryName(item) ?? string.Empty);
					if (IsKnownTabMapConflict(fileNameWithoutExtension) || IsKnownTabMapConflict(fileName) || LooksLikeTabMapConflictPlugin(fileNameWithoutExtension) || LooksLikeTabMapConflictPlugin(fileName) || LooksLikeTabMapConflictPlugin(item))
					{
						detectedPlugin = (string.IsNullOrWhiteSpace(fileName) ? fileNameWithoutExtension : (fileName + "/" + fileNameWithoutExtension + ".dll"));
						return true;
					}
				}
			}
		}
		catch
		{
		}
		return false;
	}

	private static bool IsSelfPlugin(string guid, string name, string location)
	{
		if (!string.Equals(guid, "wzc.repo.tab_map_zoom", StringComparison.OrdinalIgnoreCase) && !string.Equals(name, "A.WZC_TabMapZoom", StringComparison.OrdinalIgnoreCase))
		{
			return string.Equals(Path.GetFileNameWithoutExtension(location ?? string.Empty), "wzc_tab_map_zoom", StringComparison.OrdinalIgnoreCase);
		}
		return true;
	}

	private static bool IsKnownTabMapConflict(string text)
	{
		if (string.IsNullOrWhiteSpace(text))
		{
			return false;
		}
		string[] knownTabMapConflictPluginIds = KnownTabMapConflictPluginIds;
		foreach (string text2 in knownTabMapConflictPluginIds)
		{
			if (string.Equals(text.Trim(), text2, StringComparison.OrdinalIgnoreCase) || text.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return true;
			}
		}
		return false;
	}

	private static bool LooksLikeTabMapConflictPlugin(string text)
	{
		if (string.IsNullOrWhiteSpace(text))
		{
			return false;
		}
		string text2 = NormalizePluginSearchText(text);
		string[] tabMapConflictKeywords = TabMapConflictKeywords;
		for (int i = 0; i < tabMapConflictKeywords.Length; i++)
		{
			string value = NormalizePluginSearchText(tabMapConflictKeywords[i]);
			if (text2.Contains(value))
			{
				return true;
			}
		}
		return false;
	}

	private static string NormalizePluginSearchText(string text)
	{
		if (string.IsNullOrWhiteSpace(text))
		{
			return string.Empty;
		}
		StringBuilder stringBuilder = new StringBuilder(text.Length);
		foreach (char c in text)
		{
			if (char.IsLetterOrDigit(c) || c > '\u007f')
			{
				stringBuilder.Append(char.ToLowerInvariant(c));
			}
		}
		return stringBuilder.ToString();
	}

	private void UpdateTabMapZoom()
	{
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		if (!IsTabMapZoomEnabledEffective() || !IsRunLevelActive())
		{
			ResetTabMapZoom();
			return;
		}
		Map instance = Map.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			ResetTabMapZoom();
			return;
		}
		if (!instance.Active)
		{
			if (tabMapRestoreOfficialOnOpen.Value)
			{
				ResetTabMapZoom();
			}
			return;
		}
		Transform transform = ((Component)instance).transform;
		if ((Object)(object)transform == (Object)null)
		{
			ResetTabMapZoom();
			return;
		}
		if ((Object)(object)tabMapZoomTarget != (Object)(object)transform || !tabMapWasActive)
		{
			if ((Object)(object)tabMapZoomTarget != (Object)(object)transform)
			{
				RestoreTabMapZoomTarget();
			}
			tabMapZoomTarget = transform;
			tabMapOriginalScale = transform.localScale;
			tabMapOriginalLocalPosition = transform.localPosition;
			tabMapOriginalMapScale = instance.Scale;
			RestoreTabMapModulePositions(instance);
			tabMapZoomMultiplier = ClampTabMapZoom(tabMapDefaultZoom.Value);
			tabMapLayerSnapshots.Clear();
			CaptureTabMapLayerSnapshots(instance);
			tabMapHasOriginalCenter = TryGetMapContentBounds(instance, transform, out var bounds);
			tabMapOriginalCenterLocal = (tabMapHasOriginalCenter ? transform.InverseTransformPoint(((Bounds)(ref bounds)).center) : Vector3.zero);
			tabMapWasActive = true;
		}
		float axis = Input.GetAxis("Mouse ScrollWheel");
		if (Mathf.Abs(axis) > 0.001f)
		{
			tabMapZoomMultiplier = ClampTabMapZoom(tabMapZoomMultiplier + axis * tabMapScrollSpeed.Value * 10f);
		}
		ApplyTabMapZoom(instance, transform);
	}

	private void ResetTabMapZoom()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		RestoreTabMapZoomTarget();
		tabMapWasActive = false;
		tabMapZoomMultiplier = ClampTabMapZoom(tabMapDefaultZoom.Value);
		tabMapZoomTarget = null;
		tabMapOriginalScale = Vector3.one;
		tabMapOriginalLocalPosition = Vector3.zero;
		tabMapOriginalCenterLocal = Vector3.zero;
		tabMapOriginalMapScale = 1f;
		tabMapHasOriginalCenter = false;
		tabMapLayerSnapshots.Clear();
	}

	private void RestoreTabMapZoomTarget()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)tabMapZoomTarget == (Object)null))
		{
			tabMapZoomTarget.localScale = tabMapOriginalScale;
			tabMapZoomTarget.localPosition = tabMapOriginalLocalPosition;
			Map instance = Map.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.Scale = tabMapOriginalMapScale;
				RestoreTabMapLayerSnapshots();
				RestoreTabMapModulePositions(instance);
			}
		}
	}

	private void ApplyTabMapZoom(Map map, Transform target)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: 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)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		target.localPosition = tabMapOriginalLocalPosition;
		target.localScale = tabMapOriginalScale;
		map.Scale = tabMapOriginalMapScale * tabMapZoomMultiplier;
		ApplyTabMapLayerZoom(map);
		if (tabMapHasOriginalCenter)
		{
			Bounds bounds;
			Vector3 val = (TryGetMapContentBounds(map, target, out bounds) ? ToParentSpace(target, ((Bounds)(ref bounds)).center) : ToParentSpace(target, target.TransformPoint(tabMapOriginalCenterLocal)));
			Vector3 val2 = GetTabMapAnchorInParentSpace(map, target) - val;
			val2.y = 0f;
			target.localPosition += val2;
		}
	}

	private void CaptureTabMapLayerSnapshots(Map map)
	{
		if ((Object)(object)map == (Object)null || map.Layers == null)
		{
			return;
		}
		foreach (MapLayer layer in map.Layers)
		{
			if (!((Object)(object)layer == (Object)null))
			{
				Transform transform = ((Component)layer).transform;
				if (ShouldZoomTabMapLayer(map, transform))
				{
					CaptureTabMapLayerSnapshot(transform);
				}
			}
		}
	}

	private void CaptureTabMapLayerSnapshot(Transform transform)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)transform == (Object)null))
		{
			int instanceID = ((Object)transform).GetInstanceID();
			if (!tabMapLayerSnapshots.ContainsKey(instanceID))
			{
				tabMapLayerSnapshots[instanceID] = new TabMapTransformSnapshot
				{
					Transform = transform,
					LocalPosition = transform.localPosition,
					LocalScale = transform.localScale
				};
			}
		}
	}

	private void ApplyTabMapLayerZoom(Map map)
	{
		//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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)map == (Object)null || map.Layers == null)
		{
			return;
		}
		foreach (MapLayer layer in map.Layers)
		{
			if ((Object)(object)layer == (Object)null)
			{
				continue;
			}
			Transform transform = ((Component)layer).transform;
			if (ShouldZoomTabMapLayer(map, transform))
			{
				CaptureTabMapLayerSnapshot(transform);
				int instanceID = ((Object)transform).GetInstanceID();
				if (tabMapLayerSnapshots.TryGetValue(instanceID, out var value))
				{
					transform.localPosition = value.LocalPosition;
					Vector3 localScale = value.LocalScale;
					localScale.x *= tabMapZoomMultiplier;
					localScale.z *= tabMapZoomMultiplier;
					transform.localScale = localScale;
				}
			}
		}
	}

	private void RestoreTabMapLayerSnapshots()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		foreach (TabMapTransformSnapshot value in tabMapLayerSnapshots.Values)
		{
			if (!((Object)(object)value.Transform == (Object)null))
			{
				value.Transform.localPosition = value.LocalPosition;
				value.Transform.localScale = value.LocalScale;
			}
		}
	}

	private static void RestoreTabMapModulePositions(Map map)
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)map == (Object)null || map.MapModules == null)
		{
			return;
		}
		foreach (MapModule mapModule in map.MapModules)
		{
			if (!((Object)(object)mapModule == (Object)null) && !((Object)(object)mapModule.module == (Object)null))
			{
				MapLayer layerParent = map.GetLayerParent(((Component)mapModule.module).transform.position.y);
				if (!((Object)(object)layerParent == (Object)null))
				{
					((Component)mapModule).transform.position = ((Component)mapModule.module).transform.position * map.Scale + ((Component)layerParent).transform.position + map.GetLayerPosition(layerParent.layer);
				}
			}
		}
	}

	private static bool ShouldZoomTabMapLayer(Map map, Transform transform)
	{
		if ((Object)(object)transform == (Object)null)
		{
			return false;
		}
		if (!((Object)(object)map == (Object)null) && !((Object)(object)map.OverLayerParent == (Object)null))
		{
			return (Object)(object)transform != (Object)(object)map.OverLayerParent;
		}
		return true;
	}

	private static Vector3 GetTabMapAnchorInParentSpace(Map map, Transform target)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (((Object)(object)map != (Object)null && (Object)(object)map.ActiveParent != (Object)null) ? map.ActiveParent.transform : target.parent);
		if (!((Object)(object)val != (Object)null))
		{
			return Vector3.zero;
		}
		return ToParentSpace(target, val.position);
	}

	private static bool TryGetMapContentBounds(Map map, Transform target, out Bounds bounds)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		bounds = default(Bounds);
		bool hasBounds = false;
		if ((Object)(object)map != (Object)null && map.Layers != null)
		{
			foreach (MapLayer layer in map.Layers)
			{
				if (!((Object)(object)layer == (Object)null) && ShouldZoomTabMapLayer(map, ((Component)layer).transform))
				{
					EncapsulateRenderers(((Component)layer).transform, ref bounds, ref hasBounds);
				}
			}
		}
		if (hasBounds)
		{
			return true;
		}
		if ((Object)(object)target == (Object)null)
		{
			return false;
		}
		EncapsulateRenderers(target, ref bounds, ref hasBounds);
		return hasBounds;
	}

	private static void EncapsulateRenderers(Transform root, ref Bounds bounds, ref bool hasBounds)
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)root == (Object)null)
		{
			return;
		}
		Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(false);
		foreach (Renderer val in componentsInChildren)
		{
			if (!((Object)(object)val == (Object)null) && val.enabled)
			{
				if (!hasBounds)
				{
					bounds = val.bounds;
					hasBounds = true;
				}
				else
				{
					((Bounds)(ref bounds)).Encapsulate(val.bounds);
				}
			}
		}
	}

	private static Vector3 ToParentSpace(Transform target, Vector3 worldPoint)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)target != (Object)null) || !((Object)(object)target.parent != (Object)null))
		{
			return worldPoint;
		}
		return target.parent.InverseTransformPoint(worldPoint);
	}

	private float ClampTabMapZoom(float value)
	{
		float num = Mathf.Min(tabMapMinZoom.Value, tabMapMaxZoom.Value);
		float num2 = Mathf.Max(tabMapMinZoom.Value, tabMapMaxZoom.Value);
		return Mathf.Clamp(value, num, num2);
	}

	private static bool IsRunLevelActive()
	{
		try
		{
			return SemiFunc.RunIsLevel();
		}
		catch
		{
			return true;
		}
	}

	private void MakePluginHostPersistent()
	{
		try
		{
			((Component)this).transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to mark plugin host persistent: " + ex.GetType().Name + ": " + ex.Message));
		}
	}

	private void DrawContactInfo(ConfigEntryBase entry)
	{
		GUILayout.Label(entry.BoxedValue?.ToString() ?? "824639225", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
	}

	private static ConfigDescription ConfigDescriptionWithOrder(string description, int order)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		return new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = order
			}
		});
	}

	private static ConfigDescription ConfigDescriptionWithOrder(string description, AcceptableValueBase acceptableValues, int order)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		return new ConfigDescription(description, acceptableValues, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = order
			}
		});
	}
}
internal struct TabMapTransformSnapshot
{
	public Transform Transform;

	public Vector3 LocalPosition;

	public Vector3 LocalScale;
}
internal sealed class ConfigurationManagerAttributes
{
	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;
}