SwappableBuilding - Vanilla-Expanded/VanillaExpandedFramework GitHub Wiki

<- Back

SwappableBuilding creates buildings that can be swapped for another via code

How do I use this code?

First of all, the thingClass of the building needs to be:

       <thingClass>VEF.Buildings.SwappableBuilding</thingClass>

Second of all (the hard part), you need to make a C# class that calls the Notify_Swap method of SwappableBuilding. For example, this is the code that tells the silo traps in Vanilla Quests Expanded - Deadlife to come alive (irrelevant lines removed):

if (building is VEF.Buildings.SwappableBuilding swappable)
{  
    swappable.Notify_Swap();
}

Thirdly, you need a mod extension that tells details to the main class what to pop up when the building is opened. This mod extension is SwappableBuildingDetails

    public ThingDef buildingLeft = null;
    public SoundDef deconstructSound = null;

Please, I beg you, a crumb of example

Here is the def extension of one of the traps mentioned:

<modExtensions>
	<li Class="VEF.Buildings.SwappableBuildingDetails">
		<buildingLeft>VQED_DeathPit</buildingLeft>
		<deconstructSound>VQED_AncientDoorSeal</deconstructSound>
	</li>
</modExtensions>
⚠️ **GitHub.com Fallback** ⚠️