Improve the map inoperable patch

This commit is contained in:
Nick 2022-05-19 23:11:24 -04:00
parent eb38bfb14d
commit f39973f12a

View File

@ -1,4 +1,6 @@
using HarmonyLib; using HarmonyLib;
using UnityEngine.SceneManagement;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {
[HarmonyPatch] [HarmonyPatch]
@ -26,12 +28,18 @@ namespace NewHorizons.Patches
[HarmonyPatch(typeof(MapController), nameof(MapController.MapInoperable))] [HarmonyPatch(typeof(MapController), nameof(MapController.MapInoperable))]
public static bool MapController_MapInoperable(MapController __instance, ref bool __result) 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; if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.mapRestricted)
__result = true; {
return false; __instance._playerMapRestricted = true;
__result = true;
return false;
}
} }
catch { }
return true; return true;
} }