where to find code for implants ?

Started by kwatman, November 02, 2019, 04:43:55 AM

Previous topic - Next topic

kwatman

so i want to code my own implants for pawns.
Im new to modding and this is the first thing im going to make.
I found the xml file of the already exesting implants, but where do i find the c# code of it ?
thx in advance

K

There's a couple of different types of classes related to implants and added parts (which are distinct from each other).

The most important is the hediffClass, which defines the overall behavior of the implant or added part. Two types are available in vanilla for this application, the Hediff_Implant class, which is used for implants like joywires, and the Hediff_AddedPart class, which is used for prosthetic-type devices. They're both derived from HediffWithComps, and you can write your own hediffClass based on HediffWithComps if you'd like.

Other, more specialized behaviors are defined in HediffComps, which add functionality on top of the base class. One in the vanilla game that you can look at are HediffComp_VerbGiver, which is what gives pawns new attacks when they have prosthetics. If you're looking to add functionality to implants and added parts, HediffComps are an easy way to extend the existing behaviors.

If you don't have one already, it's strongly recommended to get a decompiler so that you can view the game's source for reference. Many C# IDEs come with a built-in decompiler, which is quite convenient. There's also ILSpy, which a stand-alone decompiler. Any of these would allow you to see the source and investigate how it works.