Skip to content

Healing Materials

RecompiledBirds edited this page Jun 28, 2025 · 2 revisions

Vine allows for the creation of materials that heal themselves, as well as things they're built out of over time.

We will be using RimVali: Far From Avalon's Nanomachines to demonstrate this:

Here is the entire XML for the RVFFA_Nanomachines ThingDef, for reference purposes.

	<ThingDef ParentName="RVFFA_BaseItem">
		<defName>RVFFA_Nanomachines</defName>
		<label>nanomachines</label>
		<comps>
			<li Class= "RVCRestructured.Comps.HealableMaterialCompProperties">
				<amountHealed>10</amountHealed>
				<ticksBetweenHeal>1800</ticksBetweenHeal>
			</li>
		</comps>
		<description>A group of specialised nanomachines, capable of reshaping and reparing themselves.</description>
		<graphicData>
			<texPath>RimValiFFA/Things/Nanomachines/Nanomachines</texPath>
			<graphicClass>Graphic_Single</graphicClass>
			<drawSize>0.85</drawSize>
		</graphicData>
		<statBases>
			<MarketValue>4000</MarketValue>
			<Mass>1.5</Mass>
			<MaxHitPoints>100.0</MaxHitPoints>
			<DeteriorationRate>0.1</DeteriorationRate>
			<StuffPower_Armor_Sharp>3.0</StuffPower_Armor_Sharp>
			<StuffPower_Armor_Blunt>1.9</StuffPower_Armor_Blunt>
			<StuffPower_Armor_Heat>0.9</StuffPower_Armor_Heat>
			<StuffPower_Insulation_Cold>1.3</StuffPower_Insulation_Cold>
			<SharpDamageMultiplier>1.5</SharpDamageMultiplier>
			<BluntDamageMultiplier>1.5</BluntDamageMultiplier>
		</statBases>
		<stuffProps>
			<stuffAdjective>Nanomachine</stuffAdjective>
			<categories>
				<li>Metallic</li>
				<li>Fabric</li>
				<li>Leathery</li>
				<li>Stony</li>
			</categories>
			<commonality>0.0</commonality>
			<color>(255,255,255)</color>
			<constructEffect>ConstructMetal</constructEffect>
			<soundMeleeHitSharp>MeleeHit_Metal_Sharp</soundMeleeHitSharp>
			<soundMeleeHitBlunt>MeleeHit_Metal_Blunt</soundMeleeHitBlunt>
			<statFactors>
				<MaxHitPoints>10.0</MaxHitPoints>
				<Beauty>1.2</Beauty>
				<Flammability>0</Flammability>
				<MarketValue>10.5</MarketValue>
				<WorkToMake>2.2</WorkToMake>
				<WorkToBuild>2.2</WorkToBuild>
			</statFactors>
			<statOffsets>
				<Beauty>4</Beauty>
			</statOffsets>
		</stuffProps>
		<terrainAffordanceNeeded>Medium</terrainAffordanceNeeded>
	</ThingDef>

To make this material self-healing, all we have to do is add the RVCRestructured.Comps.HealableMaterialCompProperties to our comps list.

<li Class= "RVCRestructured.Comps.HealableMaterialCompProperties">
	<amountHealed>10</amountHealed>
	<ticksBetweenHeal>1800</ticksBetweenHeal>
</li>

amountHealed is the amount healed each time the material should heal, and ticksBetweenHeal is the amount of ticks between each heal.

The C# implementation under the hood is designed to have minimal impacts on performance, however extremely large amounts of self-healing objects on the map may still cause stutters at times.

Clone this wiki locally