Animal Behaviours Def Extensions - AndroidQuazar/VanillaExpandedFramework GitHub Wiki

The AnimalBehaviours module of Vanilla Expanded Framework adds two Def Extensions:

AnimalStatExtension: This def extension allows you to add new entries to the animal stats that appear in the animal info panel (the one that gives you the amounts of meat they produce, their lifespan, etc).

public class AnimalStatExtension : DefModExtension
    {
        public List<string> statToAdd = null;
        public List<string> statValues = null;
        public List<string> statDescriptions = null;
    }

It also allows you to put an image of an animal in its info card

        public bool showImageInInfoCard = false;
        public string ImageToShowInInfoCard = "UI/EmptyImage";

Image is recommended to be 300 x 300 px and have a transparent background.

NocturnalAnimals: This def extension makes animals Diurnal (default), Nocturnal or Crepuscular.

        public BodyClock bodyClock; //(values can be Diurnal (default), Nocturnal or Crepuscular 

How do I use this code?

Def Extensions are added to the ThingDef of the animal you want to add them to.

If you aren't sure if the def 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 first def extension, AnimalStatExtension, the Lernaean Hydra in Magical menagerie uses this to display details about its roles and ranged abilities. All entries point to translateable strings in Languages/English/Keyed/Misc_Gameplay.xml

<modExtensions>
	<li Class="AnimalBehaviours.AnimalStatExtension">			
		<statToAdd>
			<li>MM_SecondaryRole</li>
			<li>MM_PrimaryRole</li>
			<li>MM_RangedAttacks</li>					
		</statToAdd>
		<statValues>
			<li>MM_Tank</li>
			<li>MM_DamageRanged</li>
			<li>MM_Yes</li>					
		</statValues>
		<statDescriptions>
			<li>MM_VenomousTankDesc</li>
			<li>MM_DamageRangedDOTDesc</li>
			<li>MM_Ranged</li>
		</statDescriptions>					
	</li>
</modExtensions>

As an example of the second def extension, NocturnalAnimals, this patch makes the Nightram in Alpha Animals nocturnal

    <Operation Class="PatchOperationAddModExtension">
        <xpath>/Defs/ThingDef[defName="AA_NightRam"]</xpath>
        <value>
            <li Class="NocturnalAnimals.ExtendedRaceProperties">
                <bodyClock>Nocturnal</bodyClock>
            </li>
        </value>
    </Operation>
⚠️ **GitHub.com Fallback** ⚠️