Editing Modding Tutorials/MayRequire
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:MayRequire}} | {{DISPLAYTITLE:MayRequire}} | ||
− | {{ | + | {{:Modding_Tutorials/Under_Review}} |
<code>MayRequire</code> is an [[Modding_Tutorials/Introduction_to_XML|XML attribute]] introduced alongside the [[Royalty DLC]] that allows for easy conditional loading of XML content. <code>MayRequire</code> makes it easier to load content that is optionally dependent on DLCs or other mods. | <code>MayRequire</code> is an [[Modding_Tutorials/Introduction_to_XML|XML attribute]] introduced alongside the [[Royalty DLC]] that allows for easy conditional loading of XML content. <code>MayRequire</code> makes it easier to load content that is optionally dependent on DLCs or other mods. | ||
Line 13: | Line 13: | ||
* Ideology: <code>Ludeon.RimWorld.Ideology</code> | * Ideology: <code>Ludeon.RimWorld.Ideology</code> | ||
* Biotech: <code>Ludeon.RimWorld.Biotech</code> | * Biotech: <code>Ludeon.RimWorld.Biotech</code> | ||
− | |||
The <code>packageId</code> for mods can be found in their [[About.xml]] file. | The <code>packageId</code> for mods can be found in their [[About.xml]] file. | ||
Line 20: | Line 19: | ||
By default, <code>MayRequire</code> will only allow the use of that node if ''all'' of the DLCs or mods it designates are loaded. If you instead want to load the specified node if ''any'' of the specified DLCs or mods are loaded, you can use <code>MayRequireAnyOf</code> instead. | By default, <code>MayRequire</code> will only allow the use of that node if ''all'' of the DLCs or mods it designates are loaded. If you instead want to load the specified node if ''any'' of the specified DLCs or mods are loaded, you can use <code>MayRequireAnyOf</code> instead. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== List Entries == | == List Entries == | ||
Line 36: | Line 27: | ||
{| class="TutorialCodeTable" | {| class="TutorialCodeTable" | ||
! XML Example !! Description | ! XML Example !! Description | ||
+ | |- | ||
+ | | <source lang="xml"> | ||
+ | <ThingDef ParentName="BasePawn"> | ||
+ | <defName>Human</defName> | ||
+ | <label>human</label> | ||
+ | |||
+ | <!-- irrelevant nodes omitted --> | ||
+ | |||
+ | <recipes> | ||
+ | <li>ExciseCarcinoma</li> | ||
+ | <li>AdministerMechSerumHealer</li> | ||
+ | <li>RemoveBodyPart</li> | ||
+ | <li>Euthanize</li> | ||
+ | <li>Anesthetize</li> | ||
+ | <li>CureScaria</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">Vasectomy</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ReverseVasectomy</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">TubalLigation</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ExtractOvum</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Royalty">CureBloodRot</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Royalty">CureAbasia</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ExtractHemogenPack</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">BloodTransfusion</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ImplantXenogerm</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ImplantIUD</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">RemoveIUD</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">TerminatePregnancy</li> | ||
+ | </recipes> | ||
+ | |||
+ | <!-- irrelevant nodes omitted --> | ||
+ | |||
+ | </ThingDef> | ||
+ | </source> | ||
+ | | class="TutorialCodeTable-description" | | ||
+ | <code>MayRequire</code> is used in the Human [[Modding_Tutorials/ThingDef|ThingDef]] to set surgery recipes that are only relevant to specific DLCs. Without <code>MayRequire</code>, these would cause errors as the specified [[Modding_Tutorials/Defs|Defs]] only exist in their respective DLCs. | ||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 71: | Line 97: | ||
Note that the use of <code>MayRequire</code> on the list nodes of the <code><applyToRecipes></code> is technically unnecessary as the entire outcome node would not have loaded without [[Biotech]] active. | Note that the use of <code>MayRequire</code> on the list nodes of the <code><applyToRecipes></code> is technically unnecessary as the entire outcome node would not have loaded without [[Biotech]] active. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 147: | Line 144: | ||
</div> | </div> | ||
− | == | + | == Stat Blocks == |
− | |||
− | |||
− | + | <code>MayRequire</code> can be used by any <code>StatModifier</code> list, which includes all <code>statBases</code>, <code>statOffsets</code>, <code>statFactors</code>, and <code>equippedStatOffsets</code> nodes: | |
<div class="TutorialTableWrapper"> | <div class="TutorialTableWrapper"> | ||
{| class="TutorialCodeTable" | {| class="TutorialCodeTable" | ||
− | ! XML | + | ! XML !! Description |
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
− | + | <ThingDef ParentName="ApparelMakeableBase"> | |
− | + | <defName>Apparel_Duster</defName> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | <ThingDef ParentName=" | ||
− | <defName> | ||
− | |||
− | <!-- irrelevant | + | <!-- irrelevant tags omitted --> |
− | < | + | <equippedStatOffsets> |
− | < | + | <SlaveSuppressionOffset MayRequire="Ludeon.RimWorld.Ideology">-0.05</SlaveSuppressionOffset> |
− | + | </equippedStatOffsets> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | </ | ||
− | |||
− | |||
+ | <!-- irrelevant tags omitted --> | ||
</ThingDef> | </ThingDef> | ||
</source> | </source> | ||
| class="TutorialCodeTable-description" | | | class="TutorialCodeTable-description" | | ||
− | <code>MayRequire</code> is used | + | <code>MayRequire</code> is used by several vanilla apparel [[Modding_Tutorial/ThingDef|ThingDef]]s to apply stats that are only relevant to DLCs, such as the [[Slavery|SlaveSuppressionOffset]] stat from [[Ideology]]. |
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 229: | Line 188: | ||
</source> | </source> | ||
| class="TutorialCodeTable-description" | | | class="TutorialCodeTable-description" | | ||
− | <code>MayRequire</code> | + | <code>MayRequire</code> is used by several vanilla buildings such as the torch lamp to determine how much that particular building influences the overall style of the room it is in. This is also an [[Ideology]] feature. |
+ | |- | ||
+ | |} | ||
+ | </div> | ||
+ | |||
+ | == Optional Defs == | ||
+ | |||
+ | <code>MayRequire</code> can be used to conditionally load entire Defs. This is far easier to use than the prior option of using [[Modding_Tutorials/PatchOperations|PatchOperations]] to inject new Defs. | ||
+ | |||
+ | <div class="TutorialTableWrapper"> | ||
+ | {| class="TutorialCodeTable" | ||
+ | ! XML !! Description | ||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
− | <ThingDef ParentName=" | + | <ThingDef MayRequire="Ludeon.RimWorld.Ideology" ParentName="Brazier"> |
− | <defName> | + | <defName>DarklightBrazier</defName> |
+ | <label>darklight brazier</label> | ||
+ | <description>A specially treated brazier that illuminates its surroundings with darklight and creates heat. These satisfy royal brazier requirements.</description> | ||
+ | |||
+ | <!-- irrelevant content omitted --> | ||
+ | |||
+ | </ThingDef> | ||
+ | </source> | ||
+ | | class="TutorialCodeTable-description" | | ||
+ | <code>MayRequire</code> is used to activate [[Royalty]]'s darklight brazier stat if [[Ideology]] is also loaded. | ||
+ | |- | ||
+ | | <source lang="xml"> | ||
+ | <StatDef ParentName="MeditationFocusBase" MayRequireAnyOf="Ludeon.RimWorld.Royalty,Ludeon.RimWorld.Biotech"> | ||
+ | <defName>MeditationFocusGain</defName> | ||
+ | <label>meditation psyfocus gain</label> | ||
+ | |||
+ | <!-- irrelevant content omitted --> | ||
− | + | </StatDef> | |
+ | </source> | ||
+ | | class="TutorialCodeTable-description" | | ||
+ | <code>MayRequireAnyOf</code> is used to activate the MeditationFocusGain stat if either [[Royalty]] or [[Biotech]] is loaded. | ||
+ | |- | ||
+ | | <source lang="xml"> | ||
+ | <ThingDef ParentName="ApparelMakeableBase" MayRequireAnyOf="Ludeon.RimWorld.Royalty,Ludeon.RimWorld.Biotech"> | ||
+ | <defName>Apparel_Cape</defName> | ||
+ | <label>cape</label> | ||
− | < | + | <!-- irrelevant content omitted --> |
− | |||
− | |||
− | |||
</ThingDef> | </ThingDef> | ||
</source> | </source> | ||
| class="TutorialCodeTable-description" | | | class="TutorialCodeTable-description" | | ||
− | <code> | + | <code>MayRequireAnyOf</code> is used to activate the [[Cape]] apparel if either [[Royalty]] or [[Biotech]] is loaded. |
+ | |- | ||
+ | |} | ||
+ | </div> | ||
+ | |||
+ | == Miscellaneous == | ||
+ | |||
+ | The following are specific, non-standard usages of <code>MayRequire</code>. Some of these are technically lists with special parsing, some are fields that were coded specifically to accept the <code>MayRequire</code> attribute. | ||
+ | |||
+ | <div class="TutorialTableWrapper"> | ||
+ | {| class="TutorialCodeTable" | ||
+ | ! XML !! Description | ||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 335: | Line 337: | ||
| class="TutorialCodeTable-description" | | | class="TutorialCodeTable-description" | | ||
<code>MayRequire</code> must be used for xenotype references in <code>FactionDef</code> entries, as they only exist if [[Biotech]] is loaded. | <code>MayRequire</code> must be used for xenotype references in <code>FactionDef</code> entries, as they only exist if [[Biotech]] is loaded. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 403: | Line 346: | ||
</source> | </source> | ||
| class="TutorialCodeTable-description" | | | class="TutorialCodeTable-description" | | ||
− | <code>MayRequire</code> is used by <code>PawnKindDef</code> for the <code>apparelIgnorePollution</code> node | + | <code>MayRequire</code> is used by <code>PawnKindDef</code> for the <code>apparelIgnorePollution</code> node, which is only applicable if [[Biotech]] is loaded. |
− | |||
− | |||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 424: | Line 365: | ||
| class="TutorialCodeTable-description" | | | class="TutorialCodeTable-description" | | ||
<code>MayRequire</code> is used for think tree override and worker classes in <code>LifeStageDef</code> entries for functionality related to children and growth in [[Biotech]]. | <code>MayRequire</code> is used for think tree override and worker classes in <code>LifeStageDef</code> entries for functionality related to children and growth in [[Biotech]]. | ||
− | |||
− | |||
|- | |- | ||
|} | |} | ||
</div> | </div> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:Modding]] | [[Category:Modding]] | ||
[[Category:Modding tutorials]] | [[Category:Modding tutorials]] |