回档不patch了

This commit is contained in:
2025-09-05 14:12:55 +08:00
parent 6673aeeff9
commit 804bf8a487
4 changed files with 2 additions and 70 deletions

View File

@@ -1,36 +0,0 @@
using System;
using HarmonyLib;
using RimWorld.Planet;
using Verse;
namespace WulaFallenEmpire
{
[HarmonyPatch(typeof(MapParent), "ShouldRemoveMapNow")]
[HarmonyPriority(600)]
public static class MapParent_ShouldRemoveMapNow_Patch
{
public static void Postfix(ref bool __result, MapParent __instance)
{
// 如果游戏本来就不打算删除,或者地图不存在,我们什么都不做
if (!__result || !__instance.HasMap)
{
return;
}
try
{
// 检查地图上是否存在一个“活着”的武装穿梭机
if (WulaMapProtectionHelper.ShouldProtectMap(__instance.Map))
{
// 游戏打算删除,但我们的逻辑说现在还不行,所以直接覆盖结果。
// 因为 ShouldRemoveMapNow 会被周期性调用,所以这是安全的。
__result = false;
}
}
catch (Exception arg)
{
Log.Error($"[WULA] Error in MapParent_ShouldRemoveMapNow_Patch: {arg}");
}
}
}
}

View File

@@ -1,29 +0,0 @@
using System;
using System.Linq;
using Verse;
namespace WulaFallenEmpire
{
public static class WulaMapProtectionHelper
{
public static bool ShouldProtectMap(Map map)
{
if (map == null)
{
return false;
}
try
{
// 检查地图上是否存在一个口袋空间已经初始化的武装穿梭机
// 只要地图上存在一个活着的武装穿梭机,就保护地图
return map.listerThings.AllThings.OfType<Building_ArmedShuttleWithPocket>()
.Any(shuttle => shuttle != null && shuttle.Spawned && !shuttle.Destroyed);
}
catch (Exception arg)
{
Log.Error($"[WULA] Error in WulaMapProtectionHelper.ShouldProtectMap: {arg}");
return false;
}
}
}
}

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="15.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -203,10 +204,6 @@
<ItemGroup>
<Compile Include="Verb\Verb_Excalibur\Thing_ExcaliburBeam.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Harmony\MapLifecycle_Patches.cs" />
<Compile Include="Harmony\WulaMapProtectionHelper.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 自定义清理任务删除obj文件夹中的临时文件 -->