Thoughts About Water - KonradHeinser/EBSGFramework GitHub Wiki
This workerClass allows you to create traits and genes that create moods effects based on the water around them while they are on a map. Th first step is to make a thought that uses the class and has at least 2 stages, the first for no water, and every stage after for varying levels of water. You can make the basic no water/water stages turn the thought inactive (nothing appears on needs page) by making the baseMoodEffect to 0:
<ThoughtDef>
<defName>WaterLover</defName>
<workerClass>EBSGFramework.ThoughtWorker_NearWater</workerClass>
<stages>
<li>
<label>no water</label>
<description>There isn't any water nearby.</description>
<baseMoodEffect>-10</baseMoodEffect>
</li>
<li>
<label>water</label>
<description>There's some water nearby.</description>
<baseMoodEffect>10</baseMoodEffect>
</li>
</stages>
</ThoughtDef>
In the above state, the thought will toggle between the two thoughts depending on if the pawn is standing in water at that moment. It will also be active for every single pawn unless some limiters are added, either using the vanilla requiredTraits or requiredGenes, or using the EBSG Extension's relatedGenes if you want multiple genes to have access to the thought individually
<requiredTraits>
<li>InsertDefNameHere</li>
</requiredTraits>
<requiredGenes>
<li>InsertDefNameHere</li>
</requiredGenes>
<modExtensions>
<li Class="EBSGFramework.EBSGThoughtExtension">
<relatedGenes>
<li>InsertDefNameHere</li>
</relatedGenes>
</li>
</modExtensions>
Any customization beyond this point will require the EBSGThoughtExtension, so if you want to increase the check distance or want to create multiple stages of water liking, make sure your ThoughtDef has the extension attached to it with whatever distance you desire set inside it:
<modExtensions>
<li Class="EBSGFramework.EBSGThoughtExtension">
<maxWaterDistance>5</maxWaterDistance><!--Tells the code to count water within 5 tiles-->
</li>
</modExtensions>
You can make the thought use multiple levels by adding a list of thresholds in the extension. These thresholds are the number of water tiles within your set radius, and each threshold requires its own stage. If your thought is using thresholds, setting baseMoodEffect to 0 only makes the no water stage turn the thought inactive:
<modExtensions>
<li Class="EBSGFramework.EBSGThoughtExtension">
<maxWaterDistance>5</maxWaterDistance><!--Tells the code to count water within 5 tiles-->
<thresholds>
<li>1</li>
<li>3</li>
<li>5</li>
<li>10</li>
</thresholds>
</li>
</modExtensions>
You can also make hydrophobia mental breaks similar to how vanilla's fireterror works. It uses most of the same xml as pyrophobia, just with different classes and distance deciders (pyrophobia uses a static 19.9 while these classes either use 0 or the same maxWaterDistance in the extension that is mentioned above)
<workerClass>EBSGFramework.MentalBreakWorker_Hydrophobia</workerClass> <!--The workerClass for the MentalBreakDef-->
<stateClass>EBSGFramework.MentalState_PanicFleeWater</stateClass> <!--The stateClass for the MentalStateDef-->
<!--Needs to be in both the break and the state defs. I recommend making the state use a higher number to avoid having pawns repeatedly charge the water so much-->
<modExtensions>
<li Class="EBSGFramework.EBSGThoughtExtension">
<maxWaterDistance>19.9</maxWaterDistance>
</li>
</modExtensions>
Example of a thought that provides increased mood the more water is nearby, up to 40 if there are 10 water tiles within a radius of 5, but only for pawns with the imaginary WaterLover trait
<ThoughtDef>
<defName>WaterLover</defName>
<workerClass>EBSGFramework.ThoughtWorker_NearWater</workerClass>
<validWhileDespawned>false</validWhileDespawned>
<developmentalStageFilter>Baby, Child, Adult</developmentalStageFilter>
<requiredTraits>
<li>WaterLover</li>
</requiredTraits>
<stages>
<li>
<label>no water</label>
<description>There isn't any water nearby.</description>
<baseMoodEffect>-10</baseMoodEffect>
</li>
<li>
<label>water</label>
<description>There's some water nearby.</description>
<baseMoodEffect>10</baseMoodEffect>
</li>
<li>
<label>water</label>
<description>There's plenty of water nearby.</description>
<baseMoodEffect>20</baseMoodEffect>
</li>
<li>
<label>water</label>
<description>There's a whole bunch of water nearby!</description>
<baseMoodEffect>30</baseMoodEffect>
</li>
<li>
<label>water!</label>
<description>I'm surrounded by water!</description>
<baseMoodEffect>40</baseMoodEffect>
</li>
</stages>
<modExtensions>
<li Class="EBSGFramework.EBSGThoughtExtension">
<maxWaterDistance>5</maxWaterDistance>
<thresholds>
<li>1</li>
<li>3</li>
<li>5</li>
<li>10</li>
</thresholds>
</li>
</modExtensions>
</ThoughtDef>
Alternative example of a basic hydrophobia gene from Superhero Genes. The gene can't be completely copy pasted due to the parent being different, but the primary content are the mentalBreakDef and mentalBreakMtbDays lines:
<GeneDef ParentName="SHG_FlawBase" MayRequire="EBSG.Framework">
<defName>SHG_Hydrophobia</defName>
<label>hydrophobia</label>
<description>Supers with this gene have an irrational fear of water, and may end up running away any time they are near any notable body of water. It is recommended that you adjust their allowed area to prevent them from around rivers, ponds, lakes, oceans, etc.</description>
<customEffectDescriptions>
<li>May have a mental breakdown when near water.</li>
</customEffectDescriptions>
<iconPath>UI/Icons/Genes/Gene_FireTerror</iconPath>
<mentalBreakMtbDays>0.1</mentalBreakMtbDays>
<mentalBreakDef>SHG_Hydrophobia</mentalBreakDef>
<biostatMet>5</biostatMet>
</GeneDef>
<ThoughtDef MayRequire="EBSG.Framework">
<defName>SHG_Hydrophobia</defName>
<workerClass>EBSGFramework.ThoughtWorker_NearWater</workerClass>
<developmentalStageFilter>Baby, Child, Adult</developmentalStageFilter>
<requiredGenes>
<li>SHG_Hydrophobia</li>
</requiredGenes>
<stages>
<li>
<label>hydrophobia</label>
<description>Water be scary. Stay away from it.</description>
<baseMoodEffect>0</baseMoodEffect>
</li>
<li>
<label>hydrophobia</label>
<description>The water makes me so nervous. What lies hidden within it, just waiting for me to drop my guard?</description>
<baseMoodEffect>-10</baseMoodEffect>
</li>
</stages>
<modExtensions>
<li Class="EBSGFramework.EBSGThoughtExtension">
<maxWaterDistance>14.9</maxWaterDistance>
</li>
</modExtensions>
</ThoughtDef>
<MentalBreakDef MayRequire="EBSG.Framework">
<defName>SHG_Hydrophobia</defName>
<label>hydrophobia</label>
<intensity>Minor</intensity>
<workerClass>EBSGFramework.MentalBreakWorker_Hydrophobia</workerClass>
<mentalState>SHG_Hydrophobia</mentalState>
<requiredGene>SHG_Hydrophobia</requiredGene>
<modExtensions>
<li Class="EBSGFramework.EBSGThoughtExtension">
<maxWaterDistance>14.9</maxWaterDistance>
</li>
</modExtensions>
</MentalBreakDef>
<MentalStateDef ParentName="BaseMentalState" MayRequire="EBSG.Framework">
<defName>SHG_Hydrophobia</defName>
<label>panic-fleeing water</label>
<stateClass>EBSGFramework.MentalState_PanicFleeWater</stateClass>
<category>Misc</category>
<nameColor>(0.65, 0.9, 0.93)</nameColor>
<recoveryMessage>{0} is no longer fleeing water.</recoveryMessage>
<baseInspectLine>Mental state: Fleeing water</baseInspectLine>
<blockNormalThoughts>true</blockNormalThoughts>
<minTicksBeforeRecovery>60</minTicksBeforeRecovery>
<modExtensions>
<li Class="EBSGFramework.EBSGThoughtExtension">
<maxWaterDistance>19.9</maxWaterDistance>
</li>
</modExtensions>
</MentalStateDef>