蓝图拦截,初始事件

This commit is contained in:
Tourswen
2025-11-23 15:15:35 +08:00
parent ea31c5f563
commit 38bb0c39a1
18 changed files with 719 additions and 115 deletions

View File

@@ -114,47 +114,49 @@ namespace WulaFallenEmpire
// 新增检查是否有拥有FactoryFacility设施的飞行器
private bool HasFactoryFacilityFlyOver()
{
Map map = Map;
if (map == null) return false;
// 系统禁用,但是保留代码
return true;
//Map map = Map;
//if (map == null) return false;
try
{
// 检查所有FlyOver类型的物体
var allFlyOvers = new List<Thing>();
var dynamicObjects = map.dynamicDrawManager.DrawThings;
foreach (var thing in dynamicObjects)
{
if (thing is FlyOver)
{
allFlyOvers.Add(thing);
}
}
//try
//{
// // 检查所有FlyOver类型的物体
// var allFlyOvers = new List<Thing>();
// var dynamicObjects = map.dynamicDrawManager.DrawThings;
// foreach (var thing in dynamicObjects)
// {
// if (thing is FlyOver)
// {
// allFlyOvers.Add(thing);
// }
// }
foreach (var thing in allFlyOvers)
{
if (thing is FlyOver flyOver && !flyOver.Destroyed)
{
// 检查设施
var facilitiesComp = flyOver.GetComp<CompFlyOverFacilities>();
if (facilitiesComp == null)
{
continue;
}
// foreach (var thing in allFlyOvers)
// {
// if (thing is FlyOver flyOver && !flyOver.Destroyed)
// {
// // 检查设施
// var facilitiesComp = flyOver.GetComp<CompFlyOverFacilities>();
// if (facilitiesComp == null)
// {
// continue;
// }
if (facilitiesComp.HasFacility("FactoryFacility"))
{
return true;
}
}
}
// if (facilitiesComp.HasFacility("FactoryFacility"))
// {
// return true;
// }
// }
// }
return false;
}
catch (System.Exception ex)
{
Log.Error($"[FactoryFacility Check] Error in HasFactoryFacilityFlyOver: {ex}");
return false;
}
// return false;
//}
//catch (System.Exception ex)
//{
// Log.Error($"[FactoryFacility Check] Error in HasFactoryFacilityFlyOver: {ex}");
// return false;
//}
}
// 新增:开始空投目标选择

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
using Verse;
using RimWorld;
namespace WulaFallenEmpire.Patches
{
[HarmonyPatch(typeof(ThingDefGenerator_Techprints))]
[HarmonyPatch("ImpliedTechprintDefs")]
public static class Patch_ThingDefGenerator_Techprints_ImpliedTechprintDefs_Postfix
{
private static readonly HashSet<string> BlockedTechprints = new HashSet<string>
{
"Techprint_WULA_Colony_License_LV1_Technology",
"Techprint_WULA_Colony_License_LV2_Technology",
"Techprint_WULA_Colony_License_LV3_Technology"
};
[HarmonyPostfix]
public static IEnumerable<ThingDef> Postfix(IEnumerable<ThingDef> __result)
{
foreach (ThingDef thingDef in __result)
{
if (thingDef?.defName != null && BlockedTechprints.Contains(thingDef.defName))
{
continue; // 跳过被阻止的科技蓝图
}
yield return thingDef;
}
}
}
}

View File

@@ -163,6 +163,7 @@
<Compile Include="GlobalWorkTable\CompLaunchable_ToGlobalStorage.cs" />
<Compile Include="GlobalWorkTable\CompProperties_Launchable_ToGlobalStorage.cs" />
<Compile Include="HarmonyPatches\Hediff_Mechlink_PostAdd_Patch.cs" />
<Compile Include="HarmonyPatches\Patch_ThingDefGenerator_Techprints_ImpliedTechprintDefs.cs" />
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_FloatMenuOptionProvider_SelectedPawnValid.cs" />
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_IsColonyMechPlayerControlled.cs" />
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_MechanitorUtility_CanDraftMech.cs" />