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 71: | Line 71: | ||
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 118: | ||
</div> | </div> | ||
− | == | + | === Lists of Defs === |
− | <code>MayRequire</code> | + | Unlike other usages of <code>MayRequire</code>, lists of Defs have a special behavior: when used to filter lists of [[Modding_Tutorials/Defs|Defs]], <code>MayRequire</code> only serves to suppress cross-resolution errors if the targeted DLC or mod is not loaded. '''If RimWorld finds the targeted Def, it will be loaded into the list regardless of whether the specified DLC or mod is loaded or not.''' |
− | |||
− | |||
<div class="TutorialTableWrapper"> | <div class="TutorialTableWrapper"> | ||
{| class="TutorialCodeTable" | {| class="TutorialCodeTable" | ||
! XML Example !! Description | ! XML Example !! Description | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 208: | Line 160: | ||
| class="TutorialCodeTable-description" | | | 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. | <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"> | ||
+ | <DesignationCategoryDef> | ||
+ | <defName>Zone</defName> | ||
+ | <label>zone</label> | ||
+ | <order>800</order> | ||
+ | <specialDesignatorClasses> | ||
+ | <li>Designator_Cancel</li> | ||
+ | <li>Designator_Deconstruct</li> | ||
+ | <li>Designator_ZoneAddStockpile_Resources</li> | ||
+ | <li>Designator_ZoneAddStockpile_Dumping</li> | ||
+ | <li>Designator_ZoneAdd_Growing</li> | ||
+ | <li>Designator_ZoneDelete</li> | ||
+ | <li>Designator_AreaHomeExpand</li> | ||
+ | <li>Designator_AreaHomeClear</li> | ||
+ | <li>Designator_AreaAllowedExpand</li> | ||
+ | <li>Designator_AreaAllowedClear</li> | ||
+ | <li>Designator_AreaBuildRoof</li> | ||
+ | <li>Designator_AreaNoRoof</li> | ||
+ | <li>Designator_AreaIgnoreRoof</li> | ||
+ | <li>Designator_AreaSnowClearExpand</li> | ||
+ | <li>Designator_AreaSnowClearClear</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">Designator_AreaPollutionClearExpand</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">Designator_AreaPollutionClearClear</li> | ||
+ | </specialDesignatorClasses> | ||
+ | </DesignationCategoryDef> | ||
+ | </source> | ||
+ | | class="TutorialCodeTable-description" | | ||
+ | <code>MayRequire</code> is used in the DesignationCategoryDef for the "Zone" architect menu to add designators for pollution clearing areas. | ||
+ | |- | ||
+ | |} | ||
+ | </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"> | ||
+ | {| class="TutorialCodeTable" | ||
+ | ! XML !! Description | ||
+ | |- | ||
+ | | <source lang="xml"> | ||
+ | <ThingDef ParentName="ApparelMakeableBase"> | ||
+ | <defName>Apparel_Duster</defName> | ||
+ | |||
+ | <!-- irrelevant tags omitted --> | ||
+ | |||
+ | <equippedStatOffsets> | ||
+ | <SlaveSuppressionOffset MayRequire="Ludeon.RimWorld.Ideology">-0.05</SlaveSuppressionOffset> | ||
+ | </equippedStatOffsets> | ||
+ | |||
+ | <!-- irrelevant tags omitted --> | ||
+ | </ThingDef> | ||
+ | </source> | ||
+ | | class="TutorialCodeTable-description" | | ||
+ | <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 237: | ||
</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"> | ||
+ | <ThingDef MayRequire="Ludeon.RimWorld.Ideology" ParentName="Brazier"> | ||
+ | <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"> | | <source lang="xml"> | ||
− | < | + | <StatDef ParentName="MeditationFocusBase" MayRequireAnyOf="Ludeon.RimWorld.Royalty,Ludeon.RimWorld.Biotech"> |
− | <defName> | + | <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 386: | ||
| 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"> |