Editing Modding Tutorials/ThingDef

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:
{{BackToTutorials}}
+
''Italic text''{{BackToTutorials}}
 +
{{stub}}
  
 
'''ThingDef''' is one of the many [[Modding_Tutorials/XML_Defs|Defs]] used in RimWorld. Almost every "tangible" (and some intangible) things you see in RimWorld are backed by a ThingDef.
 
'''ThingDef''' is one of the many [[Modding_Tutorials/XML_Defs|Defs]] used in RimWorld. Almost every "tangible" (and some intangible) things you see in RimWorld are backed by a ThingDef.
Line 20: Line 21:
 
[[File:ThingDef.PNG|300px|thumb|right|ILSpy v4.0 showing the decompiled ThingDef class, with the analyzer expanded on the smallVolume field. To the left a few of available fields are visible.]]
 
[[File:ThingDef.PNG|300px|thumb|right|ILSpy v4.0 showing the decompiled ThingDef class, with the analyzer expanded on the smallVolume field. To the left a few of available fields are visible.]]
  
=Introduction=
+
=Existing tags=
There are hundreds of XML tags. Some of them are rudimentary tags required for basic operation. Most of them are self-explanatory, and you can always use the Find In Files functionality of [[Modding Tutorials/Recommended software|your favourite text editor]] to see what it is used by, and what values already exist. Sometimes, this does not suffice. This tutorial is for those times.
+
{| class="wikitable sortable"
 
+
! scope="col"| Tags
=An example=
+
! scope="col"| Description
Let's take a look at the ''intricate'' tag. This tag serves as an example because unlike "DeteriorationRate" or "stackLimit" it's not immediately obvious what it does. This tutorial assumed you just used the Find In Files functionality of [[Modding Tutorials/Recommended software|your favourite text editor]] and learned just one thing: Only the [[Component]] and [[Advanced component]] have this tag, and it's set to true.
+
! scope="col"| Values
 
+
|----
<source lang = "xml">
+
! scope="row"| wantsHopperAdjacent
<Defs>
+
|Whether the building needs adjacent hoppers or not.
    <ThingDef>
+
|Boolean
        <defName>ComponentIndustrial</defName>
+
|----
        <intricate>true</intricate>
+
! scope="row"| ignoreNeedsPower
    </ThingDef>
+
|When has CompTrader: Whether this building requires power or not.
</Defs>
+
|Boolean
</source>
+
|----
 
+
! scope="row"| soundAmbient
[[File:Intricate.PNG|300px|thumb|right|The search result for intricate.]]
+
|Sound to play whenever its working.
 
+
|SoundDefs
Take your favourite [[Modding Tutorials/Decompiling source code|decompiler]] and search for ''intricate''. Now right-click the result and hit ''analyze''. The analyzer in my decompiler shows it's read in three places, and assigned nowhere. The decompiler doesn't show any assigning of this value because it's set in the XML. We can see it's read by ''PlayerItemAccessibilityUtility.CacheAccessibleThings'' and twice by ''Thing.SmeltProducts''. Taking a closer look at the ''Thing+<SmeltProducts>c__Iterator4.MoveNext'', this is an inner method for the enumerator<ref>The what? An enumerable is a fancy type of list and the MoveNext means "go to the next item on the list". Apologies to those who have a background in computer science.</ref>. That in itself doesn't do much, so let's take a look at ''SmeltProducts'' itself.
+
|----
 
+
! scope="row"| shipPart
[[File:SmeltProducts.PNG|300px|thumb|right|The view for SmeltProducts.]]
+
|Designates the building as one of the ship parts or not.
 
+
|Boolean
We can see here that ''SmeltProducts'' in turn is used for some economy related DebugOutput, and by MakeRecipeProducts. We can dive further down the rabbithole, but by now it is a reasonable assumption that ''SmeltProducts'' is used to determine what products you get from smelting. But what's the ''intricate'' tag? Well, ''SmeltProducts'' loops over the ingredients in the costList (i.e. the required ingredients to make an item) and checks if it's ''intricate''. If it's not intricate, it will return the ingredient.
+
|----
 
+
|}
In other words, the ''intricate'' tag means that ThingDef won't survive a trip to the smelter. You don't get your components back if you smelt down an [[Assault rifle]].
 
 
 
'''You can find the meaning of every XML tag this way.''' Some might be easier than others, but you can find (or make an educated guess) to the meaning of every XML tag.
 
  
 
=Adding more tags=
 
=Adding more tags=
Line 55: Line 53:
  
 
[[Category:Defs]]
 
[[Category:Defs]]
[[Category:Modding tutorials]]
 

Please note that all contributions to RimWorld Wiki are considered to be released under the CC BY-SA 3.0 (see RimWorld Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page:

This page is a member of 1 hidden category: