Modding Tutorials/ThingDef

From RimWorld Wiki
Revision as of 16:27, 8 February 2019 by Mehni (talk | contribs) (starting rewrite)
Jump to navigation Jump to search

Italic textModding Tutorials

ThingDef is one of the many Defs used in RimWorld. Almost every "tangible" (and some intangible) things you see in RimWorld are backed by a ThingDef.

What you'll learn

You will learn the structure of ThingDef, how to use a decompiler to learn what a tag does, and along the way you'll learn the meaning of a few select tags.

What you will not learn

The goal of this tutorial is not to tell you what each XML tag does. ThingDef alone has 200+ valid XML tags, not counting hundreds of subtags. There are simply too many to document, and a lot of them are self-explanatory.

  • If you want a list of all XML tags (not just ThingDef) you'll want milon's autodocumentation project. Note that it only includes tags in use by RimWorld, not necessarily all tags available.
  • If you want to see what an earnest attempt at documenting the XML looks like, you'll want the XML Documentation Database. Last updated for A15.
  • If you want to see what a documentation attempt on this wiki looks like, view the history of this article and see that was last up to date in Alpha 9.

Fact of the matter is this: there is no documentation that will tell you the meaning and usage of every tag. There probably never will. If there is, it will be out-of-date soon enough.

Requirements

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.

Existing tags

Tags Description Values
wantsHopperAdjacent Whether the building needs adjacent hoppers or not. Boolean
ignoreNeedsPower When has CompTrader: Whether this building requires power or not. Boolean
soundAmbient Sound to play whenever its working. SoundDefs
shipPart Designates the building as one of the ship parts or not. Boolean

Adding more tags

This requires C#. The current recommended way for maximum compatibility is by using a DefModExtension.

See also