From f39973f12a4c5dd21b62ef1aaa79472d87e4147e Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 19 May 2022 23:11:24 -0400 Subject: [PATCH] Improve the map inoperable patch --- NewHorizons/Patches/MapControllerPatches.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Patches/MapControllerPatches.cs b/NewHorizons/Patches/MapControllerPatches.cs index 73ef61e3..b3c25e29 100644 --- a/NewHorizons/Patches/MapControllerPatches.cs +++ b/NewHorizons/Patches/MapControllerPatches.cs @@ -1,4 +1,6 @@ using HarmonyLib; +using UnityEngine.SceneManagement; + namespace NewHorizons.Patches { [HarmonyPatch] @@ -26,12 +28,18 @@ namespace NewHorizons.Patches [HarmonyPatch(typeof(MapController), nameof(MapController.MapInoperable))] public static bool MapController_MapInoperable(MapController __instance, ref bool __result) { - if(Main.SystemDict[Main.Instance.CurrentStarSystem]?.Config?.mapRestricted ?? false) + if (SceneManager.GetActiveScene().name != "SolarSystem") return true; + + try { - __instance._playerMapRestricted = true; - __result = true; - return false; + if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.mapRestricted) + { + __instance._playerMapRestricted = true; + __result = true; + return false; + } } + catch { } return true; }