Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TabMapZoom v1.1.0
Zichen-TabMapZoom-1.1.0.dll
Decompiled 2 weeks agousing 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 System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; 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("Zichen-TabMapZoom-1.1.0")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+4c60f4c6bbf0e7e00c2a59197ecaee6868e0163a")] [assembly: AssemblyProduct("Zichen-TabMapZoom-1.1.0")] [assembly: AssemblyTitle("Zichen-TabMapZoom-1.1.0")] [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("zichen.tabmapzoom", "A.Tab Map Zoom", "1.1.0")] public sealed class ZichenTabMapZoomPlugin : BaseUnityPlugin { private static ZichenTabMapZoomPlugin Instance; public const string PluginGuid = "zichen.tabmapzoom"; public const string PluginVersion = "1.1.0"; public const string PluginName = "A.Tab Map Zoom"; 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 bool tabMapConflictCompatibilityChecked; 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 bool tabMapZoomDirty = true; private float tabMapLastAppliedZoom = float.MinValue; private int tabMapKnownLayerCount = -1; private int tabMapKnownModuleCount = -1; private Transform tabMapOverLayerTransform; private Vector3 tabMapOverLayerOffset = Vector3.zero; private readonly List<TabMapTransformSnapshot> tabMapLayerSnapshots = new List<TabMapTransformSnapshot>(); private readonly List<TabMapModuleRuntimeSnapshot> tabMapModuleSnapshots = new List<TabMapModuleRuntimeSnapshot>(); private readonly List<TabMapTransformSnapshot> tabMapModuleChildSnapshots = new List<TabMapTransformSnapshot>(); private Harmony harmony; private void Awake() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown Instance = this; DetachFromManager(); MakePluginHostPersistent(); ResetConfigIfVersionChanged(); moduleNameInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "模组名称", "地图缩放", new ConfigDescription("当前模组的中文名称。此处只是提示,不影响功能。", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1000, CustomDrawer = DrawContactInfo, ReadOnly = true } })); moduleNameInfo.Value = "地图缩放"; moduleVersionInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "模组版本号", "1.1.0", new ConfigDescription("当前模组版本号。此处只是提示,不影响功能。", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 990, CustomDrawer = DrawContactInfo, ReadOnly = true } })); moduleVersionInfo.Value = "1.1.0"; 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地图缩放", "强制生效", true, 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.3f, 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; ApplyHarmonyPatches(); TryBootstrapUpdateLoopFromCurrentMap(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"zichen-tab-map-zoom loaded."); } private void LateUpdate() { UpdateTabMapZoom(); } private void DetachFromManager() { ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void OnDestroy() { if (Instance == this) { Instance = null; } Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } if ((Object)(object)tabMapZoomTarget != (Object)null) { RestoreTabMapZoomTarget(); } } private void OnTabMapCompatibilitySettingChanged(object sender, EventArgs e) { if (!IsTabMapZoomEnabledEffective()) { ResetTabMapZoom(); SetUpdateLoopActive(active: false); } else { tabMapZoomDirty = true; TryBootstrapUpdateLoopFromCurrentMap(); } } 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; } EnsureTabMapConflictCompatibilityChecked(); if (!tabMapZoomBlockedByConflict) { return true; } if (tabMapZoomForceEnabled != null) { return tabMapZoomForceEnabled.Value; } return false; } private void EnsureTabMapConflictCompatibilityChecked() { if (!tabMapConflictCompatibilityChecked) { tabMapConflictCompatibilityChecked = true; ApplyTabMapConflictCompatibility(); } } 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, "zichen.tabmapzoom", StringComparison.OrdinalIgnoreCase) && !string.Equals(name, "A.Tab Map Zoom", StringComparison.OrdinalIgnoreCase)) { return string.Equals(Path.GetFileNameWithoutExtension(location ?? string.Empty), "Zichen-TabMapZoom", 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (!IsTabMapZoomEnabledEffective() || !IsRunLevelActive()) { ResetTabMapZoom(); SetUpdateLoopActive(active: false); return; } Map instance = Map.Instance; if ((Object)(object)instance == (Object)null) { ResetTabMapZoom(); SetUpdateLoopActive(active: false); return; } if (!instance.Active) { if (tabMapRestoreOfficialOnOpen.Value) { ResetTabMapZoom(); } SetUpdateLoopActive(active: false); 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); RefreshTabMapSnapshots(instance, transform); tabMapWasActive = true; } else if (HasTabMapStructureChanged(instance)) { RestoreTabMapZoomTarget(); RefreshTabMapSnapshots(instance, transform); } float axis = Input.GetAxis("Mouse ScrollWheel"); if (Mathf.Abs(axis) > 0.001f) { float num = ClampTabMapZoom(tabMapZoomMultiplier + axis * tabMapScrollSpeed.Value * 10f); if (!Mathf.Approximately(num, tabMapZoomMultiplier)) { tabMapZoomMultiplier = num; tabMapZoomDirty = true; } } if (tabMapZoomDirty || !Mathf.Approximately(tabMapLastAppliedZoom, tabMapZoomMultiplier)) { ApplyTabMapZoom(instance, transform); tabMapLastAppliedZoom = tabMapZoomMultiplier; tabMapZoomDirty = false; } } 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) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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; tabMapZoomDirty = true; tabMapLastAppliedZoom = float.MinValue; tabMapKnownLayerCount = -1; tabMapKnownModuleCount = -1; tabMapOverLayerTransform = null; tabMapOverLayerOffset = Vector3.zero; tabMapLayerSnapshots.Clear(); tabMapModuleSnapshots.Clear(); tabMapModuleChildSnapshots.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(); RestoreTabMapModuleChildSnapshots(); 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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) target.localPosition = tabMapOriginalLocalPosition; target.localScale = tabMapOriginalScale; map.Scale = tabMapOriginalMapScale * tabMapZoomMultiplier; ApplyTabMapLayerZoom(); ApplyTabMapModuleZoom(map); if (tabMapHasOriginalCenter) { Vector3 val = ScaleTabMapLocalVector(tabMapOriginalCenterLocal, tabMapZoomMultiplier); Vector3 val2 = ToParentSpace(target, target.TransformPoint(val)); Vector3 val3 = GetTabMapAnchorInParentSpace(map, target) - val2; val3.y = 0f; target.localPosition += val3; } } private void CaptureTabMapLayerSnapshots(Map map) { if ((Object)(object)map == (Object)null || map.Layers == null) { return; } List<MapLayer> layers = map.Layers; for (int i = 0; i < layers.Count; i++) { MapLayer val = layers[i]; if (!((Object)(object)val == (Object)null)) { Transform transform = ((Component)val).transform; if (ShouldZoomTabMapLayer(map, transform)) { AddTransformSnapshot(transform, tabMapLayerSnapshots); } } } } private void ApplyTabMapLayerZoom() { //IL_0026: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < tabMapLayerSnapshots.Count; i++) { TabMapTransformSnapshot tabMapTransformSnapshot = tabMapLayerSnapshots[i]; if (!((Object)(object)tabMapTransformSnapshot.Transform == (Object)null)) { tabMapTransformSnapshot.Transform.localPosition = tabMapTransformSnapshot.LocalPosition; Vector3 localScale = tabMapTransformSnapshot.LocalScale; localScale.x *= tabMapZoomMultiplier; localScale.z *= tabMapZoomMultiplier; tabMapTransformSnapshot.Transform.localScale = localScale; } } } private void RestoreTabMapLayerSnapshots() { RestoreTransformSnapshots(tabMapLayerSnapshots); } private void RefreshTabMapSnapshots(Map map, Transform target) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) tabMapLayerSnapshots.Clear(); tabMapModuleSnapshots.Clear(); tabMapModuleChildSnapshots.Clear(); CaptureTabMapLayerSnapshots(map); CaptureTabMapModuleSnapshots(map); UpdateTabMapStructureCounts(map); CacheTabMapOverLayerData(map); tabMapHasOriginalCenter = TryGetMapContentBounds(map, target, out var bounds); tabMapOriginalCenterLocal = (tabMapHasOriginalCenter ? target.InverseTransformPoint(((Bounds)(ref bounds)).center) : Vector3.zero); tabMapZoomDirty = true; tabMapLastAppliedZoom = float.MinValue; } private void CaptureTabMapModuleSnapshots(Map map) { if ((Object)(object)map == (Object)null || map.MapModules == null) { return; } List<MapModule> mapModules = map.MapModules; for (int i = 0; i < mapModules.Count; i++) { MapModule val = mapModules[i]; if ((Object)(object)val == (Object)null || (Object)(object)val.module == (Object)null) { continue; } Transform transform = ((Component)val).transform; Transform transform2 = ((Component)val.module).transform; if (!((Object)(object)transform == (Object)null) && !((Object)(object)transform2 == (Object)null)) { tabMapModuleSnapshots.Add(new TabMapModuleRuntimeSnapshot { ModuleTransform = transform, SourceTransform = transform2 }); int childCount = transform.childCount; for (int j = 0; j < childCount; j++) { AddTransformSnapshot(transform.GetChild(j), tabMapModuleChildSnapshots); } } } } private void ApplyTabMapModuleZoom(Map map) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)map == (Object)null) { return; } RestoreTabMapModulePositions(map); for (int i = 0; i < tabMapModuleChildSnapshots.Count; i++) { TabMapTransformSnapshot tabMapTransformSnapshot = tabMapModuleChildSnapshots[i]; if (!((Object)(object)tabMapTransformSnapshot.Transform == (Object)null)) { Vector3 localPosition = tabMapTransformSnapshot.LocalPosition; localPosition.x *= tabMapZoomMultiplier; localPosition.z *= tabMapZoomMultiplier; tabMapTransformSnapshot.Transform.localPosition = localPosition; Vector3 localScale = tabMapTransformSnapshot.LocalScale; localScale.x *= tabMapZoomMultiplier; localScale.z *= tabMapZoomMultiplier; tabMapTransformSnapshot.Transform.localScale = localScale; } } } private void RestoreTabMapModuleChildSnapshots() { RestoreTransformSnapshots(tabMapModuleChildSnapshots); } private static void RestoreTabMapModulePositions(Map map) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance == (Object)null || (Object)(object)map == (Object)null || (Object)(object)Instance.tabMapOverLayerTransform == (Object)null) { return; } Vector3 position = Instance.tabMapOverLayerTransform.position; for (int i = 0; i < Instance.tabMapModuleSnapshots.Count; i++) { TabMapModuleRuntimeSnapshot tabMapModuleRuntimeSnapshot = Instance.tabMapModuleSnapshots[i]; if (!((Object)(object)tabMapModuleRuntimeSnapshot.ModuleTransform == (Object)null) && !((Object)(object)tabMapModuleRuntimeSnapshot.SourceTransform == (Object)null)) { tabMapModuleRuntimeSnapshot.ModuleTransform.position = tabMapModuleRuntimeSnapshot.SourceTransform.position * map.Scale + position + Instance.tabMapOverLayerOffset; } } } private bool HasTabMapStructureChanged(Map map) { if ((Object)(object)map == (Object)null) { return false; } int num = ((map.Layers != null) ? map.Layers.Count : 0); int num2 = ((map.MapModules != null) ? map.MapModules.Count : 0); if (num == tabMapKnownLayerCount && num2 == tabMapKnownModuleCount) { return (Object)(object)map.OverLayerParent != (Object)(object)tabMapOverLayerTransform; } return true; } private void UpdateTabMapStructureCounts(Map map) { tabMapKnownLayerCount = ((map?.Layers != null) ? map.Layers.Count : 0); tabMapKnownModuleCount = ((map?.MapModules != null) ? map.MapModules.Count : 0); } 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 static Vector3 ScaleTabMapLocalVector(Vector3 value, float multiplier) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) value.x *= multiplier; value.z *= multiplier; return value; } private static void AddTransformSnapshot(Transform transform, List<TabMapTransformSnapshot> snapshots) { //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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)transform == (Object)null)) { snapshots?.Add(new TabMapTransformSnapshot { Transform = transform, LocalPosition = transform.localPosition, LocalScale = transform.localScale }); } } private static void RestoreTransformSnapshots(List<TabMapTransformSnapshot> snapshots) { //IL_0025: 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 (snapshots == null) { return; } for (int i = 0; i < snapshots.Count; i++) { TabMapTransformSnapshot tabMapTransformSnapshot = snapshots[i]; if (!((Object)(object)tabMapTransformSnapshot.Transform == (Object)null)) { tabMapTransformSnapshot.Transform.localPosition = tabMapTransformSnapshot.LocalPosition; tabMapTransformSnapshot.Transform.localScale = tabMapTransformSnapshot.LocalScale; } } } private void CacheTabMapOverLayerData(Map map) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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) tabMapOverLayerTransform = (((Object)(object)map != (Object)null) ? map.OverLayerParent : null); tabMapOverLayerOffset = Vector3.zero; if (!((Object)(object)map == (Object)null) && !((Object)(object)tabMapOverLayerTransform == (Object)null)) { MapLayer component = ((Component)tabMapOverLayerTransform).GetComponent<MapLayer>(); if ((Object)(object)component != (Object)null) { tabMapOverLayerOffset = map.GetLayerPosition(component.layer); } } } private void ApplyHarmonyPatches() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown harmony = new Harmony("zichen.tabmapzoom.patch"); harmony.Patch((MethodBase)AccessTools.Method(typeof(Map), "ActiveSet", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ZichenTabMapZoomPlugin), "MapActiveSetPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private void TryBootstrapUpdateLoopFromCurrentMap() { Map instance = Map.Instance; bool flag = (Object)(object)instance != (Object)null && instance.Active && IsRunLevelActive() && IsTabMapZoomEnabledEffective(); SetUpdateLoopActive(flag); if (flag) { tabMapZoomDirty = true; } } private void SetUpdateLoopActive(bool active) { ((Behaviour)this).enabled = active; } private void OnMapActiveSet(Map map, bool active) { if (!active) { if (tabMapRestoreOfficialOnOpen != null && tabMapRestoreOfficialOnOpen.Value) { ResetTabMapZoom(); } SetUpdateLoopActive(active: false); } else { tabMapZoomDirty = true; bool updateLoopActive = (Object)(object)map != (Object)null && IsRunLevelActive() && IsTabMapZoomEnabledEffective(); SetUpdateLoopActive(updateLoopActive); } } private static void MapActiveSetPostfix(Map __instance, bool active) { Instance?.OnMapActiveSet(__instance, active); } 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 } }); } private void ResetConfigIfVersionChanged() { try { string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath; string text = ReadConfigPluginVersion(configFilePath); if (!string.IsNullOrWhiteSpace(text) && !(text == "1.1.0")) { ResetConfigFileToDefaults(configFilePath); ((BaseUnityPlugin)this).Logger.LogWarning((object)"Config version changed. Old config was reset to defaults."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to reset config by version: " + ex.Message)); } } private static string ReadConfigPluginVersion(string configPath) { if (!File.Exists(configPath)) { return null; } Match match = Regex.Match(File.ReadAllText(configPath), "(?m)^模组版本号\\s*=\\s*(.+?)\\s*$"); if (!match.Success) { return null; } return match.Groups[1].Value.Trim(); } private void ResetConfigFileToDefaults(string configPath) { ((BaseUnityPlugin)this).Config.Clear(); if (File.Exists(configPath)) { File.Delete(configPath); } ((BaseUnityPlugin)this).Config.Reload(); } } internal struct TabMapTransformSnapshot { public Transform Transform; public Vector3 LocalPosition; public Vector3 LocalScale; } internal struct TabMapModuleRuntimeSnapshot { public Transform ModuleTransform; public Transform SourceTransform; } 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; }