This commit is contained in:
2025-07-19 12:49:35 +08:00
parent 82a98e8d69
commit 0cd5fc91a8
10 changed files with 61 additions and 44 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -22,7 +22,7 @@
<Intellectual>5</Intellectual>
</skillGains>
<spawnCategories>
<li>Wula_Old_Synth_Backstory_Categories</li>
<li>Wula_Backstory_Categories</li>
</spawnCategories>
<requiredWorkTags>None</requiredWorkTags>
<forcedHediffs>

View File

@@ -978,4 +978,4 @@
</li>
</stages>
</HediffDef>
</Defs>
</Defs>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<!-- <ThingDef ParentName="ImplantBase">
<ThingDef ParentName="ImplantBase">
<defName>Wula_BackstoryRegeneratorImplant</defName>
<label>backstory regenerator</label>
<thingClass>ThingWithComps</thingClass>
@@ -64,6 +64,6 @@
<li>Brain</li>
</appliedOnFixedBodyParts>
<addsHediff>Wula_RegenerateBackstory</addsHediff>
</RecipeDef> -->
</RecipeDef>
</Defs>

View File

@@ -3,20 +3,20 @@
"WorkspaceRootPath": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|c:\\steam\\steamapps\\common\\rimworld\\mods\\3516260226\\source\\wulafallenempire\\mechanitorpatch.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:mechanitorpatch.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\wulafallenempiremod.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:wulafallenempiremod.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\hediffcomp_regeneratebackstory.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:hediffcomp_regeneratebackstory.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\wulafallenempiremod.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:wulafallenempiremod.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\building_wula_darkenergy_engine.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:building_wula_darkenergy_engine.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|c:\\steam\\steamapps\\common\\rimworld\\mods\\3516260226\\source\\wulafallenempire\\mechanitorpatch.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:mechanitorpatch.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
@@ -26,7 +26,7 @@
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 3,
"SelectedChildIndex": 2,
"Children": [
{
"$type": "Bookmark",
@@ -40,46 +40,49 @@
"RelativeDocumentMoniker": "HediffComp_RegenerateBackstory.cs",
"ToolTip": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\HediffComp_RegenerateBackstory.cs",
"RelativeToolTip": "HediffComp_RegenerateBackstory.cs",
"ViewState": "AQIAAB4AAAAAAAAAAAAIwHIAAAABAAAA",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAHIAAAABAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-07-18T11:23:19.064Z"
"WhenOpened": "2025-07-18T11:23:19.064Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 0,
"Title": "WulaFallenEmpireMod.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WulaFallenEmpireMod.cs",
"RelativeDocumentMoniker": "WulaFallenEmpireMod.cs",
"ToolTip": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WulaFallenEmpireMod.cs",
"RelativeToolTip": "WulaFallenEmpireMod.cs",
"ViewState": "AQIAAAAAAAAAAAAAAADwvxQAAAAAAAAA",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABQAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-07-18T10:23:17.898Z"
"WhenOpened": "2025-07-18T10:23:17.898Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"DocumentIndex": 3,
"Title": "MechanitorPatch.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\MechanitorPatch.cs",
"RelativeDocumentMoniker": "MechanitorPatch.cs",
"ToolTip": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\MechanitorPatch.cs",
"RelativeToolTip": "MechanitorPatch.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABQAAAAsAAAA",
"ViewState": "AQIAAAAAAAAAAAAAAAAAACEAAAAJAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-07-18T10:20:31.368Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"DocumentIndex": 2,
"Title": "Building_Wula_DarkEnergy_Engine.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\Building_Wula_DarkEnergy_Engine.cs",
"RelativeDocumentMoniker": "Building_Wula_DarkEnergy_Engine.cs",
"ToolTip": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\Building_Wula_DarkEnergy_Engine.cs",
"RelativeToolTip": "Building_Wula_DarkEnergy_Engine.cs",
"ViewState": "AQIAAAYAAAAAAAAAAADwvwAAAAAAAAAA",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-07-14T12:24:18.86Z"
"WhenOpened": "2025-07-14T12:24:18.86Z",
"EditorCaption": ""
}
]
}

View File

@@ -5,37 +5,51 @@ using RimWorld;
using Verse;
using HarmonyLib; // 引入Harmony库
// 定义一个新的HediffComp用于标记可以赋予机械师能力的Hediff
public class HediffComp_MakesMechanitor : HediffComp
namespace WulaFallenEmpire
{
// 这个组件本身不需要任何特殊逻辑,它的存在就是标记
}
// Harmony Patch类用于修改MechanitorUtility.ShouldBeMechanitor方法
[HarmonyPatch(typeof(MechanitorUtility), "ShouldBeMechanitor")]
public static class MechanitorShouldBeMechanitorPatch
{
// Postfix方法将在原始方法执行后运行
// originalResult 是原始方法的返回值
// pawn 是原始方法的参数
public static void Postfix(Pawn pawn, ref bool __result)
// 定义一个新的HediffCompProperties用作标记以赋予机械师能力
public class HediffCompProperties_MakesMechanitor : HediffCompProperties
{
// 如果原始方法已经返回true则无需进一步检查
if (__result)
// 这个类本身不需要任何逻辑它的存在就是为了在XML中被引用作为标记
public HediffCompProperties_MakesMechanitor()
{
return;
// compClass必须指向一个有效的HediffComp类。
// 由于我们只想用这个Properties作为标记我们可以指向一个通用的、空的HediffComp。
// 但更简洁的方法是直接在补丁里检查Properties本身。
// 为了避免运行时错误我们暂时指向一个基础的HediffComp。
// 实际上在下面的补丁逻辑中我们不会实例化这个compClass。
this.compClass = typeof(HediffComp);
}
}
// 检查Biotech DLC是否激活且Pawn属于玩家安全派系
if (ModsConfig.BiotechActive && pawn.Faction.IsPlayerSafe())
// Harmony Patch类用于修改MechanitorUtility.ShouldBeMechanitor方法
[HarmonyPatch(typeof(MechanitorUtility), "ShouldBeMechanitor")]
public static class MechanitorShouldBeMechanitorPatch
{
// Postfix方法将在原始方法执行后运行
// originalResult 是原始方法的返回值
// pawn 是原始方法的参数
public static void Postfix(Pawn pawn, ref bool __result)
{
// 遍历Pawn的所有Hediff检查是否存在HediffComp_MakesMechanitor组件
foreach (Hediff hediff in pawn.health.hediffSet.hediffs)
// 如果原始方法已经返回true则无需进一步检查
if (__result)
{
if (hediff.TryGetComp<HediffComp_MakesMechanitor>() != null)
return;
}
// 检查Biotech DLC是否激活且Pawn属于玩家安全派系
if (ModsConfig.BiotechActive && pawn.Faction.IsPlayerSafe())
{
// 遍历Pawn的所有Hediff
foreach (Hediff hediff in pawn.health.hediffSet.hediffs)
{
__result = true; // 如果找到则将结果设置为true
return;
// 检查Hediff的定义中是否包含HediffCompProperties_MakesMechanitor
if (hediff.def.comps?.Any(c => c is HediffCompProperties_MakesMechanitor) ?? false)
{
__result = true; // 如果找到则将结果设置为true
return;
}
}
}
}