LootableBuilding - Vanilla-Expanded/VanillaExpandedFramework GitHub Wiki
LootableBuilding creates lootable buildings that use base game IOpenable interface, which automatically handles the gizmo, the workgivers, the jobdrivers, etc.
First of all, the thingClass of the building needs to be:
<thingClass>VEF.Buildings.LootableBuilding</thingClass>
Secondly, you need a mod extension that tells the main class what to pop up when the building is opened. This mod extension is LootableBuildingDetails
public bool randomFromContents = false;
public IntRange totalRandomLoops = new IntRange(1, 1);
public List<ThingAndCount> contents = null;
public ThingDef buildingLeft = null;
public SoundDef deconstructSound = null;
public string gizmoTexture; //Ignored by this class
public string gizmoText; //Ignored by this class
public string gizmoDesc; //Ignored by this class
public string cancelLootingGizmoTexture; //Ignored by this class
public string cancelLootinggizmoText; //Ignored by this class
public string cancelLootinggizmoDesc; //Ignored by this class
public string requiredMod = "";
public string overlayTexture;
ThingAndCount is a container class:
public class ThingAndCount
{
public ThingDef thing;
public int count = 1;
}
These are the lootable crates from our Quests mods:
<modExtensions>
<li Class="VEF.Buildings.LootableBuildingDetails">
<contents>
<li Name="BasicCarParts">
<thing>ComponentIndustrial</thing>
<count>8</count>
</li>
</contents>
<buildingLeft>VQED_EmptyMilitaryPallet</buildingLeft>
</li>
</modExtensions>
Here is a more complex one with random contents:
<modExtensions>
<li Class="VEF.Buildings.LootableBuildingDetails">
<contents>
<li>
<thing>VQED_Gun_Autopistol_Ancient</thing>
<count>1</count>
</li>
<li>
<thing>VQED_Gun_MachinePistol_Ancient</thing>
<count>1</count>
</li>
<li>
<thing>VQED_Gun_PumpShotgun_Ancient</thing>
<count>1</count>
</li>
<li>
<thing>VQED_Gun_LMG_Ancient</thing>
<count>1</count>
</li>
</contents>
<randomFromContents>true</randomFromContents>
<totalRandomLoops>1~1</totalRandomLoops>
<buildingLeft>VQED_EmptyAncientWeaponBox</buildingLeft>
</li>
</modExtensions>