晕晕
This commit is contained in:
Binary file not shown.
@@ -21,6 +21,19 @@
|
||||
<li>ARA_PlantCutting</li>
|
||||
</trainables>
|
||||
</li>
|
||||
<li Class="ArachnaeSwarm.CompProperties_AnimalWorkSettings">
|
||||
<workTypeMap>
|
||||
<li>
|
||||
<trainable>ARA_Sowing</trainable>
|
||||
<workType>Growing</workType>
|
||||
</li>
|
||||
<li>
|
||||
<trainable>ARA_PlantCutting</trainable>
|
||||
<workType>PlantCutting</workType>
|
||||
</li>
|
||||
</workTypeMap>
|
||||
</li>
|
||||
<li Class="ArachnaeSwarm.CompProperties_NoTrainingDecay" />
|
||||
</comps>
|
||||
<tools>
|
||||
<li>
|
||||
|
||||
@@ -508,7 +508,7 @@
|
||||
<cooldownTicks>9999</cooldownTicks>
|
||||
<productionQueue>
|
||||
<li>
|
||||
<pawnKind>Spelopede</pawnKind>
|
||||
<pawnKind>ArachnaeBase_Race_Scavenger</pawnKind>
|
||||
<count>3</count>
|
||||
<cooldownTicks>6000</cooldownTicks>
|
||||
</li>
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
<defName>ARA_Insect_WithPlanting</defName>
|
||||
<thinkRoot Class="ThinkNode_Priority">
|
||||
<subNodes>
|
||||
<!-- Start of Copied Insect ThinkTree -->
|
||||
<!-- 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>
|
||||
@@ -101,34 +102,6 @@
|
||||
<insertTag>Insect_PreMain</insertTag>
|
||||
</li>
|
||||
|
||||
<!-- OUR CUSTOM LOGIC INJECTION: PLANTING -->
|
||||
<li Class="ArachnaeSwarm.ThinkNode_ConditionalAnimalShouldSow">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>TrainedAnimalBehavior</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="RimWorld.JobGiver_Work">
|
||||
<workType>Growing</workType>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- OUR CUSTOM LOGIC INJECTION: PLANT CUTTING -->
|
||||
<li Class="ArachnaeSwarm.ThinkNode_ConditionalAnimalShouldPlantCut">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>TrainedAnimalBehavior</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="RimWorld.JobGiver_Work">
|
||||
<workType>PlantCutting</workType>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="ThinkNode_ConditionalHasFaction">
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
@@ -230,7 +203,7 @@
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>RestingForMedicalReasons</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_PatientGoToBed"/> <!-- This was the problematic line -->
|
||||
<li Class="JobGiver_PatientGoToBed"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
@@ -258,8 +231,10 @@
|
||||
<treeDef>SatisfyBasicNeeds</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- Tame insect: do useful things for the colony-->
|
||||
<li Class="ThinkNode_ConditionalHasFaction">
|
||||
<subNodes>
|
||||
|
||||
<!-- Try to mate -->
|
||||
<li Class="ThinkNode_ChancePerHour_Mate">
|
||||
<subNodes>
|
||||
@@ -360,6 +335,31 @@
|
||||
<insertTag>Insect_PreWander</insertTag>
|
||||
</li>
|
||||
|
||||
<!-- OUR CUSTOM LOGIC INJECTION -->
|
||||
<li Class="ArachnaeSwarm.ThinkNode_ConditionalAnimalShouldSow">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>TrainedAnimalBehavior</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="RimWorld.JobGiver_Work" />
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
<!-- END OF CUSTOM LOGIC -->
|
||||
|
||||
<!-- OUR CUSTOM LOGIC INJECTION FOR PLANT CUTTING -->
|
||||
<li Class="ArachnaeSwarm.ThinkNode_ConditionalAnimalShouldPlantCut">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>TrainedAnimalBehavior</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="RimWorld.JobGiver_Work" />
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Tame insect: wander near colony if possible -->
|
||||
<li Class="ThinkNode_ConditionalOfPlayerFaction">
|
||||
<subNodes>
|
||||
@@ -388,7 +388,7 @@
|
||||
<li Class="ThinkNode_ConditionalRandom">
|
||||
<chance>0.1</chance>
|
||||
<subNodes>
|
||||
<li class="JobGiver_WanderInPen">
|
||||
<li Class="JobGiver_WanderInPen">
|
||||
<maxDanger>None</maxDanger>
|
||||
<ticksBetweenWandersRange>120~240</ticksBetweenWandersRange>
|
||||
<expiryInterval>500</expiryInterval>
|
||||
@@ -568,4 +568,394 @@
|
||||
|
||||
<!-- Lord directives (high priority) -->
|
||||
<li Class="ThinkNode_JoinVoluntarilyJoinableLord">
|
||||
<dutyHook>HighPriority</dutyHook>
|
||||
<dutyHook>HighPriority</dutyHook>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>LordDuty</treeDef>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Insertion hook for modders -->
|
||||
<li Class="ThinkNode_SubtreesByTag">
|
||||
<insertTag>Humanlike_PostDuty</insertTag>
|
||||
</li>
|
||||
|
||||
<!-- JobGiver_MaintainBuildings start -->
|
||||
<li Class="ThinkNode_ChancePerHour_Constant">
|
||||
<mtbHours>2.5</mtbHours>
|
||||
<subNodes>
|
||||
<li Class="ArachnaeSwarm.JobGiver_MaintainBuildings">
|
||||
<maintainableThingDefs>
|
||||
<li>ARA_InteractiveEggSac</li> <!-- 默认维护Hive -->
|
||||
</maintainableThingDefs>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
<li Class="ArachnaeSwarm.JobGiver_MaintainBuildings">
|
||||
<maintainableThingDefs>
|
||||
<li>ARA_InteractiveEggSac</li> <!-- 默认维护Hive -->
|
||||
</maintainableThingDefs>
|
||||
<onlyIfDamagingState>true</onlyIfDamagingState>
|
||||
</li>
|
||||
<!-- JobGiver_MaintainBuildings end -->
|
||||
|
||||
<!-- Prisoner -->
|
||||
<li Class="ThinkNode_ConditionalPrisoner">
|
||||
<leaveJoinableLordIfIssuesJob>true</leaveJoinableLordIfIssuesJob>
|
||||
<subNodes>
|
||||
<!-- If it's the player home map... -->
|
||||
<li Class="ThinkNode_ConditionalInNonPlayerHomeMap">
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
<!-- Wait instead of escaping if should -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Idle</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_PrisonerWaitInsteadOfEscaping">
|
||||
<maxDanger>Deadly</maxDanger>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Escape -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Escaping</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_PrisonerEscape" />
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Exit map if released -->
|
||||
<li Class="ThinkNode_ConditionalReleased">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_ExitMapBest">
|
||||
<defaultLocomotion>Walk</defaultLocomotion>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>RestingForMedicalReasons</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_PatientGoToBed" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>ChangingApparel</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_PrisonerGetDressed" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>SatisfyingNeeds</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_PrioritySorter">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_Autofeed" MayRequire="Ludeon.RimWorld.Biotech" />
|
||||
<li Class="JobGiver_GetFood"/>
|
||||
<li Class="JobGiver_GetRest"/>
|
||||
<li Class="JobGiver_SatisfyChemicalNeed"/>
|
||||
<li Class="JobGiver_SatifyChemicalDependency" MayRequire="Ludeon.RimWorld.Biotech" />
|
||||
<li Class="JobGiver_GetHemogen" MayRequire="Ludeon.RimWorld.Biotech" />
|
||||
<li Class="JobGiver_GetDeathrest" MayRequire="Ludeon.RimWorld.Biotech" />
|
||||
<li Class="ThinkNode_Priority_GetJoy">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_GetJoy"/>
|
||||
<li Class="JobGiver_GetJoyInBed"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
<li Class="JobGiver_Meditate"/>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- If in non-PlayerHomeMap -->
|
||||
<li Class="ThinkNode_ConditionalInNonPlayerHomeMap">
|
||||
<subNodes>
|
||||
<!-- No colonist spawned in the map -->
|
||||
<li Class="ThinkNode_ConditionalAnyUndownedColonistSpawnedNearby">
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Escaping</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_PrisonerEscape" />
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
<!-- Wander -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Idle</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_WanderColony">
|
||||
<maxDanger>Deadly</maxDanger>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Idle</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_WanderCurrentRoom">
|
||||
<maxDanger>Deadly</maxDanger>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="JobGiver_IdleError" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- If on colonist team, do forced and emergency work -->
|
||||
<li Class="ThinkNode_ConditionalColonist">
|
||||
<subNodes>
|
||||
<!-- Seek allowed area -->
|
||||
<li Class="JobGiver_SeekAllowedArea" />
|
||||
|
||||
<!-- Seek safe temperatures -->
|
||||
<li Class="JobGiver_BringBabyToSafety" />
|
||||
<li Class="JobGiver_SeekSafeTemperature" />
|
||||
|
||||
<!-- Drop unnused inventory -->
|
||||
<li Class="JobGiver_DropUnusedInventory" />
|
||||
|
||||
<!-- Emergency work -->
|
||||
<li Class="JobGiver_Work">
|
||||
<leaveJoinableLordIfIssuesJob>true</leaveJoinableLordIfIssuesJob>
|
||||
<emergency>true</emergency>
|
||||
</li>
|
||||
|
||||
<!-- Get food (only if starving) -->
|
||||
<li Class="ThinkNode_ConditionalStarving">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>SatisfyingNeeds</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_GetFood">
|
||||
<leaveJoinableLordIfIssuesJob>true</leaveJoinableLordIfIssuesJob>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Breastfeed -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_Autofeed" MayRequire="Ludeon.RimWorld.Biotech" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Lord directives (medium priority) -->
|
||||
<li Class="ThinkNode_JoinVoluntarilyJoinableLord">
|
||||
<dutyHook>MediumPriority</dutyHook>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>LordDuty</treeDef>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Pick up a weapon dropped while previously downed -->
|
||||
<li Class="JobGiver_PickupDroppedWeapon">
|
||||
<ignoreForbidden>true</ignoreForbidden>
|
||||
</li>
|
||||
|
||||
<!-- Optimize apparel -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>ChangingApparel</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_OptimizeApparel">
|
||||
<leaveJoinableLordIfIssuesJob>true</leaveJoinableLordIfIssuesJob>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Look change -->
|
||||
<li MayRequire="Ludeon.RimWorld.Ideology" Class="ThinkNode_ConditionalWantsLookChange">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_UseStylingStationAutomatic" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Dye hair -->
|
||||
<li MayRequire="Ludeon.RimWorld.Ideology" Class="JobGiver_DyeHair" />
|
||||
|
||||
<!-- Take for inventory stock -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>TakeForInventoryStock</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_TakeForInventoryStock">
|
||||
<leaveJoinableLordIfIssuesJob>true</leaveJoinableLordIfIssuesJob>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Unload your inventory -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>UnloadingOwnInventory</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_UnloadYourInventory" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Pack food if not hungry-->
|
||||
<li Class="ThinkNode_ConditionalNeedPercentageAbove">
|
||||
<need>Food</need>
|
||||
<threshold>0.6</threshold>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_PackFood">
|
||||
<leaveJoinableLordIfIssuesJob>true</leaveJoinableLordIfIssuesJob>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Behavior from traits -->
|
||||
<li Class="ThinkNode_TraitBehaviors" />
|
||||
|
||||
<!-- Insertion hook for modders -->
|
||||
<li Class="ThinkNode_SubtreesByTag">
|
||||
<insertTag>Humanlike_PreMain</insertTag>
|
||||
</li>
|
||||
|
||||
<!-- Main colonist behavior core -->
|
||||
<li Class="ThinkNode_ConditionalColonist">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>MainColonistBehaviorCore</treeDef>
|
||||
<leaveJoinableLordIfIssuesJob>true</leaveJoinableLordIfIssuesJob>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
<!-- Main wild man behavior core -->
|
||||
<li Class="ThinkNode_ConditionalPawnKind">
|
||||
<pawnKind>WildMan</pawnKind>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>MainWildManBehaviorCore</treeDef>
|
||||
<leaveJoinableLordIfIssuesJob>true</leaveJoinableLordIfIssuesJob>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Insertion hook for modders -->
|
||||
<li Class="ThinkNode_SubtreesByTag">
|
||||
<insertTag>Humanlike_PostMain</insertTag>
|
||||
</li>
|
||||
|
||||
<!-- Idle colonist -->
|
||||
<li Class="ThinkNode_ConditionalColonist">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Idle</tagToGive>
|
||||
<subNodes>
|
||||
<!-- Do random joy activity -->
|
||||
<li Class="ThinkNode_ConditionalNeedPercentageAbove">
|
||||
<need>Joy</need>
|
||||
<threshold>0.9</threshold>
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_IdleJoy" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Wander -->
|
||||
<li Class="JobGiver_WanderColony">
|
||||
<maxDanger>None</maxDanger>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Idle wild man -->
|
||||
<li Class="ThinkNode_ConditionalPawnKind">
|
||||
<pawnKind>WildMan</pawnKind>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Idle</tagToGive>
|
||||
<subNodes>
|
||||
<!-- Wander -->
|
||||
<li Class="JobGiver_WanderAnywhere">
|
||||
<maxDanger>Deadly</maxDanger>
|
||||
<ticksBetweenWandersRange>120~240</ticksBetweenWandersRange>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- If you're a neutral guest, if you're not hurt exit the map, otherwise use a medical bed -->
|
||||
<li Class="ThinkNode_ConditionalGuest">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalNonPlayerNonHostileFactionOrFactionless">
|
||||
<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>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Final backup: If you're just here for no apparent reason, and not a colonist, leave the map
|
||||
e.g. This happens for pawns who are downed during combat, then later self-heal -->
|
||||
<li Class="ThinkNode_ConditionalColonist">
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Misc</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_ExitMapBest">
|
||||
<defaultLocomotion>Walk</defaultLocomotion>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- If you can't leave, just wander -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Idle</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_WanderAnywhere">
|
||||
<maxDanger>Deadly</maxDanger>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<li Class="JobGiver_IdleError" />
|
||||
</subNodes>
|
||||
</thinkRoot>
|
||||
</ThinkTreeDef>
|
||||
|
||||
</Defs>
|
||||
@@ -96,6 +96,8 @@
|
||||
<Compile Include="CompNoTrainingDecay.cs" />
|
||||
<Compile Include="ThinkNode_ConditionalAnimalShouldSow.cs" />
|
||||
<Compile Include="ThinkNode_ConditionalAnimalShouldPlantCut.cs" />
|
||||
<Compile Include="CompProperties_AnimalWorkSettings.cs" />
|
||||
<Compile Include="CompAnimalWorkSettings.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="WULA_AutoMechCarrier\CompAutoMechCarrier.cs" />
|
||||
|
||||
49
Source/ArachnaeSwarm/CompAnimalWorkSettings.cs
Normal file
49
Source/ArachnaeSwarm/CompAnimalWorkSettings.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompAnimalWorkSettings : ThingComp
|
||||
{
|
||||
public CompProperties_AnimalWorkSettings Props => (CompProperties_AnimalWorkSettings)this.props;
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
|
||||
Pawn pawn = this.parent as Pawn;
|
||||
if (pawn == null) return;
|
||||
|
||||
// 关键:如果 pawn 没有 workSettings,则为其创建一个
|
||||
if (pawn.workSettings == null)
|
||||
{
|
||||
// Log.Message($"Initializing Pawn_WorkSettings for animal: {pawn.LabelShort}");
|
||||
pawn.workSettings = new Pawn_WorkSettings(pawn);
|
||||
pawn.workSettings.EnableAndInitializeIfNotAlreadyInitialized();
|
||||
|
||||
// 注意:Pawn_WorkSettings 的构造函数和 EnableAndInitializeIfNotAlreadyInitialized()
|
||||
// 通常会处理所有可用的 WorkTypeDef,并将它们的优先级初始化为 0。
|
||||
// 这正是我们想要的初始状态。具体的优先级将由其他逻辑(如你的 CompInstantTrain 或 ThinkNode)来设置。
|
||||
}
|
||||
|
||||
// 设置工作优先级
|
||||
if (pawn.workSettings != null)
|
||||
{
|
||||
foreach (var entry in Props.workTypeMap)
|
||||
{
|
||||
TrainableDef trainable = entry.trainable;
|
||||
WorkTypeDef workType = entry.workType;
|
||||
|
||||
// 检查动物是否学会了对应的 Trainable
|
||||
if (pawn.training != null && pawn.training.HasLearned(trainable))
|
||||
{
|
||||
// 设置一个默认的非零优先级,例如 3 (Medium)
|
||||
// 真正的"开关"由 ThinkNode_Conditional 的 GetWanted 控制
|
||||
pawn.workSettings.SetPriority(workType, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using RimWorld;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
// 定义在 XML 中使用的属性
|
||||
public class CompProperties_InstantTrain : CompProperties
|
||||
{
|
||||
public List<TrainableDef> trainables = new List<TrainableDef>();
|
||||
@@ -15,19 +14,15 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
}
|
||||
|
||||
// 实现组件的逻辑
|
||||
public class CompInstantTrain : ThingComp
|
||||
{
|
||||
// 方便地访问属性
|
||||
public CompProperties_InstantTrain Props => (CompProperties_InstantTrain)this.props;
|
||||
|
||||
// 在 Pawn 生成到地图上后被调用
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
|
||||
// 如果不是在加载存档时重生,则执行训练逻辑
|
||||
if (!respawningAfterLoad)
|
||||
if (!respawningAfterLoad) // 只在初次生成时执行
|
||||
{
|
||||
Pawn pawn = this.parent as Pawn;
|
||||
if (pawn == null || pawn.training == null)
|
||||
@@ -35,13 +30,11 @@ namespace ArachnaeSwarm
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历在 XML 中定义的需要训练的技能列表
|
||||
// 瞬间训练技能
|
||||
foreach (TrainableDef trainableDef in Props.trainables)
|
||||
{
|
||||
// 检查 Pawn 是否还未学会此技能
|
||||
if (!pawn.training.HasLearned(trainableDef))
|
||||
{
|
||||
// 调用原版方法,瞬间完成训练
|
||||
pawn.training.Train(trainableDef, null, true);
|
||||
}
|
||||
}
|
||||
|
||||
25
Source/ArachnaeSwarm/CompProperties_AnimalWorkSettings.cs
Normal file
25
Source/ArachnaeSwarm/CompProperties_AnimalWorkSettings.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompProperties_AnimalWorkSettings : CompProperties
|
||||
{
|
||||
// 使用列表存储键值对,因为RimWorld的XML解析器对字典有特殊要求
|
||||
public List<WorkTypeMapEntry> workTypeMap = new List<WorkTypeMapEntry>();
|
||||
|
||||
// 可以在这里添加一些配置选项,比如默认优先级等,但现在简单起见,可以留空或只做基本初始化
|
||||
public CompProperties_AnimalWorkSettings()
|
||||
{
|
||||
this.compClass = typeof(CompAnimalWorkSettings);
|
||||
}
|
||||
}
|
||||
|
||||
// 定义键值对的结构
|
||||
public class WorkTypeMapEntry
|
||||
{
|
||||
public TrainableDef trainable;
|
||||
public WorkTypeDef workType;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user