机械师和背景hediff未验证
This commit is contained in:
53
.gitignore
vendored
Normal file
53
.gitignore
vendored
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Visual Studio
|
||||||
|
.vs/
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.ilk
|
||||||
|
*.obj
|
||||||
|
*.pdb
|
||||||
|
*.tlb
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
*.csproj.user
|
||||||
|
*.resharper
|
||||||
|
*.dotSettings
|
||||||
|
*.pidb
|
||||||
|
*.booproj
|
||||||
|
*.kproj
|
||||||
|
*.lock.json
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
*.nupkg
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.cer
|
||||||
|
*.pfx
|
||||||
|
*.snk
|
||||||
|
*.vsix
|
||||||
|
*.vsmacros
|
||||||
|
*.webtest
|
||||||
|
*.testrunconfig
|
||||||
|
*.trx
|
||||||
|
*.fxcop
|
||||||
|
*.fxcopcmd
|
||||||
|
*.scc
|
||||||
|
*.vsscc
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
*.builds
|
||||||
|
*.deploy
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
*.log
|
||||||
|
*.cache
|
||||||
|
*.tmp
|
||||||
Binary file not shown.
Binary file not shown.
@@ -71,6 +71,7 @@
|
|||||||
<damageDefIncoming>EMP</damageDefIncoming>
|
<damageDefIncoming>EMP</damageDefIncoming>
|
||||||
<vomit>true</vomit>
|
<vomit>true</vomit>
|
||||||
</li>
|
</li>
|
||||||
|
<li Class="WulaFallenEmpire.HediffCompProperties_MakesMechanitor"/>
|
||||||
</comps>
|
</comps>
|
||||||
</HediffDef>
|
</HediffDef>
|
||||||
<HediffDef>
|
<HediffDef>
|
||||||
|
|||||||
56
1.6/Defs/HediffDefs/Implants_RegenerateBackstory.xml
Normal file
56
1.6/Defs/HediffDefs/Implants_RegenerateBackstory.xml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Defs>
|
||||||
|
|
||||||
|
<ThingDef ParentName="ImplantBase">
|
||||||
|
<defName>Wula_BackstoryRegeneratorImplant</defName>
|
||||||
|
<label>backstory regenerator</label>
|
||||||
|
<description>A one-use implant that restructures a person's memories and experiences, effectively giving them a new backstory. The process is unstable and the implant is consumed on use.</description>
|
||||||
|
<statBases>
|
||||||
|
<MarketValue>1500</MarketValue>
|
||||||
|
<Mass>0.1</Mass>
|
||||||
|
</statBases>
|
||||||
|
</ThingDef>
|
||||||
|
|
||||||
|
<HediffDef ParentName="ImplantHediffBase">
|
||||||
|
<defName>Wula_RegenerateBackstory</defName>
|
||||||
|
<label>backstory regenerator</label>
|
||||||
|
<labelNoun>a backstory regenerator</labelNoun>
|
||||||
|
<description>A backstory regenerator is installed.</description>
|
||||||
|
<spawnThingOnRemoved>Wula_BackstoryRegeneratorImplant</spawnThingOnRemoved>
|
||||||
|
<comps>
|
||||||
|
<li Class="WulaFallenEmpire.HediffCompProperties_RegenerateBackstory">
|
||||||
|
<spawnCategories>
|
||||||
|
<li>Wula_Backstory_Categories</li>
|
||||||
|
</spawnCategories>
|
||||||
|
<regenerateChildhood>false</regenerateChildhood>
|
||||||
|
</li>
|
||||||
|
</comps>
|
||||||
|
</HediffDef>
|
||||||
|
|
||||||
|
<RecipeDef ParentName="SurgeryInstallImplantBase">
|
||||||
|
<defName>InstallWulaBackstoryRegenerator</defName>
|
||||||
|
<label>install backstory regenerator</label>
|
||||||
|
<description>Installs a backstory regenerator.</description>
|
||||||
|
<jobString>Installing backstory regenerator.</jobString>
|
||||||
|
<ingredients>
|
||||||
|
<li>
|
||||||
|
<filter>
|
||||||
|
<thingDefs>
|
||||||
|
<li>Wula_BackstoryRegeneratorImplant</li>
|
||||||
|
</thingDefs>
|
||||||
|
</filter>
|
||||||
|
<count>1</count>
|
||||||
|
</li>
|
||||||
|
</ingredients>
|
||||||
|
<fixedIngredientFilter>
|
||||||
|
<thingDefs>
|
||||||
|
<li>Wula_BackstoryRegeneratorImplant</li>
|
||||||
|
</thingDefs>
|
||||||
|
</fixedIngredientFilter>
|
||||||
|
<appliedOnFixedBodyParts>
|
||||||
|
<li>Brain</li>
|
||||||
|
</appliedOnFixedBodyParts>
|
||||||
|
<addsHediff>Wula_RegenerateBackstory</addsHediff>
|
||||||
|
</RecipeDef>
|
||||||
|
|
||||||
|
</Defs>
|
||||||
7
Languages/ChineseSimplified/Keyed/Hediffs_Wula_Keys.xml
Normal file
7
Languages/ChineseSimplified/Keyed/Hediffs_Wula_Keys.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<LanguageData>
|
||||||
|
|
||||||
|
<Wula_RegenerateBackstoryHediff.label>背景故事重塑</Wula_RegenerateBackstoryHediff.label>
|
||||||
|
<Wula_RegenerateBackstoryHediff.description>这个效果会重新生成小人的背景故事,然后自行移除。</Wula_RegenerateBackstoryHediff.description>
|
||||||
|
|
||||||
|
</LanguageData>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<LanguageData>
|
||||||
|
|
||||||
|
<Wula_BackstoryRegeneratorImplant.label>背景故事重构器</Wula_BackstoryRegeneratorImplant.label>
|
||||||
|
<Wula_BackstoryRegeneratorImplant.description>一种一次性植入物,可以重构一个人的记忆和经历,有效地赋予他们一个新的背景故事。该过程不稳定,植入物在使用后会被消耗。</Wula_BackstoryRegeneratorImplant.description>
|
||||||
|
|
||||||
|
<Wula_RegenerateBackstory.label>背景故事重构器</Wula_RegenerateBackstory.label>
|
||||||
|
<Wula_RegenerateBackstory.labelNoun>一个背景故事重构器</Wula_RegenerateBackstory.labelNoun>
|
||||||
|
<Wula_RegenerateBackstory.description>背景故事重构器已安装。</Wula_RegenerateBackstory.description>
|
||||||
|
|
||||||
|
<InstallWulaBackstoryRegenerator.label>安装背景故事重构器</InstallWulaBackstoryRegenerator.label>
|
||||||
|
<InstallWulaBackstoryRegenerator.description>安装一个背景故事重构器。</InstallWulaBackstoryRegenerator.description>
|
||||||
|
<InstallWulaBackstoryRegenerator.jobString>正在安装背景故事重构器。</InstallWulaBackstoryRegenerator.jobString>
|
||||||
|
|
||||||
|
</LanguageData>
|
||||||
Binary file not shown.
@@ -1,9 +1,21 @@
|
|||||||
{
|
{
|
||||||
"Version": 1,
|
"Version": 1,
|
||||||
"WorkspaceRootPath": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\WulaFallenEmpire\\Source\\WulaFallenEmpire\\",
|
"WorkspaceRootPath": "C:\\Steam\\steamapps\\workshop\\content\\294100\\3516260226\\Source\\WulaFallenEmpire\\",
|
||||||
"Documents": [
|
"Documents": [
|
||||||
{
|
{
|
||||||
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|d:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\wulafallenempire\\source\\wulafallenempire\\building_wula_darkenergy_engine.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|C:\\Steam\\steamapps\\workshop\\content\\294100\\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\\workshop\\content\\294100\\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\\workshop\\content\\294100\\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\\workshop\\content\\294100\\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}"
|
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:building_wula_darkenergy_engine.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -14,20 +26,62 @@
|
|||||||
"DocumentGroups": [
|
"DocumentGroups": [
|
||||||
{
|
{
|
||||||
"DockedWidth": 200,
|
"DockedWidth": 200,
|
||||||
"SelectedChildIndex": 0,
|
"SelectedChildIndex": 3,
|
||||||
"Children": [
|
"Children": [
|
||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
"DocumentIndex": 0,
|
"DocumentIndex": 1,
|
||||||
"Title": "Building_Wula_DarkEnergy_Engine.cs",
|
"Title": "HediffComp_RegenerateBackstory.cs",
|
||||||
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\WulaFallenEmpire\\Source\\WulaFallenEmpire\\Building_Wula_DarkEnergy_Engine.cs",
|
"DocumentMoniker": "C:\\Steam\\steamapps\\workshop\\content\\294100\\3516260226\\Source\\WulaFallenEmpire\\HediffComp_RegenerateBackstory.cs",
|
||||||
"RelativeDocumentMoniker": "Building_Wula_DarkEnergy_Engine.cs",
|
"RelativeDocumentMoniker": "HediffComp_RegenerateBackstory.cs",
|
||||||
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\WulaFallenEmpire\\Source\\WulaFallenEmpire\\Building_Wula_DarkEnergy_Engine.cs",
|
"ToolTip": "C:\\Steam\\steamapps\\workshop\\content\\294100\\3516260226\\Source\\WulaFallenEmpire\\HediffComp_RegenerateBackstory.cs",
|
||||||
"RelativeToolTip": "Building_Wula_DarkEnergy_Engine.cs",
|
"RelativeToolTip": "HediffComp_RegenerateBackstory.cs",
|
||||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAwAAAABAAAAAAAAAA==",
|
"ViewState": "AQIAAB4AAAAAAAAAAAAIwHIAAAABAAAA",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2025-07-14T12:24:18.86Z",
|
"WhenOpened": "2025-07-18T11:23:19.064Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Bookmark",
|
||||||
|
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Document",
|
||||||
|
"DocumentIndex": 2,
|
||||||
|
"Title": "WulaFallenEmpireMod.cs",
|
||||||
|
"DocumentMoniker": "C:\\Steam\\steamapps\\workshop\\content\\294100\\3516260226\\Source\\WulaFallenEmpire\\WulaFallenEmpireMod.cs",
|
||||||
|
"RelativeDocumentMoniker": "WulaFallenEmpireMod.cs",
|
||||||
|
"ToolTip": "C:\\Steam\\steamapps\\workshop\\content\\294100\\3516260226\\Source\\WulaFallenEmpire\\WulaFallenEmpireMod.cs",
|
||||||
|
"RelativeToolTip": "WulaFallenEmpireMod.cs",
|
||||||
|
"ViewState": "AQIAAAAAAAAAAAAAAADwvxQAAAAAAAAA",
|
||||||
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
|
"WhenOpened": "2025-07-18T10:23:17.898Z",
|
||||||
|
"EditorCaption": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Document",
|
||||||
|
"DocumentIndex": 0,
|
||||||
|
"Title": "MechanitorPatch.cs",
|
||||||
|
"DocumentMoniker": "C:\\Steam\\steamapps\\workshop\\content\\294100\\3516260226\\Source\\WulaFallenEmpire\\MechanitorPatch.cs",
|
||||||
|
"RelativeDocumentMoniker": "MechanitorPatch.cs",
|
||||||
|
"ToolTip": "C:\\Steam\\steamapps\\workshop\\content\\294100\\3516260226\\Source\\WulaFallenEmpire\\MechanitorPatch.cs",
|
||||||
|
"RelativeToolTip": "MechanitorPatch.cs",
|
||||||
|
"ViewState": "AQIAAAAAAAAAAAAAAAAAABYAAAAiAAAA",
|
||||||
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
|
"WhenOpened": "2025-07-18T10:20:31.368Z",
|
||||||
|
"EditorCaption": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Document",
|
||||||
|
"DocumentIndex": 3,
|
||||||
|
"Title": "Building_Wula_DarkEnergy_Engine.cs",
|
||||||
|
"DocumentMoniker": "C:\\Steam\\steamapps\\workshop\\content\\294100\\3516260226\\Source\\WulaFallenEmpire\\Building_Wula_DarkEnergy_Engine.cs",
|
||||||
|
"RelativeDocumentMoniker": "Building_Wula_DarkEnergy_Engine.cs",
|
||||||
|
"ToolTip": "C:\\Steam\\steamapps\\workshop\\content\\294100\\3516260226\\Source\\WulaFallenEmpire\\Building_Wula_DarkEnergy_Engine.cs",
|
||||||
|
"RelativeToolTip": "Building_Wula_DarkEnergy_Engine.cs",
|
||||||
|
"ViewState": "AQIAAAYAAAAAAAAAAADwvwAAAAAAAAAA",
|
||||||
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
|
"WhenOpened": "2025-07-14T12:24:18.86Z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
115
Source/WulaFallenEmpire/HediffComp_RegenerateBackstory.cs
Normal file
115
Source/WulaFallenEmpire/HediffComp_RegenerateBackstory.cs
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Verse;
|
||||||
|
using RimWorld;
|
||||||
|
|
||||||
|
namespace WulaFallenEmpire
|
||||||
|
{
|
||||||
|
// HediffCompProperties,用于在XML中配置组件的属性
|
||||||
|
public class HediffCompProperties_RegenerateBackstory : HediffCompProperties
|
||||||
|
{
|
||||||
|
public List<string> spawnCategories; // 存储背景故事类别的列表
|
||||||
|
public bool regenerateChildhood = false; // 控制是否重新生成幼年时期故事,默认为false
|
||||||
|
|
||||||
|
public HediffCompProperties_RegenerateBackstory()
|
||||||
|
{
|
||||||
|
this.compClass = typeof(HediffComp_RegenerateBackstory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HediffComp的实际逻辑实现
|
||||||
|
public class HediffComp_RegenerateBackstory : HediffComp
|
||||||
|
{
|
||||||
|
private HediffCompProperties_RegenerateBackstory Props => (HediffCompProperties_RegenerateBackstory)this.props;
|
||||||
|
|
||||||
|
public override void CompPostMake()
|
||||||
|
{
|
||||||
|
base.CompPostMake();
|
||||||
|
// 在Hediff被添加到Pawn时立即触发背景故事重新生成
|
||||||
|
// 使用一个延迟操作,确保Pawn完全初始化后再修改其故事
|
||||||
|
// 否则可能导致Pawn.story为null
|
||||||
|
LongEventHandler.QueueLongEvent(RegenerateBackstory, "RegeneratingBackstory", false, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RegenerateBackstory()
|
||||||
|
{
|
||||||
|
Pawn pawn = this.parent.pawn;
|
||||||
|
if (pawn == null || pawn.story == null)
|
||||||
|
{
|
||||||
|
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: Pawn or Pawn.story is null for hediff {this.parent.def.defName}. Cannot regenerate backstory.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取指定的背景故事类别
|
||||||
|
List<string> categories = new List<string>();
|
||||||
|
if (Props.spawnCategories != null && Props.spawnCategories.Any())
|
||||||
|
{
|
||||||
|
categories = Props.spawnCategories;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: No spawnCategories specified for hediff {this.parent.def.defName}. Using all available categories.");
|
||||||
|
categories = DefDatabase<BackstoryDef>.AllDefs.SelectMany(bs => bs.spawnCategories).Distinct().ToList(); // 如果没有指定类别,则使用所有类别
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试重新生成背景故事
|
||||||
|
BackstoryDef newChildhood = null;
|
||||||
|
BackstoryDef newAdulthood = null;
|
||||||
|
|
||||||
|
// 根据 regenerateChildhood 的值决定是否重新生成幼年时期故事
|
||||||
|
if (Props.regenerateChildhood)
|
||||||
|
{
|
||||||
|
// 筛选符合类别的幼年背景故事
|
||||||
|
List<BackstoryDef> availableChildhoodBackstories = DefDatabase<BackstoryDef>.AllDefsListForReading
|
||||||
|
.Where(bs => bs.slot == BackstorySlot.Childhood && bs.spawnCategories.Any(cat => categories.Contains(cat)))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
// 随机选择幼年背景故事
|
||||||
|
if (availableChildhoodBackstories.Any())
|
||||||
|
{
|
||||||
|
newChildhood = availableChildhoodBackstories.RandomElement();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: No childhood backstories found for categories: {string.Join(", ", Props.spawnCategories ?? new List<string>())}.");
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// 如果 regenerateChildhood 为 false,则保留原有的幼年时期故事
|
||||||
|
newChildhood = pawn.story.Childhood;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 筛选符合类别的成年背景故事
|
||||||
|
List<BackstoryDef> availableAdulthoodBackstories = DefDatabase<BackstoryDef>.AllDefsListForReading
|
||||||
|
.Where(bs => bs.slot == BackstorySlot.Adulthood && bs.spawnCategories.Any(cat => categories.Contains(cat)))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
// 随机选择成年背景故事
|
||||||
|
if (availableAdulthoodBackstories.Any())
|
||||||
|
{
|
||||||
|
newAdulthood = availableAdulthoodBackstories.RandomElement();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: No adulthood backstories found for categories: {string.Join(", ", Props.spawnCategories ?? new List<string>())}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 应用新的背景故事
|
||||||
|
if (newChildhood != null || newAdulthood != null)
|
||||||
|
{
|
||||||
|
pawn.story.Childhood = newChildhood;
|
||||||
|
pawn.story.Adulthood = newAdulthood;
|
||||||
|
Log.Message($"[WulaFallenEmpire] Regenerated backstory for {pawn.NameShortColored}: Childhood='{newChildhood?.title ?? "None"}', Adulthood='{newAdulthood?.title ?? "None"}'.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Warning($"[WulaFallenEmpire] HediffComp_RegenerateBackstory: Failed to find any suitable backstories for {pawn.NameShortColored} with categories: {string.Join(", ", Props.spawnCategories ?? new List<string>())}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除当前的Hediff
|
||||||
|
pawn.health.RemoveHediff(this.parent);
|
||||||
|
Log.Message($"[WulaFallenEmpire] Removed hediff {this.parent.def.defName} from {pawn.NameShortColored} after backstory regeneration.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
43
Source/WulaFallenEmpire/MechanitorPatch.cs
Normal file
43
Source/WulaFallenEmpire/MechanitorPatch.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using RimWorld;
|
||||||
|
using Verse;
|
||||||
|
using HarmonyLib; // 引入Harmony库
|
||||||
|
|
||||||
|
// 定义一个新的HediffComp,用于标记可以赋予机械师能力的Hediff
|
||||||
|
public class HediffComp_MakesMechanitor : HediffComp
|
||||||
|
{
|
||||||
|
// 这个组件本身不需要任何特殊逻辑,它的存在就是标记
|
||||||
|
}
|
||||||
|
|
||||||
|
// Harmony Patch类,用于修改MechanitorUtility.ShouldBeMechanitor方法
|
||||||
|
[HarmonyPatch(typeof(MechanitorUtility), "ShouldBeMechanitor")]
|
||||||
|
public static class MechanitorShouldBeMechanitorPatch
|
||||||
|
{
|
||||||
|
// Postfix方法将在原始方法执行后运行
|
||||||
|
// originalResult 是原始方法的返回值
|
||||||
|
// pawn 是原始方法的参数
|
||||||
|
public static void Postfix(Pawn pawn, ref bool __result)
|
||||||
|
{
|
||||||
|
// 如果原始方法已经返回true,则无需进一步检查
|
||||||
|
if (__result)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查Biotech DLC是否激活且Pawn属于玩家安全派系
|
||||||
|
if (ModsConfig.BiotechActive && pawn.Faction.IsPlayerSafe())
|
||||||
|
{
|
||||||
|
// 遍历Pawn的所有Hediff,检查是否存在HediffComp_MakesMechanitor组件
|
||||||
|
foreach (Hediff hediff in pawn.health.hediffSet.hediffs)
|
||||||
|
{
|
||||||
|
if (hediff.TryGetComp<HediffComp_MakesMechanitor>() != null)
|
||||||
|
{
|
||||||
|
__result = true; // 如果找到,则将结果设置为true
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,6 +31,10 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="0Harmony">
|
||||||
|
<HintPath>..\..\..\2009463077\1.5\Assemblies\0Harmony.dll</HintPath>
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Assembly-CSharp">
|
<Reference Include="Assembly-CSharp">
|
||||||
<HintPath>..\..\..\..\..\..\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
|
<HintPath>..\..\..\..\..\..\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
@@ -54,8 +58,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Building_Wula_DarkEnergy_Engine.cs" />
|
<Compile Include="Building_Wula_DarkEnergy_Engine.cs" />
|
||||||
|
<Compile Include="MechanitorPatch.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SectionLayer_WulaHull.cs" />
|
<Compile Include="SectionLayer_WulaHull.cs" />
|
||||||
|
<Compile Include="HediffComp_RegenerateBackstory.cs" />
|
||||||
|
<Compile Include="WulaFallenEmpireMod.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
20
Source/WulaFallenEmpire/WulaFallenEmpireMod.cs
Normal file
20
Source/WulaFallenEmpire/WulaFallenEmpireMod.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using HarmonyLib;
|
||||||
|
using Verse;
|
||||||
|
|
||||||
|
namespace WulaFallenEmpire
|
||||||
|
{
|
||||||
|
[StaticConstructorOnStartup]
|
||||||
|
public class WulaFallenEmpireMod : Mod
|
||||||
|
{
|
||||||
|
public WulaFallenEmpireMod(ModContentPack content) : base(content)
|
||||||
|
{
|
||||||
|
// 初始化Harmony
|
||||||
|
var harmony = new Harmony("tourswen.wulafallenempire"); // 替换为您的唯一Mod ID
|
||||||
|
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
||||||
|
|
||||||
|
Log.Message("[WulaFallenEmpire] Harmony patches applied.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
7322c4600dadaa91ac1b2bb031e9cbc014b17bc3975a22153da6ee0f9d7e3730
|
72de1e9a7da52e157c70cc86abd8fa9924b925654b82d1642885fb3932330213
|
||||||
|
|||||||
@@ -37,3 +37,9 @@ E:\SteamLibrary\steamapps\common\RimWorld\Mods\WulaFallenEmpire\Source\WulaFalle
|
|||||||
E:\SteamLibrary\steamapps\common\RimWorld\Mods\WulaFallenEmpire\Source\WulaFallenEmpire\obj\Debug\WulaFall.44DB8A10.Up2Date
|
E:\SteamLibrary\steamapps\common\RimWorld\Mods\WulaFallenEmpire\Source\WulaFallenEmpire\obj\Debug\WulaFall.44DB8A10.Up2Date
|
||||||
E:\SteamLibrary\steamapps\common\RimWorld\Mods\WulaFallenEmpire\Source\WulaFallenEmpire\obj\Debug\WulaFallenEmpire.dll
|
E:\SteamLibrary\steamapps\common\RimWorld\Mods\WulaFallenEmpire\Source\WulaFallenEmpire\obj\Debug\WulaFallenEmpire.dll
|
||||||
E:\SteamLibrary\steamapps\common\RimWorld\Mods\WulaFallenEmpire\Source\WulaFallenEmpire\obj\Debug\WulaFallenEmpire.pdb
|
E:\SteamLibrary\steamapps\common\RimWorld\Mods\WulaFallenEmpire\Source\WulaFallenEmpire\obj\Debug\WulaFallenEmpire.pdb
|
||||||
|
C:\Steam\steamapps\workshop\content\294100\3516260226\1.6\Assemblies\WulaFallenEmpire.dll
|
||||||
|
C:\Steam\steamapps\workshop\content\294100\3516260226\1.6\Assemblies\WulaFallenEmpire.pdb
|
||||||
|
C:\Steam\steamapps\workshop\content\294100\3516260226\Source\WulaFallenEmpire\obj\Debug\WulaFallenEmpire.csproj.AssemblyReference.cache
|
||||||
|
C:\Steam\steamapps\workshop\content\294100\3516260226\Source\WulaFallenEmpire\obj\Debug\WulaFallenEmpire.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Steam\steamapps\workshop\content\294100\3516260226\Source\WulaFallenEmpire\obj\Debug\WulaFallenEmpire.dll
|
||||||
|
C:\Steam\steamapps\workshop\content\294100\3516260226\Source\WulaFallenEmpire\obj\Debug\WulaFallenEmpire.pdb
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user