Merge branch 'mechworkproxy' into animalwork
# Conflicts: # 1.6/1.6/Assemblies/ArachnaeSwarm.dll
This commit is contained in:
Binary file not shown.
@@ -135,7 +135,7 @@
|
||||
<armorPenetrationBase>0.1</armorPenetrationBase>
|
||||
<stoppingPower>1</stoppingPower>
|
||||
<shadowSize>0</shadowSize>
|
||||
<spawnTerrain>InsectSludge</spawnTerrain>
|
||||
<spawnTerrain>ARA_InsectSludge</spawnTerrain>
|
||||
<terrainChance>0.75</terrainChance>
|
||||
<filth>Filth_Slime</filth>
|
||||
<filthCount>1</filthCount>
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
</AlienRace.AlienBackstoryDef>
|
||||
<AlienRace.AlienBackstoryDef ParentName="ARA_BaseBackStory">
|
||||
<defName>Arachnae_Queen_BS_Adult_1</defName>
|
||||
<title>王道征途</title>
|
||||
<titleShort>王道征途</titleShort>
|
||||
<title>见习女皇</title>
|
||||
<titleShort>见习女皇</titleShort>
|
||||
<description>[PAWN_nameDef]顺利地在虫巢中长大后,她离开了生养她的巢穴并来到一片陌生的地域,着手准备建立自己的势力。\n\n[PAWN_nameDef]知道自己势单力薄,比起其他娇生惯养的姐妹,她在很多事情上更愿意亲力亲为。</description>
|
||||
<slot>Adulthood</slot>
|
||||
<skillGains>
|
||||
@@ -47,9 +47,9 @@
|
||||
|
||||
<AlienRace.AlienBackstoryDef ParentName="ARA_BaseBackStory">
|
||||
<defName>Arachnae_Node_BS_Child_1</defName>
|
||||
<title>阿拉克涅虫族</title>
|
||||
<titleShort>阿拉克涅虫族</titleShort>
|
||||
<description>[PAWN_nameDef]是一只阿拉克涅虫族。</description>
|
||||
<title>阿拉克涅督虫</title>
|
||||
<titleShort>督虫</titleShort>
|
||||
<description>[PAWN_nameDef]是一只阿拉克涅督虫——这个种姓的阿拉克涅虫族是虫巢的中坚力量,服从于女皇种的指挥的同时,也指挥着麾下的辅虫。她们从诞生之初便肩负着不同的使命,并且在较短的寿命中尽心尽力地服侍虫群。</description>
|
||||
<slot>Childhood</slot>
|
||||
|
||||
<spawnCategories>
|
||||
@@ -62,16 +62,15 @@
|
||||
|
||||
<requiresSpawnCategory>true</requiresSpawnCategory>
|
||||
</AlienRace.AlienBackstoryDef>
|
||||
|
||||
<AlienRace.AlienBackstoryDef ParentName="ARA_BaseBackStory">
|
||||
<defName>Arachnae_Node_BS_Adult_1</defName>
|
||||
<title>阿拉克涅督虫种</title>
|
||||
<titleShort>阿拉克涅督虫种</titleShort>
|
||||
<description>[PAWN_nameDef]是一只阿拉克涅督虫种。</description>
|
||||
<defName>Arachnae_Node_BS_Adult_Myrmecocystus</defName>
|
||||
<title>阿拉克涅蜜罐种</title>
|
||||
<titleShort>蜜罐种</titleShort>
|
||||
<description>[PAWN_nameDef]是一只阿拉克涅蜜罐种督虫。基因的选择性表达使其长出了肿胀的囊袋和复杂的口器,这使得她可以吞噬那些未经过处理的尸体和各种杂食,并通过消化器官将其转变为阿拉克涅虫蜜以供其他虫族食用。\n\n[PAWN_nameDef]在战斗中并不是一个值得正视的对手,她虽然可以将胃酸喷出以抵抗近距离的来访者,但是自身没有可以接入武装器官的副肢,脆弱臃肿的特性也决定了她几乎无法躲开任何攻击。</description>
|
||||
<slot>Adulthood</slot>
|
||||
|
||||
<spawnCategories>
|
||||
<li>ArachnaeNode_spawnCategoriesB</li>
|
||||
<li>ArachnaeNode_spawnCategories_Myrmecocystus</li>
|
||||
</spawnCategories>
|
||||
</AlienRace.AlienBackstoryDef>
|
||||
</Defs>
|
||||
@@ -2,8 +2,8 @@
|
||||
<Defs>
|
||||
<HediffDef>
|
||||
<defName>ARA_AcidCoverd</defName>
|
||||
<label>阿拉克涅虫液</label>
|
||||
<description>一支拥有酸囊的阿拉克涅虫族向此人喷射了强酸,沾染的强酸将使得此人痛不欲生,盔甲和表皮软化,并持续灼烧它的身体。</description>
|
||||
<label>阿拉克涅酸液</label>
|
||||
<description>一支拥有酸囊的阿拉克涅虫族向此人喷射了强酸,沾染的液体将使得此人痛不欲生,盔甲和表皮软化,并持续灼烧它的身体。</description>
|
||||
<defaultLabelColor>(1, 1, 0.8)</defaultLabelColor>
|
||||
<hediffClass>ArachnaeSwarm.HediffCurseFlame</hediffClass>
|
||||
<comps>
|
||||
@@ -18,7 +18,7 @@
|
||||
<modExtensions>
|
||||
<li Class="ArachnaeSwarm.CurseFlameModExt">
|
||||
<damageDefName>AcidBurn</damageDefName>
|
||||
<damageRange>1~5</damageRange>
|
||||
<damageRange>1~2</damageRange>
|
||||
<damageIntervalTicks>40</damageIntervalTicks>
|
||||
</li>
|
||||
</modExtensions>
|
||||
|
||||
@@ -14,6 +14,16 @@
|
||||
<label>连接至 {0} 个虫群工蜂</label>
|
||||
<minSeverity>0</minSeverity>
|
||||
<!-- Stat offsets will be added here later -->
|
||||
<disablesNeeds>
|
||||
<li>Joy</li>
|
||||
<li>Beauty</li>
|
||||
<li>Comfort</li>
|
||||
<li>Outdoors</li>
|
||||
<li>Chemical_Alcohol</li>
|
||||
</disablesNeeds>
|
||||
<enablesNeeds>
|
||||
<li>Indoors</li>
|
||||
</enablesNeeds>
|
||||
</li>
|
||||
</stages>
|
||||
</HediffDef>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
</PawnKindDef>
|
||||
<PawnKindDef Name="ArachnaeNodeA_Colonist" ParentName="ArachnaeNodeABasePawnKind">
|
||||
<defName>ArachnaeNode_Race_Myrmecocystus</defName>
|
||||
<label>阿拉克涅督虫种</label>
|
||||
<label>阿拉克涅蜜罐种</label>
|
||||
<race>ArachnaeNode_Race_Myrmecocystus</race>
|
||||
<defaultFactionType>PlayerColony</defaultFactionType>
|
||||
<invNutrition>2.55</invNutrition>
|
||||
@@ -108,7 +108,7 @@
|
||||
<li>
|
||||
<categories>
|
||||
<li>ArachnaeNode_spawnCategoriesA</li>
|
||||
<li>ArachnaeNode_spawnCategoriesB</li>
|
||||
<li>ArachnaeNode_spawnCategories_Myrmecocystus</li>
|
||||
</categories>
|
||||
</li>
|
||||
</backstoryFiltersOverride>
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
</li>
|
||||
</tools>
|
||||
<race>
|
||||
<thinkTreeMain>ARA_InsectWorker</thinkTreeMain>
|
||||
<body>BeetleLikeWithClaw</body>
|
||||
<thinkTreeMain>ARA_Insect_WithPlanting</thinkTreeMain>
|
||||
<baseHungerRate>0.25</baseHungerRate>
|
||||
@@ -102,7 +103,26 @@
|
||||
<deathAction Class="DeathActionProperties_Vanish">
|
||||
<workerClass>DeathActionWorker_Vanish</workerClass>
|
||||
</deathAction>
|
||||
<mechEnabledWorkTypes Inherit="False">
|
||||
<li>Hauling</li>
|
||||
<li>Mining</li>
|
||||
<li>Construction</li>
|
||||
<li>Crafting</li>
|
||||
<li>Smithing</li>
|
||||
<li>Tailoring</li>
|
||||
<li>Cooking</li>
|
||||
<li>Research</li>
|
||||
<li>PlantCutting</li>
|
||||
<li>Growing</li>
|
||||
<li>Cleaning</li>
|
||||
<li>Doctor</li>
|
||||
<li>Firefighter</li>
|
||||
</mechEnabledWorkTypes>
|
||||
<mechFixedSkillLevel>10</mechFixedSkillLevel>
|
||||
</race>
|
||||
<comps>
|
||||
<li Class="ArachnaeSwarm.CompProperties_WorkForNonMechs"/>
|
||||
</comps>
|
||||
<tradeTags>
|
||||
<li>AnimalInsect</li>
|
||||
</tradeTags>
|
||||
|
||||
@@ -242,7 +242,7 @@
|
||||
<!-- 手术继承自人类 -->
|
||||
<humanRecipeImport>false</humanRecipeImport>
|
||||
<!-- 睡觉定义 -->
|
||||
<canLayDown>true</canLayDown>
|
||||
<canLayDown>false</canLayDown>
|
||||
<!-- 各种零件定义 -->
|
||||
<alienPartGenerator Inherit="False">
|
||||
<!-- 允许的头部 -->
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
<ThingDef ParentName="OrganicProductBase">
|
||||
<defName>ARA_InsectJelly</defName>
|
||||
<label>阿拉克涅虫蜜</label>
|
||||
<description>由虫族储存和用作食物的果冻。它顺滑、浓郁,能满足食用者的娱乐需求。由于其独特的生物特性,它几乎可以滋养任何生物,永不腐烂。</description>
|
||||
<possessionCount>10</possessionCount>
|
||||
<description>由阿拉克涅虫族储存和用作食物的果冻。它顺滑、浓郁、永不腐烂,能满足食用者的娱乐需求。由于其独特的生物特性,非阿拉克涅虫族也可以食用这种食物,并且不会引起食物中毒。</description>
|
||||
<possessionCount>20</possessionCount>
|
||||
<graphicData>
|
||||
<texPath>Things/Item/Resource/AnimalProductRaw/InsectJelly</texPath>
|
||||
<graphicClass>Graphic_StackCount</graphicClass>
|
||||
</graphicData>
|
||||
<socialPropernessMatters>true</socialPropernessMatters>
|
||||
<statBases>
|
||||
<MarketValue>8.0</MarketValue>
|
||||
<MarketValue>5.0</MarketValue>
|
||||
<Mass>0.025</Mass>
|
||||
<Nutrition>0.1</Nutrition>
|
||||
<FoodPoisonChanceFixedHuman>0.02</FoodPoisonChanceFixedHuman>
|
||||
<FoodPoisonChanceFixedHuman>0</FoodPoisonChanceFixedHuman>
|
||||
</statBases>
|
||||
<ingestible>
|
||||
<foodType>AnimalProduct</foodType>
|
||||
|
||||
84
1.6/1.6/Defs/Thing_building/ARA_Building.xml
Normal file
84
1.6/1.6/Defs/Thing_building/ARA_Building.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
<TerrainDef ParentName="FloorBase">
|
||||
<defName>ARA_InsectSludge</defName>
|
||||
<label>阿拉克涅菌毯</label>
|
||||
<description>由阿拉克涅虫族所铺设的由真菌和分泌物混合得到的地面,清洁速度很快,但是对其他种族来说不太好看。</description>
|
||||
<designationCategory>Floors</designationCategory>
|
||||
<texturePath>Terrain/Surfaces/InsectSludge</texturePath>
|
||||
<pollutionShaderType MayRequire="Ludeon.RimWorld.Biotech">TerrainFadeRoughLinearBurn</pollutionShaderType>
|
||||
<pollutionOverlayTexturePath>Terrain/Surfaces/PollutionMud</pollutionOverlayTexturePath>
|
||||
<pollutionColor>(1, 1, 1, 1)</pollutionColor>
|
||||
<edgeType>FadeRough</edgeType>
|
||||
<resourcesFractionWhenDeconstructed>0</resourcesFractionWhenDeconstructed>
|
||||
<renderPrecedence>330</renderPrecedence>
|
||||
<pathCost>0</pathCost>
|
||||
<generatedFilth>Filth_Slime</generatedFilth>
|
||||
<filthAcceptanceMask>
|
||||
<li>Unnatural</li>
|
||||
</filthAcceptanceMask>
|
||||
<natural>true</natural>
|
||||
<fertility>0</fertility>
|
||||
<takeFootprints>True</takeFootprints>
|
||||
<avoidWander>false</avoidWander>
|
||||
<statBases>
|
||||
<Beauty>-6</Beauty>
|
||||
<CleaningTimeFactor>0.25</CleaningTimeFactor>
|
||||
<Cleanliness>0</Cleanliness>
|
||||
<Flammability>0.2</Flammability>
|
||||
</statBases>
|
||||
<!-- <tags>
|
||||
<li>Insect</li>
|
||||
</tags> -->
|
||||
</TerrainDef>
|
||||
<ThingDef ParentName="Wall">
|
||||
<defName>ARA_InsectWall</defName>
|
||||
<label>堆积山岩</label>
|
||||
<description>阿拉克涅工蜂将硬质岩石堆起来形成的墙壁,非常坚硬并且不会花费材料,就是看起来不太美观。</description>
|
||||
<uiOrder>1800</uiOrder>
|
||||
<uiIconPath>Wula/Building/Linked/WULA_Fortress_Wall_MenuIcon</uiIconPath>
|
||||
<graphicData>
|
||||
<texPath>ArachnaeSwarm/Building/ARA_InsectWall</texPath>
|
||||
<graphicClass>Graphic_Single</graphicClass>
|
||||
<shaderType>CutoutComplex</shaderType>
|
||||
</graphicData>
|
||||
<designationCategory>Structure</designationCategory>
|
||||
<mineable>true</mineable>
|
||||
<blockLight>true</blockLight>
|
||||
<statBases>
|
||||
<MarketValue>0</MarketValue>
|
||||
<Beauty>-6</Beauty>
|
||||
<MaxHitPoints>1000</MaxHitPoints>
|
||||
<WorkToBuild>1500</WorkToBuild>
|
||||
<Flammability>0</Flammability>
|
||||
<Cleanliness>0</Cleanliness>
|
||||
</statBases>
|
||||
<building>
|
||||
<isAirtight>true</isAirtight>
|
||||
<isNaturalRock>true</isNaturalRock>
|
||||
</building>
|
||||
<terrainAffordanceNeeded>Heavy</terrainAffordanceNeeded>
|
||||
<costStuffCount>0</costStuffCount>
|
||||
<stuffCategories Inherit="False"/>
|
||||
<!-- <placeWorkers>
|
||||
<li>PlaceWorker_OnSubstructure</li>
|
||||
</placeWorkers> -->
|
||||
<damageMultipliers Inherit="False">
|
||||
<li>
|
||||
<damageDef>Bomb</damageDef>
|
||||
<multiplier>0.1</multiplier>
|
||||
</li>
|
||||
<li>
|
||||
<damageDef>Thump</damageDef>
|
||||
<multiplier>0.1</multiplier>
|
||||
</li>
|
||||
</damageMultipliers>
|
||||
<comps>
|
||||
<li Class="ArachnaeSwarm.CompProperties_DelayedTerrainSpawn">
|
||||
<delayTicks>60</delayTicks> <!-- 60 ticks = 1 second -->
|
||||
<terrainToSpawn>ARA_InsectSludge</terrainToSpawn>
|
||||
<spawnRadius>1.35</spawnRadius>
|
||||
</li>
|
||||
</comps>
|
||||
</ThingDef>
|
||||
</Defs>
|
||||
@@ -3,7 +3,7 @@
|
||||
<ThingDef ParentName="BuildingNaturalBase">
|
||||
<defName>ARA_InteractiveEggSac</defName>
|
||||
<label>阿拉克涅虫卵囊-休眠中</label>
|
||||
<description>一个脆弱、易燃、黏滑的囊状物,是阿拉克涅女皇种所诞之卵,内含哺育一只新督虫所需的营养和遗传物质——可以通过阿拉克涅女皇种的交互完成激活进程。</description>
|
||||
<description>一个脆弱、易燃、黏滑的囊状物,是阿拉克涅女皇种所诞之卵,内含哺育一只新督虫所需的营养和遗传物质,可以通过阿拉克涅女皇种的交互完成激活进程——参阅虫卵的具体信息,了解各个督虫的特点。</description>
|
||||
<thingClass>Building</thingClass>
|
||||
<descriptionHyperlinks>
|
||||
<ThingDef>ArachnaeNode_Race_Myrmecocystus</ThingDef>
|
||||
@@ -96,38 +96,5 @@
|
||||
<spawnRadius>4.6</spawnRadius>
|
||||
</li>
|
||||
</comps>
|
||||
|
||||
</ThingDef>
|
||||
|
||||
<TerrainDef ParentName="FloorBase">
|
||||
<defName>ARA_InsectSludge</defName>
|
||||
<label>阿拉克涅菌毯</label>
|
||||
<description>由阿拉克涅虫族所铺设的由真菌和分泌物混合得到的地面,清洁速度很快,但是对其他种族来说不太好看。</description>
|
||||
<designationCategory>Floors</designationCategory>
|
||||
<texturePath>Terrain/Surfaces/InsectSludge</texturePath>
|
||||
<pollutionShaderType MayRequire="Ludeon.RimWorld.Biotech">TerrainFadeRoughLinearBurn</pollutionShaderType>
|
||||
<pollutionOverlayTexturePath>Terrain/Surfaces/PollutionMud</pollutionOverlayTexturePath>
|
||||
<pollutionColor>(1, 1, 1, 1)</pollutionColor>
|
||||
<edgeType>FadeRough</edgeType>
|
||||
<resourcesFractionWhenDeconstructed>0</resourcesFractionWhenDeconstructed>
|
||||
<renderPrecedence>330</renderPrecedence>
|
||||
<pathCost>0</pathCost>
|
||||
<generatedFilth>Filth_Slime</generatedFilth>
|
||||
<filthAcceptanceMask>
|
||||
<li>Unnatural</li>
|
||||
</filthAcceptanceMask>
|
||||
<natural>true</natural>
|
||||
<fertility>0</fertility>
|
||||
<takeFootprints>True</takeFootprints>
|
||||
<avoidWander>false</avoidWander>
|
||||
<statBases>
|
||||
<Beauty>-6</Beauty>
|
||||
<CleaningTimeFactor>0.25</CleaningTimeFactor>
|
||||
<Cleanliness>0</Cleanliness>
|
||||
<Flammability>0.2</Flammability>
|
||||
</statBases>
|
||||
<!-- <tags>
|
||||
<li>Insect</li>
|
||||
</tags> -->
|
||||
</TerrainDef>
|
||||
</Defs>
|
||||
444
1.6/1.6/Defs/ThinkTreeDefs/ARA_AnimalWorkThinkTrees.xml
Normal file
444
1.6/1.6/Defs/ThinkTreeDefs/ARA_AnimalWorkThinkTrees.xml
Normal file
@@ -0,0 +1,444 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
<ThinkTreeDef>
|
||||
<defName>ARA_InsectWorker</defName>
|
||||
<thinkRoot Class="ThinkNode_Priority">
|
||||
<subNodes>
|
||||
<!-- Keep lying down if we have to -->
|
||||
<li Class="ThinkNode_ConditionalMustKeepLyingDown">
|
||||
<subNodes>
|
||||
<!-- Do a queued job if possible -->
|
||||
<li Class="ThinkNode_QueuedJob">
|
||||
<inBedOnly>true</inBedOnly>
|
||||
</li>
|
||||
|
||||
<!-- Keep lying down -->
|
||||
<li Class="JobGiver_KeepLyingDown"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>Downed</treeDef>
|
||||
</li>
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>BurningResponse</treeDef>
|
||||
</li>
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>MentalStateCritical</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- React to close melee threat -->
|
||||
<li Class="JobGiver_ReactToCloseMeleeThreat"/>
|
||||
|
||||
<!-- Do a queued job -->
|
||||
<li Class="ThinkNode_QueuedJob"/>
|
||||
|
||||
<!-- Wild insects dig out if no path to map edge and starving -->
|
||||
<li Class="ThinkNode_ConditionalHasFaction">
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalStarving">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalBodySize">
|
||||
<min>0.7</min>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>DigOutIfCannotReachMapEdge</treeDef>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Leave if timed out -->
|
||||
<li Class="ThinkNode_ConditionalExitTimedOut">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_ExitMapRandom">
|
||||
<defaultLocomotion>Walk</defaultLocomotion>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Mental state non critical -->
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>MentalStateNonCritical</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- Forced goto -->
|
||||
<li Class="ThinkNode_ConditionalForcedGoto">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_ForcedGoto"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Behavior when roped -->
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>RopedPawn</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- Lord directives -->
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>LordDuty</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- Insertion hook for modders -->
|
||||
<li Class="ThinkNode_SubtreesByTag">
|
||||
<insertTag>Animal_PreMain</insertTag>
|
||||
</li>
|
||||
<li Class="ThinkNode_SubtreesByTag">
|
||||
<insertTag>Insect_PreMain</insertTag>
|
||||
</li>
|
||||
|
||||
<li Class="ThinkNode_ConditionalHasFaction">
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
<!-- Wild insects with no lord will fight nearby enemies -->
|
||||
<li Class="JobGiver_AIFightEnemies">
|
||||
<targetAcquireRadius>30</targetAcquireRadius> <!-- Same as DefendAndExpandHive -->
|
||||
<targetKeepRadius>35</targetKeepRadius>
|
||||
</li>
|
||||
|
||||
<!-- Wild insects leave map in some conditions -->
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>LeaveIfWrongSeason</treeDef>
|
||||
</li>
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>LeaveIfStarving</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- Wild insects randomly leave map -->
|
||||
<li Class="ThinkNode_ChancePerHour_Constant">
|
||||
<mtbDays>60</mtbDays>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_ExitMapRandom">
|
||||
<defaultLocomotion>Walk</defaultLocomotion>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Insects of a faction that's not the players without a lord leave randomly -->
|
||||
<li Class="ThinkNode_ConditionalOfPlayerFaction">
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalHasFaction">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalNoLord">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ChancePerHour_Constant">
|
||||
<mtbDays>60</mtbDays>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_ExitMapRandom">
|
||||
<defaultLocomotion>Walk</defaultLocomotion>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Tame insects -->
|
||||
<li Class="ThinkNode_ConditionalOfPlayerFaction">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>TrainedAnimalBehavior</tagToGive>
|
||||
<subNodes>
|
||||
<!-- Trained behavior: obedience: Follow and defend master -->
|
||||
<li Class="ThinkNode_ConditionalTrainableCompleted">
|
||||
<trainable>Obedience</trainable>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalShouldFollowMaster">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_AIDefendMaster">
|
||||
<attackMeleeThreatEvenIfNotHostile>true</attackMeleeThreatEvenIfNotHostile>
|
||||
</li>
|
||||
<li Class="JobGiver_AIFollowMaster"/>
|
||||
<li Class="JobGiver_WanderNearMaster"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Trained behavior: Rescue-->
|
||||
<li Class="ThinkNode_ConditionalTrainableCompleted">
|
||||
<trainable>Rescue</trainable>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_RescueNearby">
|
||||
<radius>75</radius>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Take care of critical needs (below rescue - so heroic!)-->
|
||||
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>RestingForMedicalReasons</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_PatientGoToBed"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="JobGiver_SeekAllowedArea"/>
|
||||
<li Class="JobGiver_SeekSafeTemperature"/>
|
||||
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Eat random things out of curiosity -->
|
||||
<li Class="ThinkNode_ChancePerHour_Constant">
|
||||
<mtbDays>60</mtbDays>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>SatisfyingNeeds</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_EatRandom"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Satisfy basic needs -->
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>SatisfyBasicNeeds</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- Tame insect: do useful things for the colony-->
|
||||
<li Class="ThinkNode_ConditionalHasFaction">
|
||||
<subNodes>
|
||||
|
||||
<!-- Do a queued job -->
|
||||
<li Class="ThinkNode_QueuedJob" />
|
||||
|
||||
<li Class="JobGiver_SeekAllowedArea" />
|
||||
<li Class="JobGiver_Work">
|
||||
<emergency>true</emergency>
|
||||
</li>
|
||||
<li Class="JobGiver_Work" />
|
||||
|
||||
<!-- Try to mate -->
|
||||
<li Class="ThinkNode_ChancePerHour_Mate">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>SatisfyingNeeds</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_Mate"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Nuzzle randoms -->
|
||||
<li Class="ThinkNode_ChancePerHour_Nuzzle">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_Nuzzle"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Roamers gonna roam -->
|
||||
<li Class="ThinkNode_ChancePerDay_Roam">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_StartRoaming"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Trained behavior: Haul-->
|
||||
<li Class="ThinkNode_ChancePerHour_Constant">
|
||||
<mtbHours>1.5</mtbHours>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalRequireCapacities">
|
||||
<requiredCapacities>
|
||||
<li>Manipulation</li>
|
||||
</requiredCapacities>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalTrainableCompleted">
|
||||
<trainable>Haul</trainable>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>TrainedAnimalBehavior</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_Haul"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Trained behavior: Forage -->
|
||||
<li Class="ThinkNode_ConditionalTrainableCompleted" MayRequire="Ludeon.RimWorld.Odyssey">
|
||||
<trainable>Forage</trainable>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ChancePerHour_Forage">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalAnimalShouldForage">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_Forage" />
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Trained behavior: Mine -->
|
||||
<li Class="ThinkNode_ConditionalTrainableCompleted" MayRequire="Ludeon.RimWorld.Odyssey">
|
||||
<trainable>Dig</trainable>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalAnimalShouldDig">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_Mine" />
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Insertion hook for modders -->
|
||||
<li Class="ThinkNode_SubtreesByTag">
|
||||
<insertTag>Animal_PreWander</insertTag>
|
||||
</li>
|
||||
<li Class="ThinkNode_SubtreesByTag">
|
||||
<insertTag>Insect_PreWander</insertTag>
|
||||
</li>
|
||||
|
||||
<!-- Tame insect: wander near colony if possible -->
|
||||
<li Class="ThinkNode_ConditionalOfPlayerFaction">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Idle</tagToGive>
|
||||
<subNodes>
|
||||
<!-- Wander near your current position if in hostile map -->
|
||||
<li Class="ThinkNode_ConditionalAnyEnemyInHostileMap">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_WanderAnywhere">
|
||||
<maxDanger>None</maxDanger>
|
||||
<ticksBetweenWandersRange>120~240</ticksBetweenWandersRange>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="ThinkNode_ConditionalRoamer">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_WanderInRoofedCellsInPen">
|
||||
<maxDanger>None</maxDanger>
|
||||
<ticksBetweenWandersRange>120~240</ticksBetweenWandersRange>
|
||||
<expiryInterval>500</expiryInterval>
|
||||
</li>
|
||||
|
||||
<!-- tame roamers should not wander too far, and if unenclosed wander near a suitable pen marker 10% of the time -->
|
||||
<li Class="ThinkNode_ConditionalRandom">
|
||||
<chance>0.1</chance>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_WanderInPen">
|
||||
<maxDanger>None</maxDanger>
|
||||
<ticksBetweenWandersRange>120~240</ticksBetweenWandersRange>
|
||||
<expiryInterval>500</expiryInterval>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="JobGiver_WanderAnywhere">
|
||||
<maxDanger>None</maxDanger>
|
||||
<ticksBetweenWandersRange>120~240</ticksBetweenWandersRange>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Wander near colony -->
|
||||
<li Class="JobGiver_WanderColony">
|
||||
<maxDanger>None</maxDanger>
|
||||
<ticksBetweenWandersRange>120~240</ticksBetweenWandersRange>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Of neutral faction: rest and then exit the map -->
|
||||
<li Class="ThinkNode_ConditionalNonPlayerNonHostileFaction">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>RestingForMedicalReasons</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_PatientGoToBed"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_ExitMapBest">
|
||||
<defaultLocomotion>Walk</defaultLocomotion>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Wander -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Idle</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalHerdAnimal">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_WanderHerd">
|
||||
<maxDanger>Deadly</maxDanger>
|
||||
<ticksBetweenWandersRange>120~240</ticksBetweenWandersRange>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="JobGiver_WanderAnywhere">
|
||||
<maxDanger>Deadly</maxDanger>
|
||||
<ticksBetweenWandersRange>120~240</ticksBetweenWandersRange>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="JobGiver_IdleError"/>
|
||||
</subNodes>
|
||||
</thinkRoot>
|
||||
</ThinkTreeDef>
|
||||
</Defs>
|
||||
BIN
Content/Textures/ArachnaeSwarm/Building/ARA_InsectWall.png
Normal file
BIN
Content/Textures/ArachnaeSwarm/Building/ARA_InsectWall.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
75
Source/ArachnaeSwarm/AnimalWorkSystemPatcher.cs
Normal file
75
Source/ArachnaeSwarm/AnimalWorkSystemPatcher.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
[StaticConstructorOnStartup]
|
||||
public static class AnimalWorkSystemPatcher
|
||||
{
|
||||
static AnimalWorkSystemPatcher()
|
||||
{
|
||||
var harmony = new Harmony("com.yourname.animalworksystem");
|
||||
harmony.PatchAll();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Pawn_WorkSettings), "EnableAndInitialize")]
|
||||
public static class Patch_Pawn_WorkSettings_EnableAndInitialize
|
||||
{
|
||||
public static void Postfix(Pawn_WorkSettings __instance, Pawn ___pawn)
|
||||
{
|
||||
// 检查是否是我们想要启用工作系统的动物,并且它不是机械体
|
||||
// 因为原版的 EnableAndInitialize 已经处理了机械体的工作设置
|
||||
if (___pawn.Faction != null && ___pawn.Faction.IsPlayer &&
|
||||
!___pawn.RaceProps.IsMechanoid &&
|
||||
ShouldEnableWorkSystem(___pawn))
|
||||
{
|
||||
// 获取 CompProperties_WorkForNonMechs
|
||||
CompProperties_WorkForNonMechs compProps = null;
|
||||
if (___pawn.def.comps != null)
|
||||
{
|
||||
foreach (var comp in ___pawn.def.comps)
|
||||
{
|
||||
if (comp is CompProperties_WorkForNonMechs props)
|
||||
{
|
||||
compProps = props;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compProps != null && compProps.workTypes != null)
|
||||
{
|
||||
// 设置 CompProperties_WorkForNonMechs 中定义的工作类型优先级
|
||||
foreach (var workType in compProps.workTypes)
|
||||
{
|
||||
if (!__instance.WorkIsActive(workType) && !___pawn.WorkTypeIsDisabled(workType))
|
||||
{
|
||||
__instance.SetPriority(workType, 3); // 默认优先级
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ShouldEnableWorkSystem(Pawn pawn)
|
||||
{
|
||||
// 检查 ThingDef 中是否有 CompProperties_WorkForNonMechs 配置
|
||||
if (pawn.def.comps != null)
|
||||
{
|
||||
foreach (var compProperties in pawn.def.comps)
|
||||
{
|
||||
if (compProperties is CompProperties_WorkForNonMechs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,12 @@
|
||||
<Compile Include="CompProperties_AbilityBindDrone.cs" />
|
||||
<Compile Include="JobGiver_MaintainBuildings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CompWorkForNonMechs.cs" />
|
||||
<Compile Include="AnimalWorkSystemPatcher.cs" />
|
||||
<Compile Include="Patch_WorkGivers_Growing.cs" />
|
||||
<Compile Include="Patch_QualityUtility.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CompProperties_DelayedTerrainSpawn.cs" />
|
||||
<Compile Include="CompDelayedTerrainSpawn.cs" />
|
||||
|
||||
37
Source/ArachnaeSwarm/CompWorkForNonMechs.cs
Normal file
37
Source/ArachnaeSwarm/CompWorkForNonMechs.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompProperties_WorkForNonMechs : CompProperties
|
||||
{
|
||||
public List<WorkTypeDef> workTypes;
|
||||
|
||||
public CompProperties_WorkForNonMechs()
|
||||
{
|
||||
compClass = typeof(CompWorkForNonMechs);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompWorkForNonMechs : ThingComp
|
||||
{
|
||||
public CompProperties_WorkForNonMechs Props => (CompProperties_WorkForNonMechs)props;
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
|
||||
var pawn = parent as Pawn;
|
||||
if (pawn == null || pawn.Faction == null || !pawn.Faction.IsPlayer) return;
|
||||
|
||||
// 确保 workSettings 实例存在
|
||||
if (pawn.workSettings == null)
|
||||
{
|
||||
pawn.workSettings = new Pawn_WorkSettings(pawn);
|
||||
}
|
||||
|
||||
pawn.workSettings.EnableAndInitialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
62
Source/ArachnaeSwarm/Patch_QualityUtility.cs
Normal file
62
Source/ArachnaeSwarm/Patch_QualityUtility.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Reflection; // For MethodInfo
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
[StaticConstructorOnStartup]
|
||||
public static class QualityUtilityPatch
|
||||
{
|
||||
static QualityUtilityPatch()
|
||||
{
|
||||
var harmony = new Harmony("com.yourname.qualityutilitypatch");
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(QualityUtility), nameof(QualityUtility.GenerateQualityCreatedByPawn), new[] { typeof(Pawn), typeof(SkillDef), typeof(bool) }),
|
||||
prefix: new HarmonyMethod(typeof(QualityUtilityPatch), nameof(GenerateQualityCreatedByPawn_Prefix))
|
||||
);
|
||||
}
|
||||
|
||||
public static bool GenerateQualityCreatedByPawn_Prefix(Pawn pawn, SkillDef relevantSkill, bool consumeInspiration, ref QualityCategory __result)
|
||||
{
|
||||
// 检查当前 Pawn 是否是我们的自定义动物(通过检查其 ThingDef 是否拥有 CompProperties_WorkForNonMechs)
|
||||
if (pawn != null && pawn.def.comps != null && ShouldEnableWorkSystem(pawn))
|
||||
{
|
||||
// 如果是,强制使用 mechFixedSkillLevel
|
||||
int relevantSkillLevel = pawn.RaceProps.mechFixedSkillLevel;
|
||||
bool inspired = consumeInspiration && pawn.InspirationDef == InspirationDefOf.Inspired_Creativity;
|
||||
|
||||
// 调用 QualityUtility.GenerateQualityCreatedByPawn 的 int 重载
|
||||
__result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
|
||||
|
||||
// 消耗灵感(如果适用)
|
||||
if (inspired)
|
||||
{
|
||||
pawn.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Creativity);
|
||||
}
|
||||
|
||||
// 返回 false,跳过原版方法执行
|
||||
return false;
|
||||
}
|
||||
|
||||
// 返回 true,执行原版方法
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool ShouldEnableWorkSystem(Pawn pawn)
|
||||
{
|
||||
// 检查 ThingDef 中是否有 CompProperties_WorkForNonMechs 配置
|
||||
if (pawn.def.comps != null)
|
||||
{
|
||||
foreach (var compProperties in pawn.def.comps)
|
||||
{
|
||||
if (compProperties is CompProperties_WorkForNonMechs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
96
Source/ArachnaeSwarm/Patch_WorkGivers_Growing.cs
Normal file
96
Source/ArachnaeSwarm/Patch_WorkGivers_Growing.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
[StaticConstructorOnStartup]
|
||||
public static class Patch_WorkGivers_Growing
|
||||
{
|
||||
static Patch_WorkGivers_Growing()
|
||||
{
|
||||
var harmony = new Harmony("com.yourname.workgiversgrowingpatch");
|
||||
|
||||
// Patch WorkGiver_GrowerSow.JobOnCell
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(WorkGiver_GrowerSow), nameof(WorkGiver_GrowerSow.JobOnCell)),
|
||||
prefix: new HarmonyMethod(typeof(Patch_WorkGivers_Growing), nameof(JobOnCell_GrowerSow_Prefix))
|
||||
);
|
||||
|
||||
// Patch JobDriver_Deconstruct.TickActionInterval
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(JobDriver_Deconstruct), "TickActionInterval"),
|
||||
prefix: new HarmonyMethod(typeof(Patch_WorkGivers_Growing), nameof(TickActionInterval_Deconstruct_Prefix))
|
||||
);
|
||||
}
|
||||
|
||||
public static bool JobOnCell_GrowerSow_Prefix(Pawn pawn, IntVec3 c, ref Job __result, WorkGiver_GrowerSow __instance)
|
||||
{
|
||||
// 检查是否是我们的自定义动物,并且它不是真正的机械体 (因为真正的机械体原版会处理)
|
||||
if (ShouldEnableWorkSystem(pawn) && !pawn.RaceProps.IsMechanoid)
|
||||
{
|
||||
// 使用反射获取 WorkGiver_GrowerSow 实例的 wantedPlantDef 字段
|
||||
ThingDef wantedPlantDef = (ThingDef)AccessTools.Field(typeof(WorkGiver_Grower), "wantedPlantDef").GetValue(__instance);
|
||||
|
||||
if (wantedPlantDef == null)
|
||||
{
|
||||
__result = null;
|
||||
return false; // 跳过原版方法
|
||||
}
|
||||
|
||||
// 强制使用 mechFixedSkillLevel 作为相关技能等级
|
||||
int relevantSkillLevel = pawn.RaceProps.mechFixedSkillLevel;
|
||||
|
||||
// 然后进行原始的 sowMinSkill 检查
|
||||
if (wantedPlantDef.plant.sowMinSkill > relevantSkillLevel)
|
||||
{
|
||||
__result = null; // 技能不足,不生成 Job
|
||||
return false; // 跳过原版方法
|
||||
}
|
||||
|
||||
// 如果技能足够,让原版方法继续执行,处理其他复杂的检查
|
||||
// 注意:这里我们只处理了技能检查部分,其他逻辑仍然依赖原版方法。
|
||||
// 如果原版方法在其他地方再次访问 pawn.skills,仍然可能出错。
|
||||
// 但这是最直接的修复方法,避免了完全复制整个原始方法。
|
||||
}
|
||||
|
||||
return true; // 执行原版方法
|
||||
}
|
||||
|
||||
public static bool TickActionInterval_Deconstruct_Prefix(JobDriver_Deconstruct __instance, Pawn ___pawn, int delta)
|
||||
{
|
||||
// 检查是否是我们的自定义动物,并且它不是真正的机械体
|
||||
if (ShouldEnableWorkSystem(___pawn) && !___pawn.RaceProps.IsMechanoid)
|
||||
{
|
||||
// 模拟技能学习,避免访问 pawn.skills 导致 NullReferenceException
|
||||
// 这里我们不实际增加经验值,只是模拟原版方法的行为
|
||||
// 避免了对 pawn.skills 的访问
|
||||
if (__instance.Building.def.CostListAdjusted(__instance.Building.Stuff).Count > 0)
|
||||
{
|
||||
// 可以选择在这里添加一些日志,以便调试
|
||||
// Log.Message($"Animal {___pawn.LabelShort} is deconstructing, simulating skill gain.");
|
||||
}
|
||||
return false; // 跳过原版方法
|
||||
}
|
||||
return true; // 执行原版方法
|
||||
}
|
||||
|
||||
private static bool ShouldEnableWorkSystem(Pawn pawn)
|
||||
{
|
||||
// 检查 ThingDef 中是否有 CompProperties_WorkForNonMechs 配置
|
||||
if (pawn.def.comps != null)
|
||||
{
|
||||
foreach (var compProperties in pawn.def.comps)
|
||||
{
|
||||
if (compProperties is CompProperties_WorkForNonMechs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
70a1ccfa141c7c82eb05a9fac71c32df86f6b34332995c92bb7aac69bc46394b
|
||||
@@ -0,0 +1,2 @@
|
||||
C:\Steam\steamapps\common\RimWorld\Mods\ArachnaeSwarm\Source\ArachnaeSwarm\obj\Debug\ArachnaeSwarm.csproj.AssemblyReference.cache
|
||||
C:\Steam\steamapps\common\RimWorld\Mods\ArachnaeSwarm\Source\ArachnaeSwarm\obj\Debug\ArachnaeSwarm.csproj.CoreCompileInputs.cache
|
||||
514
Source/Documents/AnimalWorkModeSolution_Final_Implementation.md
Normal file
514
Source/Documents/AnimalWorkModeSolution_Final_Implementation.md
Normal file
@@ -0,0 +1,514 @@
|
||||
# 动物工作模式解决方案文档(最终实现版)
|
||||
|
||||
## 1. 项目概述
|
||||
|
||||
本项目旨在实现一个功能,使动物(特别是昆虫)能够像机械体一样持续工作,而不需要通过机械师控制 WorkMode。通过为动物启用工作系统并创建自定义行为树,动物将始终处于工作状态,持续执行允许的工作类型。
|
||||
|
||||
## 2. 原版代码分析
|
||||
|
||||
### 2.1 昆虫 ThinkTreeDef 结构
|
||||
|
||||
原版昆虫的 ThinkTree (`Insect.xml`) 包含以下主要逻辑:
|
||||
|
||||
1. **紧急情况处理**:倒地、燃烧、精神状态等
|
||||
2. **基本需求满足**:睡觉、吃饭等
|
||||
3. **驯服动物行为**:跟随主人、救援等
|
||||
4. **闲置行为**:漫游、待命等
|
||||
|
||||
### 2.2 机械体 ThinkTreeDef 结构
|
||||
|
||||
原版机械体的 ThinkTree (`Mechanoid.xml`) 包含 WorkMode 系统,这是动物不具备的。
|
||||
|
||||
## 3. 为什么机械体有 workSettings 而动物没有
|
||||
|
||||
### 3.1 核心原因分析
|
||||
|
||||
机械体和动物虽然都是 Pawn,但它们的 workSettings 初始化逻辑不同:
|
||||
|
||||
1. **`Pawn_WorkSettings` 的存在性**:
|
||||
- `Pawn` 类内部持有一个 `Pawn_WorkSettings` 类型的引用 `priorities`,默认为 `null`
|
||||
- `public bool EverWork => priorities != null;` 属性表明只有当 `priorities` 不为 `null` 时,Pawn 才有工作能力
|
||||
|
||||
2. **初始化条件**:
|
||||
- `EnableAndInitializeIfNotAlreadyInitialized()` 方法检查 `priorities` 是否为 `null`,如果为 `null` 则调用 `EnableAndInitialize()`
|
||||
- `EnableAndInitialize()` 方法是真正执行初始化的地方,创建 `priorities` 对象并根据条件设置初始优先级
|
||||
|
||||
3. **Mechanoid 有 WorkSettings 的证据**:
|
||||
- `EnableAndInitialize()` 方法明确包含对机械体的特殊处理:
|
||||
```csharp
|
||||
if (ModsConfig.BiotechActive && pawn.RaceProps.IsMechanoid && !pawn.RaceProps.mechWorkTypePriorities.NullOrEmpty())
|
||||
{
|
||||
for (int i = 0; i < pawn.RaceProps.mechWorkTypePriorities.Count; i++)
|
||||
{
|
||||
MechWorkTypePriority mechWorkTypePriority = pawn.RaceProps.mechWorkTypePriorities[i];
|
||||
SetPriority(mechWorkTypePriority.def, mechWorkTypePriority.priority);
|
||||
}
|
||||
}
|
||||
```
|
||||
- 这表明机械体的设计意图就是拥有并使用 `Pawn_WorkSettings`
|
||||
|
||||
4. **Animal 没有 WorkSettings 的证据**:
|
||||
- **直接初始化逻辑**:`EnableAndInitialize()` 方法在为 Pawn 分配默认"活跃"工作类型时,会过滤掉 `pawn.WorkTypeIsDisabled(w)` 的工作类型。对于大多数动物来说,它们的 `RaceProps` 会禁用几乎所有需要手动分配的 `WorkTypeDef`
|
||||
- **工作类型的定义**:绝大多数工作类型都包含限制,使得动物 Pawn 默认无法执行这些工作
|
||||
- **特定工作提供者的处理**:针对动物的操作是通过独立的 `WorkGiver` 系统直接处理的,不依赖于通用的 `workSettings` 优先级系统
|
||||
|
||||
### 3.2 结论
|
||||
|
||||
机械体被设计为拥有 `Pawn_WorkSettings`,因为它们的工作优先级可以通过其 `RaceProps.mechWorkTypePriorities` 进行预设,并且游戏逻辑会在需要时初始化它。
|
||||
|
||||
动物通常没有有效的 `Pawn_WorkSettings`,因为:
|
||||
1. 它们被设计为不能执行绝大多数需要手动分配的工作
|
||||
2. 它们与玩家互动的特定工作是通过独立的 `WorkGiver` 系统直接处理的
|
||||
3. 因此,除非有特定的游戏逻辑或 Mod 显式地为动物调用 `EnableAndInitialize()`,否则它们的 `priorities` 对象很可能保持 `null` 状态
|
||||
|
||||
## 4. 为什么 `RaceProps.mechWorkTypePriorities` 只对机械体有效
|
||||
|
||||
### 4.1 核心解释
|
||||
|
||||
`mechWorkTypePriorities` 是 `RaceProperties` 类中的一个字段,专门用于定义机械体(Mechanoid)在生成时其工作类型(Work Types)的默认优先级。它的设计和使用都与机械体的独特机制紧密相关,而这些机制在动物或其他生物上并不存在或不以相同方式运作。
|
||||
|
||||
### 4.2 详细证据和解释
|
||||
|
||||
1. **字段定义与命名**:
|
||||
- `mechWorkTypePriorities` 被明确定义为:
|
||||
```csharp
|
||||
public List<MechWorkTypePriority> mechWorkTypePriorities;
|
||||
```
|
||||
- 其名称 `mechWorkTypePriorities` 包含了 "Mech" 前缀,明确指示其用途是针对机械体的。
|
||||
|
||||
2. **`MechWorkTypePriority` 类型**:
|
||||
- 该字段存储的是 `MechWorkTypePriority` 对象的列表。虽然代码片段中没有直接给出 `MechWorkTypePriority` 的定义,但其名称和用途(存储工作类型及其优先级)强烈暗示它是专门为机械体设计的数据结构。
|
||||
|
||||
3. **使用场景 - 初始化工作设置**:
|
||||
- 关键证据出现在 `Pawn_WorkSettings.EnableAndInitialize()` 方法中:
|
||||
```csharp
|
||||
// ... (其他初始化代码) ...
|
||||
if (ModsConfig.BiotechActive && pawn.RaceProps.IsMechanoid && !pawn.RaceProps.mechWorkTypePriorities.NullOrEmpty())
|
||||
{
|
||||
for (int i = 0; i < pawn.RaceProps.mechWorkTypePriorities.Count; i++)
|
||||
{
|
||||
MechWorkTypePriority mechWorkTypePriority = pawn.RaceProps.mechWorkTypePriorities[i];
|
||||
SetPriority(mechWorkTypePriority.def, mechWorkTypePriority.priority);
|
||||
}
|
||||
}
|
||||
// ... (其他初始化代码,如处理禁用的工作类型) ...
|
||||
```
|
||||
- 这段代码明确地检查了三个条件:
|
||||
* `ModsConfig.BiotechActive`:生物技术(Biotech)模组是否激活。这表明该功能是与 Biotech 模组引入的机械体相关的。
|
||||
* `pawn.RaceProps.IsMechanoid`:当前 Pawn(单位)的种族属性是否为机械体。
|
||||
* `!pawn.RaceProps.mechWorkTypePriorities.NullOrEmpty()`:该机械体的 `mechWorkTypePriorities` 列表是否存在且非空。
|
||||
- **只有当这三个条件都满足时,才会遍历 `mechWorkTypePriorities` 列表,并根据其中定义的 `WorkTypeDef` 和优先级来设置该机械体 Pawn 的工作优先级。**
|
||||
- 对于动物或其他非机械体生物,`pawn.RaceProps.IsMechanoid` 条件为假,因此即使在它们的 `ThingDef` 中定义了 `mechWorkTypePriorities`,这段代码也不会执行,这些优先级设置就会被忽略。
|
||||
|
||||
4. **机制差异 - 动物 vs 机械体**:
|
||||
- **动物**:动物的工作能力(如驯服、训练、特定任务)通常是通过 `trainability`(可训练性)、`trainableTags`(可训练标签)等属性来定义的。它们的工作行为(如觅食、繁殖、战斗)主要由其 `intelligence`(智力)、`thinkTreeMain`(主思考树)和 `dutyBoss`(职责)等属性驱动。它们的初始工作优先级(如果有的话)通常是固定的或基于简单规则随机分配,而不是通过一个专门的优先级列表来精确控制。
|
||||
- **机械体**:机械体是 Biotech 模组引入的复杂单位,它们拥有类似殖民者的工作系统。它们可以被指派执行各种殖民者能做的工作(如建造、种植、烹饪等),其能力范围和初始工作优先级需要更精细的控制。`mechWorkTypePriorities` 就是为了满足这种需求而设计的,允许设计者为每种机械体明确指定哪些工作类型应该默认开启以及它们的优先级。
|
||||
|
||||
5. **辅助证据 - MechWorkUtility**:
|
||||
- 在 `MechWorkUtility` 类中,多个方法(如 `SpecialDisplayStats`, `AnyWorkMechCouldDo`)在处理与机械体工作相关逻辑时,都会首先检查 `parentDef.race.IsMechanoid`。这进一步证明了与机械体工作类型相关的逻辑是严格限定于机械体的。
|
||||
|
||||
### 4.3 结论
|
||||
|
||||
`RaceProperties.mechWorkTypePriorities` 虽然是 `RaceProperties` 类的一个通用属性,但它被设计并实现为**仅对机械体(Mechanoid)生效**。这是因为:
|
||||
|
||||
1. 它的命名和数据类型 (`MechWorkTypePriority`) 明确指向机械体。
|
||||
2. 核心的使用代码 (`Pawn_WorkSettings.EnableAndInitialize`) 通过 `pawn.RaceProps.IsMechanoid` 条件严格限制了其应用范围。
|
||||
3. 机械体和动物在工作系统上的根本差异决定了需要不同的机制来管理其初始工作能力,`mechWorkTypePriorities` 是为满足机械体特有需求而生的。
|
||||
|
||||
因此,即使在动物的 `ThingDef` 文件中添加了 `mechWorkTypePriorities` 部分,游戏代码也不会读取或应用这些设置,因为动物不是机械体,相关的初始化逻辑不会被执行。
|
||||
|
||||
## 5. 通过 Harmony 补丁拦截 `pawn.RaceProps.IsMechanoid` 的分析
|
||||
|
||||
### 5.1 用户提供的实现思路
|
||||
|
||||
用户提供了一种更精确和安全的实现思路:通过 Harmony 补丁拦截 `Pawn_WorkSettings.EnableAndInitialize` 方法,在特定条件下局部伪装成机械体来为动物启用工作系统。
|
||||
|
||||
### 5.2 实现方法
|
||||
|
||||
1. **引入 Harmony**:确保你的 Mod 项目中引用了 Harmony 库。
|
||||
2. **定义补丁类**:创建一个静态类来存放你的 Harmony 补丁。
|
||||
3. **编写前缀补丁**:
|
||||
```csharp
|
||||
[HarmonyPatch(typeof(Pawn_WorkSettings), nameof(Pawn_WorkSettings.EnableAndInitialize))]
|
||||
public static class Patch_Pawn_WorkSettings_EnableAndInitialize
|
||||
{
|
||||
public static bool Prefix(Pawn_WorkSettings __instance, Pawn ___pawn)
|
||||
{
|
||||
// 检查是否是我们想要启用工作系统的动物
|
||||
if (___pawn.Faction != null && ___pawn.Faction.IsPlayer &&
|
||||
!___pawn.RaceProps.IsMechanoid && // 真实身份不是机械体
|
||||
ShouldEnableWorkSystem(___pawn)) // 但我们需要为它启用工作系统
|
||||
{
|
||||
// 局部伪装成机械体来执行初始化逻辑
|
||||
|
||||
// 执行机械体工作优先级初始化逻辑
|
||||
if (ModsConfig.BiotechActive && !___pawn.RaceProps.mechWorkTypePriorities.NullOrEmpty())
|
||||
{
|
||||
for (int i = 0; i < ___pawn.RaceProps.mechWorkTypePriorities.Count; i++)
|
||||
{
|
||||
var priority = ___pawn.RaceProps.mechWorkTypePriorities[i];
|
||||
__instance.SetPriority(priority.def, priority.priority);
|
||||
}
|
||||
}
|
||||
|
||||
// 同时也可以初始化 mechEnabledWorkTypes 中的工作类型
|
||||
if (!___pawn.RaceProps.mechEnabledWorkTypes.NullOrEmpty())
|
||||
{
|
||||
foreach (var workType in ___pawn.RaceProps.mechEnabledWorkTypes)
|
||||
{
|
||||
if (!__instance.WorkIsActive(workType) && !___pawn.WorkTypeIsDisabled(workType))
|
||||
{
|
||||
__instance.SetPriority(workType, 3); // 默认优先级
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 阻止原方法继续执行
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // 其他情况正常执行原逻辑
|
||||
}
|
||||
|
||||
private static bool ShouldEnableWorkSystem(Pawn pawn)
|
||||
{
|
||||
// 检查是否有特定的 Comp
|
||||
if (pawn.TryGetComp<CompWorkForNonMechs>() != null)
|
||||
return true;
|
||||
|
||||
// 检查是否有 mechWorkTypePriorities 或 mechEnabledWorkTypes 配置
|
||||
if (!pawn.RaceProps.mechWorkTypePriorities.NullOrEmpty() ||
|
||||
!pawn.RaceProps.mechEnabledWorkTypes.NullOrEmpty())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
```
|
||||
4. **应用补丁**:
|
||||
```csharp
|
||||
[StaticConstructorOnStartup]
|
||||
public static class AnimalWorkSystemPatcher
|
||||
{
|
||||
static AnimalWorkSystemPatcher()
|
||||
{
|
||||
var harmony = new Harmony("com.yourname.animalworksystem");
|
||||
harmony.PatchAll();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 5.3 潜在问题和风险
|
||||
|
||||
1. **副作用**:
|
||||
- 这种方法比直接补丁 `IsMechanoid` 属性更加精确,因为它只在 `Pawn_WorkSettings.EnableAndInitialize` 方法中进行伪装,不影响其他系统。
|
||||
- 但仍需注意确保伪装逻辑只在特定条件下触发,避免意外影响其他 Pawn。
|
||||
|
||||
2. **补丁冲突**:
|
||||
- 其他 Mod 也可能使用 Harmony 来修改 `Pawn_WorkSettings` 或相关逻辑。
|
||||
- 需要确保补丁逻辑具有良好的兼容性。
|
||||
|
||||
3. **性能影响**:
|
||||
- Harmony 补丁会增加方法调用的开销,但在这个场景下影响很小。
|
||||
|
||||
4. **维护困难**:
|
||||
- 如果游戏更新修改了相关逻辑,你的补丁可能失效或产生新的问题,需要随之更新。
|
||||
|
||||
### 5.4 结论和建议
|
||||
|
||||
用户提供的实现思路是一种更加精确和安全的方法,通过局部伪装成机械体来为动物启用工作系统。这种方法的优点包括:
|
||||
|
||||
1. **精确性**:只在特定条件下(动物是玩家阵营且需要启用工作系统)才进行伪装。
|
||||
2. **安全性**:只在 `Pawn_WorkSettings.EnableAndInitialize` 方法中进行伪装,不影响其他系统。
|
||||
3. **兼容性**:通过检查特定的 Comp 或配置来决定是否启用工作系统,具有良好的可扩展性。
|
||||
|
||||
## 6. 完整实现方案
|
||||
|
||||
### 6.1 核心思路
|
||||
|
||||
1. 为动物添加 `CompWorkForNonMechs` 以启用工作系统
|
||||
2. 创建 `ThinkNode_AnimalWorker` 替代默认行为,强制工作
|
||||
3. 使用 Harmony 补丁局部伪装成机械体来为动物启用工作系统
|
||||
4. 使用自定义 ThinkTree 替代默认动物行为树
|
||||
5. 定义允许的工作类型,并确保其与 WorkGiver 兼容
|
||||
|
||||
### 6.2 设计要点
|
||||
|
||||
1. **为动物启用 WorkSettings 系统**:通过 Harmony 补丁局部伪装成机械体来为动物启用工作系统
|
||||
2. **使用自定义 ThinkNode 强制工作行为**:创建 ThinkNode,跳过所有动物默认行为,直接进入工作逻辑
|
||||
3. **修改动物定义**:添加 ThinkTree 和 Comp
|
||||
4. **为动物添加工作类型支持**:定义允许的工作类型
|
||||
|
||||
## 7. 实现细节
|
||||
|
||||
### 7.1 CompWorkForNonMechs.cs
|
||||
|
||||
```csharp
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace YourModName
|
||||
{
|
||||
public class CompWorkForNonMechs : ThingComp
|
||||
{
|
||||
public class CompProperties_WorkForNonMechs : CompProperties
|
||||
{
|
||||
public List<WorkTypeDef> workTypes;
|
||||
|
||||
public CompProperties_WorkForNonMechs()
|
||||
{
|
||||
compClass = typeof(CompWorkForNonMechs);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
|
||||
var pawn = parent as Pawn;
|
||||
if (pawn == null || pawn.Faction == null || !pawn.Faction.IsPlayer) return;
|
||||
|
||||
// 启用工作设置
|
||||
if (pawn.workSettings == null)
|
||||
{
|
||||
pawn.workSettings = new Pawn_WorkSettings(pawn);
|
||||
}
|
||||
|
||||
pawn.workSettings.EnableAndInitialize();
|
||||
|
||||
// 启用指定的工作类型
|
||||
var props = (CompProperties_WorkForNonMechs)props;
|
||||
if (props.workTypes != null)
|
||||
{
|
||||
foreach (var workType in props.workTypes)
|
||||
{
|
||||
if (!pawn.WorkTypeIsDisabled(workType))
|
||||
{
|
||||
pawn.workSettings.SetPriority(workType, 3); // 默认优先级
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 7.2 ThinkNode_AnimalWorker.cs
|
||||
|
||||
```csharp
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace YourModName
|
||||
{
|
||||
public class ThinkNode_AnimalWorker : ThinkNode_Priority
|
||||
{
|
||||
public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
|
||||
{
|
||||
if (pawn.workSettings == null || !pawn.Faction.IsPlayer)
|
||||
{
|
||||
return ThinkResult.NoJob;
|
||||
}
|
||||
|
||||
// 优先执行紧急工作
|
||||
var job = WorkGiverUtility.GetPriorityWork(pawn, emergency: true);
|
||||
if (job != null) return new ThinkResult(job, this);
|
||||
|
||||
// 然后执行普通工作
|
||||
job = WorkGiverUtility.GetPriorityWork(pawn, emergency: false);
|
||||
if (job != null) return new ThinkResult(job, this);
|
||||
|
||||
return ThinkResult.NoJob;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 7.3 AnimalWorkSystemPatcher.cs
|
||||
|
||||
```csharp
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace YourModName
|
||||
{
|
||||
[StaticConstructorOnStartup]
|
||||
public static class AnimalWorkSystemPatcher
|
||||
{
|
||||
static AnimalWorkSystemPatcher()
|
||||
{
|
||||
var harmony = new Harmony("com.yourname.animalworksystem");
|
||||
harmony.PatchAll();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Pawn_WorkSettings), nameof(Pawn_WorkSettings.EnableAndInitialize))]
|
||||
public static class Patch_Pawn_WorkSettings_EnableAndInitialize
|
||||
{
|
||||
// 缓存原始的 IsMechanoid 属性 Getter
|
||||
private static PropertyInfo isMechanoidProperty =
|
||||
typeof(RaceProperties).GetProperty("IsMechanoid", BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
public static bool Prefix(Pawn_WorkSettings __instance, Pawn ___pawn)
|
||||
{
|
||||
// 检查是否是我们想要启用工作系统的动物
|
||||
if (___pawn.Faction != null && ___pawn.Faction.IsPlayer &&
|
||||
!___pawn.RaceProps.IsMechanoid && // 真实身份不是机械体
|
||||
ShouldEnableWorkSystem(___pawn)) // 但我们需要为它启用工作系统
|
||||
{
|
||||
// 局部伪装成机械体来执行初始化逻辑
|
||||
|
||||
// 执行机械体工作优先级初始化逻辑(来自 Pawn_WorkSettings.EnableAndInitialize)
|
||||
if (ModsConfig.BiotechActive && !___pawn.RaceProps.mechWorkTypePriorities.NullOrEmpty())
|
||||
{
|
||||
for (int i = 0; i < ___pawn.RaceProps.mechWorkTypePriorities.Count; i++)
|
||||
{
|
||||
var priority = ___pawn.RaceProps.mechWorkTypePriorities[i];
|
||||
__instance.SetPriority(priority.def, priority.priority);
|
||||
}
|
||||
}
|
||||
|
||||
// 同时也可以初始化 mechEnabledWorkTypes 中的工作类型(如果你需要)
|
||||
if (!___pawn.RaceProps.mechEnabledWorkTypes.NullOrEmpty())
|
||||
{
|
||||
foreach (var workType in ___pawn.RaceProps.mechEnabledWorkTypes)
|
||||
{
|
||||
if (!__instance.WorkIsActive(workType) && !___pawn.WorkTypeIsDisabled(workType))
|
||||
{
|
||||
__instance.SetPriority(workType, 3); // 默认优先级
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 阻止原方法继续执行(因为我们已经手动处理了初始化)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // 其他情况正常执行原逻辑
|
||||
}
|
||||
|
||||
private static bool ShouldEnableWorkSystem(Pawn pawn)
|
||||
{
|
||||
// 你可以通过多种方式判断:
|
||||
// 1. 检查是否有特定的 Comp
|
||||
if (pawn.TryGetComp<CompWorkForNonMechs>() != null)
|
||||
return true;
|
||||
|
||||
// 2. 检查是否有 mechWorkTypePriorities 或 mechEnabledWorkTypes 配置
|
||||
if (!pawn.RaceProps.mechWorkTypePriorities.NullOrEmpty() ||
|
||||
!pawn.RaceProps.mechEnabledWorkTypes.NullOrEmpty())
|
||||
return true;
|
||||
|
||||
// 3. 检查特定的标签或 defName
|
||||
// return pawn.def.defName.Contains("Worker");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 7.4 修改动物定义
|
||||
|
||||
```xml
|
||||
<ThingDef ParentName="BaseInsect">
|
||||
<defName>Megascarab_Worker</defName>
|
||||
<label>worker megascarab</label>
|
||||
<description>A genetically modified megascarab, capable of performing simple mechanical tasks.</description>
|
||||
<statBases>
|
||||
<MoveSpeed>3.0</MoveSpeed>
|
||||
<MarketValue>300</MarketValue>
|
||||
</statBases>
|
||||
<race>
|
||||
<thinkTreeMain>InsectWorker</thinkTreeMain>
|
||||
<thinkTreeConstant>AnimalConstant</thinkTreeConstant>
|
||||
<mechWorkTypePriorities>
|
||||
<li>
|
||||
<def>Hauling</def>
|
||||
<priority>3</priority>
|
||||
</li>
|
||||
<li>
|
||||
<def>Cleaning</def>
|
||||
<priority>2</priority>
|
||||
</li>
|
||||
</mechWorkTypePriorities>
|
||||
</race>
|
||||
<comps>
|
||||
<li Class="YourModName.CompWorkForNonMechs+CompProperties_WorkForNonMechs">
|
||||
<workTypes>
|
||||
<li>Hauling</li>
|
||||
<li>Cleaning</li>
|
||||
<li>BasicWorker</li>
|
||||
</workTypes>
|
||||
</li>
|
||||
</comps>
|
||||
</ThingDef>
|
||||
```
|
||||
|
||||
### 7.5 自定义 ThinkTreeDef
|
||||
|
||||
```xml
|
||||
<ThinkTreeDef>
|
||||
<defName>InsectWorker</defName>
|
||||
<thinkRoot Class="ThinkNode_Priority">
|
||||
<subNodes>
|
||||
<!-- 紧急情况处理 -->
|
||||
<li Class="ThinkNode_Subtree"><treeDef>Downed</treeDef></li>
|
||||
<li Class="ThinkNode_Subtree"><treeDef>BurningResponse</treeDef></li>
|
||||
<li Class="ThinkNode_Subtree"><treeDef>MentalStateCritical</treeDef></li>
|
||||
|
||||
<!-- 强制工作模式 -->
|
||||
<li Class="YourModName.ThinkNode_AnimalWorker" />
|
||||
|
||||
<!-- 闲置行为 -->
|
||||
<li Class="JobGiver_IdleError"/>
|
||||
</subNodes>
|
||||
</thinkRoot>
|
||||
</ThinkTreeDef>
|
||||
```
|
||||
|
||||
## 8. 原始方案的反驳分析
|
||||
|
||||
### 8.1 项目概述:不成立
|
||||
|
||||
**反驳证据:**
|
||||
- RimWorld 原版设计中,动物的行为树是完全独立于机械体的,没有 WorkMode 系统。
|
||||
- 动物不能直接复用机械体的工作逻辑。
|
||||
|
||||
### 8.2 ThinkNode_AnimalAlwaysWork 类:不成立
|
||||
|
||||
**反驳证据:**
|
||||
- `ThinkNode_Priority` 是一个标准的 ThinkNode,它会按顺序尝试子节点,直到某一个返回 `ThinkResult`。
|
||||
- 该类不会实现"始终工作"的功能,因为它没有改变行为树的执行逻辑。
|
||||
|
||||
### 8.3 InsectWorker ThinkTreeDef:不成立
|
||||
|
||||
**反驳证据:**
|
||||
- RimWorld 中,动物的 ThinkTree 并不会调用 `JobGiver_Work`,因为该类是为机械体设计的。
|
||||
- 即使强制插入 `JobGiver_Work`,它也会因为动物的 `WorkSettings` 未初始化而失败。
|
||||
|
||||
### 8.4 Harmony 补丁拦截 IsMechanoid:不成立
|
||||
|
||||
**反驳证据:**
|
||||
- `RaceProperties.IsMechanoid` 是一个只读属性,由 `<race><isMechanoid>true</isMechanoid></race>` 控制。
|
||||
- Patch 该属性会导致所有依赖该属性的逻辑被干扰,风险极高。
|
||||
|
||||
## 9. 使用说明
|
||||
|
||||
1. **编译代码**:将所有 C# 文件编译到您的 Mod 中
|
||||
2. **添加 XML 文件**:将新的 ThinkTreeDef 和动物定义添加到您的 Mod 中
|
||||
3. **配置工作类型**:在动物定义中配置 `mechWorkTypePriorities` 和 `CompWorkForNonMechs` 组件
|
||||
4. **测试**:在游戏中生成修改后的动物,观察其工作行为
|
||||
|
||||
## 10. 注意事项
|
||||
|
||||
1. **兼容性**:此方案绕过了 WorkMode 系统,动物将始终处于工作状态
|
||||
2. **性能**:频繁的工作查找可能会有轻微性能影响
|
||||
3. **调试**:如果遇到问题,请检查日志文件中的错误信息
|
||||
4. **避免 patch IsMechanoid**:不干扰原版逻辑
|
||||
5. **副作用风险**:直接 patch `IsMechanoid` 会导致严重的副作用,强烈不推荐使用
|
||||
6. **精确补丁**:用户提供的实现通过局部伪装成机械体来为动物启用工作系统,是一种更加精确和安全的方法
|
||||
BIN
非公开资源/Content/Textures/Building/ARA_InsectWall.sai2
Normal file
BIN
非公开资源/Content/Textures/Building/ARA_InsectWall.sai2
Normal file
Binary file not shown.
Reference in New Issue
Block a user