CompProperties_ResourceStorage - Vanilla-Expanded/VanillaExpandedFramework GitHub Wiki

This comp can be added to any building. It allows said building to connect to other buildings in the net and act as storage.

Basic

Below, an example of the comp, the building do not need to tick (🟢 mean it default to true).

<li Class="PipeSystem.CompProperties_ResourceStorage">
  <!-- Accept a PipeNetDef -->
  <pipeNet>VCHE_ChemfuelNet</pipeNet>
  <!-- Amount that can be stored -->
  <storageCapacity>1500</storageCapacity>
  <!-- False if you don't want the storage bar to show -->
  <drawStorageBar>True</drawStorageBar> 🟢
  <!-- False if you don't want the storage info to show in inspect tab -->
  <addStorageInfo>True</addStorageInfo> 🟢
  <!-- False if player shouldn't be able to transfer content to other comps -->
  <addTransferGizmo>True</addTransferGizmo> 🟢
  <!-- Lenght and Width of the bar -->
  <barSize>(1.3, 0.25)</barSize>
  <!-- 0 mean there is no bar outline -->
  <margin>0.1</margin>
  <!-- Bar center offset -->
  <centerOffset>(0, 0, 0.35)</centerOffset>
  <!-- False if the bar should be horizontal, true if it should be vertical -->
  <barHorizontal>false</barHorizontal>
  <!-- False if the bar shouldn't rotate together with the building, true if it should -->
  <rotateBarWithBuilding>true</rotateBarWithBuilding> 🟢
  <!-- True if the contents can spoil when unpowered, and the storage won't accept anymore stuff if it's unpowered -->
  <!-- Requires the storage to use any ticker type -->
  <contentRequirePower>false</contentRequirePower>
  <!-- True if the contents spoiling time is paused while held in a freezer (under 0°C/32°F) -->
  <preventRotInNegativeTemp>true</preventRotInNegativeTemp> 🟢
  <!-- How many days it will take for the contents to spoil without power -->
  <daysToRotStart>0.75</daysToRotStart>
  <!-- Only use this if you want the player to be able to tell pawn to extract stuff -->
  <extractOptions>
    <!-- Extract gizmo icon -->
    <texPath>UI/Gizmos/ExtractChemfuel</texPath>
    <!-- Those need to be translation key -->
    <labelKey>VCHE_ExtractChemfuel</labelKey>
    <descKey>VCHE_ExtractChemfuelDesc</descKey>
    <!-- Optional. Reason for why the gizmo is disabled. -->
    <disabledReasonKey>VCHE_ExtractChemfuelDisabledReason</disabledReasonKey>
    <!-- The amount extracted -->
    <!-- Negative values will be treated as maximum possible value -->
    <extractAmount>150</extractAmount>
    <!-- The amount of ticks it take to extract (supports fractions, but will be rounded to an integer) -->
    <extractTime>150</extractTime>
    <!-- True if only allowed to extract exact amount, false if any amount (at least 1) under the specified extractAmount can be extracted -->
    <extractExactAmount>false</extractExactAmount>
    <!-- True if extractTime will be multiplied by the amount extracted -->
    <extractTimeScalesWithAmount>false</extractTimeScalesWithAmount> 🟢
    <!-- The thing spawned after extract -->
    <thing>Chemfuel</thing>
    <!-- 1 spawned, 1*X less in the grid (supports fractions) -->
    <ratio>X</ratio>
  </extractOptions>
  <refillOptions>
    <!-- If true, will always be refilled by pawns. -->
    <!-- If false, allow user to enable/disable tank refill -->
    <alwaysRefill>false</alwaysRefill>
    <!-- Number of ticks needed to refill (supports fractions, but will be rounded to an integer) -->
    <refillTime>150</refillTime>
    <!-- True if refillTime will be multiplied by the amount refilled -->
    <refillTimeScalesWithAmount>false</refillTimeScalesWithAmount>
    <!-- Thing to refill with -->
    <thing>Chemfuel</thing>
    <!-- 1 used, 1*X more in the grid (supports fractions) -->
    <ratio>X</ratio>
  </refillOptions>
  <!-- Use this if you want filth to be spawned when the storage is destroyed -->
  <!-- For now you can still use <destroyOption> tag, but it may be removed in the future -->
  <destroyOptions>
    <li>
      <!-- Thing to spawn - supports items, building, or filth -->
      <!-- For compatibility reasons, you can still use <filth> tag (although it's recommended to use <thing>) -->
      <thing>VNPE_Filth_Paste</thing>
      <!-- Amount to spawn: X/ratio + amount, or only amount if ratio is 0 (ratio supports fractions) -->
      <ratio>1</ratio>
      <amount>0</amount>
      <!-- Maximum distance from the center of the destroyed building at which the thing will spawn -->
      <!-- Required for filth, optional for items/buildings (treated as unlimited range) -->
      <maxRadius>4</maxRadius>
      <!-- True if the thing should be spawned when the storage is deconstructed by a pawn -->
      <spawnWhenDeconstructed>true</spawnWhenDeconstructed> 🟢
      <!-- True if the thing should be spawned when the storage is destroyed -->
      <spawnWhenDestroyed>true</spawnWhenDestroyed> 🟢
      <!-- True if the thing should be spawned when the storage building is refunded (for example, if pit gate starts opening under it) -->
      <!-- It's a separate option from others in case we only give partial refund when deconstructed/destroyed, while full one for actual refund -->
      <spawnWhenRefunded>true</spawnWhenRefunded> 🟢
      <!-- When thing to spawn is a building, this determines if it should be spawned as a minified thing (if possible) or a building -->
      <spawnMinified>true</spawnMinified> 🟢
    </li>
    <li>
      <!-- Additional things that can be spawned when destroyed -->
    </li>
  </destroyOptions>
</li>

You will also need to add to your def:

  • If drawStorageBar is True:
    • <drawerType>MapMeshAndRealTime</drawerType>
  • If contentRequirePower is True:
    • <tickerType>Normal</tickerType> or <tickerType>Rare</tickerType> or <tickerType>Long</tickerType>

Additional translation key arguments

When using <extractOptions>, the <labelKey>, <descKey>, and <disabledReasonKey> will receive the following arguments that may be used:

  • {0} or {RESOURCEMIN} - the minimum amount of resource that's needed to extract it.
  • {1} or {RESOURCECOUNT} - the current amount of resource in storage.
  • {2} or {RESOURCEEXTRACTCOUNT} - the amount of resource that would be extracted to match the current {THINGCOUNT} count.
  • {3} or {RESOURCEMAX} - the maximum amount of resource we can extract at a time.
  • {4} or {THINGMIN} - the minimum amount of items we can extract.
  • {5} or {THINGCOUNT} - the current amount of items in storage.
  • {6} or {THINGEXTRACTCOUNT} - the current amount of items we can extract (same as above, included for consistency).
  • {7} or {THINGMAX} - the maximum amount of items we can extract at a time.

If using <ratio>1</ratio> all of those (besides {RESOURCEEXTRACTCOUNT}) will match 1-to-1. If using <extractExactAmount>true</extractExactAmount>, {RESOURCEMIN}/{THINGMIN} will match {RESOURCEMAX}/{THINGMAX}.

Linked comp

If you want the storage to explode when damaged, and the explosion size scaling with how full the storage is, you can use the CompProperties_ExplosiveContent comp.

<li Class="PipeSystem.CompProperties_ExplosiveContent">
  <!-- 1.5 when empty, 12 when full. Min radius is optional and starts at 0 if unspecified. -->
  <!-- You can swap those around so min radius is higher than max radius, making explosions smaller the more content there is in the container. -->
  <explosiveMaxRadius>12</explosiveMaxRadius>
  <explosiveMinRadius>1.5</explosiveMinRadius>
  <!-- The minimum radius an explosion needs to actually happen. Useful for preventing explosions when content is almost empty. -->
  <radiusRequiredForExplosion>2.5</radiusRequiredForExplosion>
  <!-- Vanilla options below -->
  <explosiveDamageType>Flame</explosiveDamageType>
  <destroyThingOnExplosionSize>2</destroyThingOnExplosionSize>
  <startWickHitPointsPercent>0.333</startWickHitPointsPercent>
  <preExplosionSpawnThingDef>Filth_Fuel</preExplosionSpawnThingDef>
  <preExplosionSpawnChance>1</preExplosionSpawnChance>
  <wickTicks>70~150</wickTicks>
</li>

Advanced usage

If your building have this comp. Use the GetComp<CompResourceStorage>() method. Then you have access to everything inherited from CompProperties_Resource;

⚠️ **GitHub.com Fallback** ⚠️