Editing Modding Tutorials/Essence
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: | ||
− | |||
− | |||
− | |||
If you have a high-level understanding of what your mod will do, this page will give you a basic understanding of how to approach it. Further pages will explain how to actually go about this, but here we get you started. Don't get frustrated if not all of this makes sense to you yet. | If you have a high-level understanding of what your mod will do, this page will give you a basic understanding of how to approach it. Further pages will explain how to actually go about this, but here we get you started. Don't get frustrated if not all of this makes sense to you yet. | ||
+ | = So you want to... = | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | == ... Add a new Thing to RimWorld. == | |
RimWorld uses XML to define the Things in RimWorld, in ThingDef XML entries. So, if you are going to create a new Thing, look in the Core XML files of RimWorld and duplicate a ThingDef entry for a similar item. Then, make the modifications to that entry to achieve your item. Remember, defName needs to be different for all entries. | RimWorld uses XML to define the Things in RimWorld, in ThingDef XML entries. So, if you are going to create a new Thing, look in the Core XML files of RimWorld and duplicate a ThingDef entry for a similar item. Then, make the modifications to that entry to achieve your item. Remember, defName needs to be different for all entries. | ||
Line 39: | Line 19: | ||
− | + | == ...Create new functionality. == | |
The XML files are used to apply and adapt existing functionality in the code base in new ways, but for modders, many times this is not enough. If you need new functionality, you create that with C# code and apply it to your new Things with XML entries. | The XML files are used to apply and adapt existing functionality in the code base in new ways, but for modders, many times this is not enough. If you need new functionality, you create that with C# code and apply it to your new Things with XML entries. | ||
Line 50: | Line 30: | ||
;Create a Thing with new XML specifiable properties | ;Create a Thing with new XML specifiable properties | ||
− | : Create a new C# class with these new XML properties, that | + | : Create a new C# class with these new XML properties, that inherits from ThingDef. In your XML ThingDef entry, have 'Class="MyNamespace.YourThingDef".' |
− | + | ||
+ | |||
+ | == ...Alter RimWorld code. == | ||
− | |||
Sometimes, you need to change what existing code does. This can be done in both XML and C# code. | Sometimes, you need to change what existing code does. This can be done in both XML and C# code. | ||
;Alter a Core Thing's XML Entry | ;Alter a Core Thing's XML Entry | ||
− | + | : As of A17, there exists something called DefPatches to alter the XML of RimWorld, often with no effect upon other Mods. So, you could change the power consumption of a lamp or make Devilstrand plantable in new locations. | |
− | : | ||
;Alter a C# method | ;Alter a C# method | ||
− | : Harmony is the current best approach for enhancing existing RimWorld code by inserting code pre/post to an existing method being called. See | + | : Harmony is the current best approach for enhancing existing RimWorld code by inserting code pre/post to an existing method being called. See HugsLib and Harmony. |
+ | |||
+ | |||
+ | |||
+ | = Levels of Difficulty = | ||
+ | |||
+ | So how hard is it to mod? | ||
+ | |||
+ | * Easy - Edit XML to apply existing functionality in new ways to make new things. (i.e. a new gun) | ||
+ | |||
+ | * Easy (if artist) - Create new RimWorld art and sound assets and add them to XML to use them. | ||
− | + | * Easy (if can code) - Create a C# class to make new behavior. These c# classes can be used in XML ThingDefs. | |
− | |||
− | + | * Harder: GUI programming | |
+ | * Hard: Complex inter-object behaviors | ||
− | + | * Hard: Create new AI behaviors |