Modding Tutorials/Modifying classes

From RimWorld Wiki
Revision as of 13:46, 28 January 2019 by Mehni (talk | contribs) (Created page with "{{BackToTutorials}} =Changing methods= Use Harmony. =Adding fields or methods to classes= You can't. Not even with Modding Tutorials/Harmony...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Modding Tutorials

Changing methods

Use Harmony.

Adding fields or methods to classes

You can't. Not even with Harmony. Maybe you want to subclass instead?

Adding fields to Defs

You can. The game support something called a DefModExtension. If you have a Def, you can get your mod extension from it. This allows you to add any custom field to any def.

Adding behaviour to the Thing class

If it's a ThingWithComps, you can add a ThingComp instead. Almost all Things are a ThingWithComps. ThingComps can also be used to store whatever data you need.

Adding behaviour to the Hediff class

HediffWithComps also support comps. HediffComps are different from ThingComps, but their general use is the same.