Skip to content

ThingDefExtension

Kylian Balde edited this page Nov 5, 2022 · 16 revisions

The ThingDefExtension of Vanilla Expanded Framework provides additional configurable features to weapons, apparel (including shields) and various other ThingDefs.

public class ThingDefExtension : DefModExtension
{
	// For weapons
        public bool usableWithShields = false;
        public WeaponDrawOffsets weaponCarryDrawOffsets = null;     // Offsets carried weapon regardless of stance
        public WeaponDrawOffsets weaponDraftedDrawOffsets = null;   // Only when drafted but not actively attacking/aiming

        // For shields and apparel
        public List<PawnKindDef> useFactionColourForPawnKinds;

        // For artillery
        public float siegeBlueprintPoints = SiegeBlueprintPlacer.ArtyCost;

        // For thing that can be discovered by deep scanner
        public Color deepColor = Color.white;
        public float transparencyMultiplier = 0.5f;
        public bool allowDeepDrill = true;
        // For buildings that need to render deep resources mouse attachments
        public bool deepResourcesOnGUI = false;
        public bool deepResourcesOnGUIRequireScanner = true;

        // For skyfallers that can fall into shield fields
        public int shieldDamageIntercepted = -1;

        public bool destroyCorpse;
}

How do I use this code?

Add the VFECore.ThingDefExtension Def Extension to the ThingDef you want to customize, and specify optional parameters as desired:

<modExtensions>
	<li Class="VFECore.ThingDefExtension">			
		<!-- Specify optional parameters here -->				
	</li>
</modExtensions>

Specifying draw offsets and angles for equipped weapons

Offsetting weapons regardless of stance

For oversized weapons such as the Warcasket lasers and wardrone mini-blasters from Vanilla Factions Expanded - Pirates, you can use weaponCarryDrawOffsets to specify draw offsets and angles. These apply at all times, whenever the pawn is drafted, carrying weapons openly, watching for targets or actively aiming/attacking a target.

<!-- Example: VFEP_WarcasketGun_LaserBlaster from Vanilla Factions Expanded - Pirates -->
<modExtensions>
	<li Class="VFECore.ThingDefExtension">
		<weaponCarryDrawOffsets>
			<north>
				<drawOffset>(0,0,-0.18)</drawOffset>
			</north>
			<east>
				<drawOffset>(0,0,-0.18)</drawOffset>
			</east>
			<south>
				<drawOffset>(0,0,-0.18)</drawOffset>
			</south>
			<west>
				<drawOffset>(0,0,-0.18)</drawOffset>
			</west>
		</weaponCarryDrawOffsets>
	</li>
</modExtensions>

Vanilla Factions Expanded - Pirate Warcasket armed with an oversized laser weapon from Vanilla Weapons Expanded - Laser (regular pawn with Charge Rifle for scale)

Offsetting weapons only when drafted but not attacking

For long polearm weapons such as pikes and halberds, you can use weaponDraftedDrawOffsets to specify draw offsets and angles that only apply when the pawn is drafted, carrying weapons openly, watching for targets - aiming is not affected.

<!-- Example: Mousekin Pike from Mousekin Race -->
<modExtensions>
	<li Class="VFECore.ThingDefExtension">
		<weaponDraftedDrawOffsets>
			<north>
				<drawOffset>(0.25, 0, 0.36)</drawOffset>
				<angleOffset>-143</angleOffset>
			</north>
			<east>
				<drawOffset>(0.1, 0, 0.42)</drawOffset>
				<angleOffset>-122</angleOffset>
			</east>
			<south>
				<drawOffset>(-0.25, 0, 0.47)</drawOffset>
				<angleOffset>-143</angleOffset>
			</south>
			<west>
				<drawOffset>(-0.1, 0, 0.42)</drawOffset>
				<angleOffset>122</angleOffset>
			</west>
		</weaponDraftedDrawOffsets>
	</li>
</modExtensions>

Mousekin marching with Pike Mousekin attacking rock wall with Pike

General notes:

  • All orientations (north/south/east/west), position and angular offsets are optional, and default to 0,0,0 and 0 degrees respectively
  • Both weaponCarryDrawOffsets and weaponDraftedDrawOffsets can be used simultaneously
  • The offsets apply cumulatively over the base game's existing equippedAngleOffset parameter

Customizing the color of a deep lump for a minable resource/item

For items or resources that can be mined using Deep drills, you can customize the color and transparency of their associated underground deposits detected by the Long-range mineral scanners:

<modExtensions>
	<li Class="VFECore.ThingDefExtension">
		<deepColor>(0.72, 0.29, 0.29)</deepColor> <!-- defaults to white if unspecified -->
		<transparencyMultiplier>0.75</transparencyMultiplier> <!-- defaults to 0.5 if unspecified -->
	</li>
</modExtensions>

VFE Core

General Comp classes

General DefModExtensions

Item Processor

PipeSystem

Custom Structure Generation

Multi Verb Combat Framework - MVCF

Animal Behaviours

Genes

Apparel

Cuisine

Furniture

Plants

Deprecated

Clone this wiki locally