虫洞1
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using HarmonyLib;
|
||||
using Verse;
|
||||
using System.Linq;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
[HarmonyPatch(typeof(Game), "DeinitAndRemoveMap")]
|
||||
public static class Patch_Game_DeinitAndRemoveMap
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
public static bool Prefix(Map map)
|
||||
{
|
||||
// 如果地图上存在B端传送门,则阻止该地图被销毁
|
||||
if (map != null && map.listerBuildings.AllBuildingsColonistOfClass<Building_WormholePortal_B>().Any())
|
||||
{
|
||||
return false; // 返回 false, 阻止原版方法执行
|
||||
}
|
||||
|
||||
// 否则,正常执行原版方法
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using RimWorld.Planet;
|
||||
using Verse;
|
||||
using System.Linq;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
[HarmonyPatch(typeof(SettlementDefeatUtility), "CheckDefeated")]
|
||||
public static class Patch_SettlementDefeatUtility_CheckDefeated
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
public static bool Prefix(Settlement factionBase)
|
||||
{
|
||||
// 如果目标没有地图,或者地图上存在B端传送门,则跳过原版的失败检查
|
||||
if (!factionBase.HasMap || factionBase.Map.listerBuildings.AllBuildingsColonistOfClass<Building_WormholePortal_B>().Any())
|
||||
{
|
||||
return false; // 返回 false, 阻止原版方法执行
|
||||
}
|
||||
|
||||
// 否则,正常执行原版方法
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using HarmonyLib;
|
||||
using RimWorld.Planet;
|
||||
using Verse;
|
||||
using System.Linq;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
[HarmonyPatch(typeof(Site), "ShouldRemoveMapNow")]
|
||||
public static class Patch_Site_ShouldRemoveMapNow
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
public static void Postfix(MapParent __instance, ref bool __result)
|
||||
{
|
||||
// 如果原方法已经决定不移除,我们就不需要干预
|
||||
if (!__result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果地图上存在B端传送门,则推翻原方法的决定,阻止地图被移除
|
||||
if (__instance.HasMap && __instance.Map.listerBuildings.AllBuildingsColonistOfClass<Building_WormholePortal_B>().Any())
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user