diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index c48554bb..9f473560 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/Source/WulaFallenEmpire/HarmonyPatches/MapParent_ShouldRemoveMapNow_Patch.cs b/Source/WulaFallenEmpire/HarmonyPatches/MapParent_ShouldRemoveMapNow_Patch.cs new file mode 100644 index 00000000..9946c2a0 --- /dev/null +++ b/Source/WulaFallenEmpire/HarmonyPatches/MapParent_ShouldRemoveMapNow_Patch.cs @@ -0,0 +1,43 @@ +using System.Linq; +using HarmonyLib; +using RimWorld.Planet; +using Verse; + +namespace WulaFallenEmpire +{ + [HarmonyPatch(typeof(MapParent), "CheckRemoveMapNow")] + public static class MapParent_CheckRemoveMapNow_Patch + { + [HarmonyPrefix] + public static bool Prefix(MapParent __instance) + { + // 如果该 MapParent 没有地图,则直接放行,执行原方法(虽然原方法也会检查 HasMap,但这里提前返回更清晰) + if (!__instance.HasMap) + { + return true; + } + + try + { + // 在当前地图上查找所有武装穿梭机 + foreach (var shuttle in __instance.Map.listerBuildings.AllBuildingsColonistOfClass()) + { + // 检查穿梭机是否有已生成的口袋地图,并且该地图里是否有人 + if (shuttle != null && shuttle.PocketMapGenerated && shuttle.PocketMap != null && shuttle.PocketMap.mapPawns.AnyPawnBlockingMapRemoval) + { + // 如果找到了这样的穿梭机,则阻止原方法 CheckRemoveMapNow 的执行,从而阻止地图被移除。 + // Log.Message($"[WULA] Prevented removal of map '{__instance.Map}' because shuttle '{shuttle.Label}' still contains pawns in its pocket dimension."); + return false; // 返回 false 以跳过原方法的执行 + } + } + } + catch (System.Exception ex) + { + Log.Error($"[WULA] Error in MapParent_CheckRemoveMapNow_Patch Prefix: {ex}"); + } + + // 如果没有找到需要保护的穿梭机,则允许原方法 CheckRemoveMapNow 继续执行其正常的逻辑 + return true; + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/ThingDefOf_WULA.cs b/Source/WulaFallenEmpire/WulaDefOf.cs similarity index 100% rename from Source/WulaFallenEmpire/ThingDefOf_WULA.cs rename to Source/WulaFallenEmpire/WulaDefOf.cs diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj index deb52a54..34cef6d7 100644 --- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj +++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj @@ -106,6 +106,7 @@ + @@ -158,12 +159,12 @@ + -