Gene Extension - Vanilla-Expanded/VanillaExpandedFramework GitHub Wiki

GeneExtension is the main way to add custom behaviours to genes. You can use any number of customizations simply by setting XML fields on the extension:

  • Gene Backgrounds: backgroundPathEndogenes and backgroundPathXenogenes change the background image of a gene. They are a string with the image path you want.
  • Hediffs: when added to a gene, these two fields will add a hediff to the pawn. hediffsToBodyParts adds the hediffs to a specific body part, using a custom structure called HediffToBodyparts. hediffToWholeBody just adds the hediff to the whole body.
  • Fur colours and masks: useSkinColorForFur makes a fur adding gene use the skin colour to tint the fur, instead of the usual hair colour. dontColourFur makes the fur appear untinted. useMaskForFur changes shader to be CutoutComplex rather than skin shader, which allows you to use masks. furHidesBody makes the fur texture hide the base game bodies completely, so they don't show behind the fur (useful for smaller than normal body furs, or furs with holes in them)
  • Gene goodies: thingSetMaker allows you to set a starting set of things (items or pawns) that pawns with this gene will start play with. These things will drop pod along with the pawns when the game is started.
  • Fixed sex: genes with these flags will force sex to be either male or female.
  • Custom blood: with these four fields you can customize blood ThingDef that is dropped when the pawn bleeds, blood icon that appears in the health screen, blood effecter that shows up when the pawns is damaged, and blood wounds specified in a FleshTypeDef.
  • Custom vomit: with these two fields you can customize vomit ThingDef that is dropped when the pawn vomits as well as the vomit effecter.
  • Disease progression factor: with this field, you can make genes that make disease progress (tick) faster or slower. This only affects diseases when they are have not been immunized against yet.
  • Caravan Carrying factor: with this field, you can pawns carry less or more during caravaning.
  • Hide gene: a field that hides the gene from appearing on the xenotype creator, useful to make special functionality genes that you don't want the player to be able to select.
  • Skills: two fields to make a gene cause no skill loss for a given skill, and make a gene increases recreation when a skill gains XP.
  • Offsets: Offset the gene graphic data depending on specific conditions like bodytype.
    public class GeneExtension : DefModExtension
    {

        //Custom gene backgrounds
        public string backgroundPathEndogenes;
        public string backgroundPathXenogenes;
        public string backgroundPathArchite;

        //Applies hediffs to existing body parts when the gene is acquired
        public List<HediffToBodyparts> hediffsToBodyParts;
        //Applies a hediff to the whole body when the gene is acquired
        public HediffDef hediffToWholeBody;

        //Makes "fur" associated with this gene use the body's colour, instead of the hair
        public bool useSkinColorForFur = false;
        //Makes "fur" associated with this gene use the body's and hair's colours
        public bool useSkinAndHairColorsForFur = false;
        //Keeps "fur" untinted
        public bool dontColourFur = false;
        //Switches "fur" shader to be CutoutComplex rather than skin shader.
        public bool useMaskForFur = false;
        //Fur hides the body graphic underneath completely
        public bool furHidesBody = false;

        //Reference to a thingsetmaker that makes pawns with this gene start play with some things (only on game start)
        public ThingSetMakerDef thingSetMaker = null;

        //Gender bender
        public bool forceMale = false;
        public bool forceFemale = false;

        // Gene will be active for a given gender only
        public Gender forGenderOnly;

        //Custom blood thingDef, custom blood icon, custom flood splash effecter, custom wounds from a fleshtype
        public ThingDef customBloodThingDef = null;
        public string customBloodIcon = "";
        public EffecterDef customBloodEffect = null;
        public FleshTypeDef customWoundsFromFleshtype = null;
        public ThingDef customBloodSmearThingDef = null;

        //Custom vomit thingDef, custom vomit effecter
        public ThingDef customVomitThingDef = null;
        public EffecterDef customVomitEffect = null;
        //Custom meat thingDef when butchered. Looks like meat is back on the menu, boys!
        public ThingDef customMeatThingDef = null;
        //Custom leather thingDef when butchered
        public ThingDef customLeatherThingDef = null;

        //Disease progression factor. Diseases will advance (when not immunized) by this factor
        public float diseaseProgressionFactor = 1f;

        //Hide gene from appearing on the xenotype creation screen. Useful for special genes that only appear as rewards during gameplay.
        public bool hideGene = false;

        //Makes this gene cause no skill loss for a given skill.
        public SkillDef noSkillLoss = null;
        //Makes this gene give the pawn recreation when gaining XP on a given skill.
        public SkillDef skillRecreation = null;
        //Makes this gene multiply skill loss of all skills by this factor
        public float globalSkillLossMultiplier = 1f;
        //Makes this gene make pawns lose skill when below 10
        public bool skillDegradation = false;

        //Makes pregancies advance faster or slower
        public float pregnancySpeedFactor = 1f;

        // Makes pawns with this gene have a higher chance of getting food-binge mental break.
        public float foodBingeMentalBreakSelectionChanceFactor = 1;

        public bool doubleNegativeFoodThought = false;

        // Size by age
        public SizeByAge sizeByAge = null;

        //Makes genes scale body per lifestages, only works for gene graphics currently
        public Dictionary<LifeStageDef, Vector2> bodyScaleFactorsPerLifestages;

        public BodyTypeDef forcedBodyType;
        public string bodyNakedGraphicPath;
        public string bodyDessicatedGraphicPath;
        public string headDessicatedGraphicPath;
        public string skullGraphicPath;

        public List<GeneDef> applySkinColorWithGenes;

    }

How do I use this code?

Def Extensions are added to the GeneDef of the gene you want to add them to.

If you aren't sure if the GeneDef ALREADY has an extension (for example, if you think another mod will add their own), always use XPATH (xml patching) to add an extension, as there is already a PatchOperationAddModExtension to ensure they don't collide.

As an example of the GeneExtension, this would make a pawn always be male, bleed green blood and start with a set of things defined in a GreenThings ThingSetMaker (both the defs for each thing and the graphics should be there too, of course). It will also move the gene graphic of the addon by (0.01, 0.2, -0.7) if the pawn is Thin.

<modExtensions>
	<li Class="VanillaGenesExpanded.GeneExtension">		
               
                <forceMale>true</forceMale>
                <thingSetMaker>GreenThings</thingSetMaker>  
		<customBloodThingDef>Filth_GreenBlood</customBloodThingDef>
		<customBloodIcon>UI/Icons/Medical/GreenBlood_BleedingIcon</customBloodIcon>
		<customBloodEffect>Damage_HitGreenFlesh</customBloodEffect>
		<customWoundsFromFleshtype>GreenWoundsFlesh</customWoundsFromFleshtype>

		<offsets>
		 <north>
		  <bodyTypes>
		   <Thin>(0.01, 0.2, -0.7)</Thin>
		  </bodyTypes>
		 </north>
		</offsets>
	</li>
</modExtensions>
⚠️ **GitHub.com Fallback** ⚠️