PipeSystem basics - AndroidQuazar/VanillaExpandedFramework GitHub Wiki

The goal of this framework is to allow modders to easily create a new pipe system, without any C# coding required. They act similarly to power net: there are producers/users/storages. The framework come with a number of pre-coded utilities. You can easily create building that store, produce, use and convert generated resource to items.

This guide will learn you how to make a pipe network.

Creating the PipeNetDef

This def allows anyone to create a new network type.

<PipeSystem.PipeNetDef>
  <defName>VCHE_ChemfuelNet</defName>
  <!-- Tanks marked for transfer will output the bellow amount each net tick (each 100 game ticks)-->
  <transferAmount>100</transferAmount>
  <resource>
    <!-- This is the name used in all the comps inspect panels -->
    <name>Chemfuel</name>
    <!-- This is the unit, also used in all comps inspect panels -->
    <unit>l</unit>
    <!-- This is the resource color, it will be used by all storages of this net -->
    <color>(0.68, 0.43, 0.19)</color>
    <!-- If this is true, all things connected to net will have this line:
             {name} stored in network: {storedAmount} {unit} 
         Else: {name} excess (stored) in network: {production} {unit}/d ({storedAmount} {unit})
         The latter should only be used if you plan to use CompResourceTrader.
    -->
    <onlyShowStored>True</onlyShowStored>
    <!-- This is the texture that will be used to indicate a building is missing resource -->
    <offTexPath>Things/Item/Resource/Chemfuel</offTexPath>
  </resource>
  <!-- All the pipe defs that can be part of this net -->
  <pipeDefs>
    <li>VCHE_ChemfuelPipe</li>
  </pipeDefs>
  <!-- Automatically create a designator that will only deconstructs net pipe(s) -->
  <designator>
    <!-- Texture-->
    <deconstructIconPath>UI/Gizmos/ChemfuelPipes_Deconstruct</deconstructIconPath>
    <!-- Designation category -->
    <designationCategoryDef>VCHE_PipeNetworks</designationCategoryDef>
  </designator>
  <!-- The overlay show up when you select any building that connect to the net -->
  <overlayOptions>
    <!-- <transmitterAtlas></transmitterAtlas> If you don't want to use the premade atlas -->
    <!-- The color of the overlay -->
    <overlayColor>(0.68, 0.43, 0.19)</overlayColor>
  </overlayOptions>
  <!-- If you want the net to automatically connect and refuel other buildings -->
  <linkToRefuelables>
    <!-- You can add as many as you want -->
    <li>
      <!-- Connect to all chemfuel building -->
      <thing>Chemfuel</thing>
      <!-- 1 in pipenet: 1 when refueling -->
      <ratio>1</ratio>
    </li>
  </linkToRefuelables>
</PipeSystem.PipeNetDef>

Creating pipes

Below is an example of a pipe definition. Every lines that have the ⚠️ symbol is mandatory.

<ThingDef ParentName="BuildingBase">
  <defName>VCHE_ChemfuelPipe</defName>
  <label>chemfuel pipe</label>
  <description>...</description>
  <thingClass>PipeSystem.Building_Pipe</thingClass> ⚠️
  <category>Building</category>
  <graphicData>
    <texPath>Things/Building/Linked/ChemfuelPipes_Atlas</texPath>
    <graphicClass>Graphic_Single</graphicClass>
    <linkType>Basic</linkType> ⚠️
    <!-- Any of the custom link flag. Only used so blueprint connect to buildings -->
    <linkFlags> ⚠️
      <li>Custom7</li>
    </linkFlags>
    <damageData>
      <rect>(0,0.35,1,0.3)</rect>
    </damageData>
  </graphicData>
  <uiIconPath>Things/Building/Linked/ChemfuelPipes_MenuIcon</uiIconPath>
  <uiIconScale>0.7</uiIconScale>
  <building>
    <ai_chillDestination>false</ai_chillDestination>
    <isInert>true</isInert>
    <isEdifice>false</isEdifice>
    <blueprintGraphicData>
      <texPath>Things/Building/Linked/ChemfuelPipes_Blueprint_Atlas</texPath>
    </blueprintGraphicData>
  </building>
  <drawerType>MapMeshOnly</drawerType>
  <altitudeLayer>Conduits</altitudeLayer> ⚠️
  <passability>Standable</passability>
  <leaveResourcesWhenKilled>false</leaveResourcesWhenKilled>
  <statBases>
    <MaxHitPoints>40</MaxHitPoints>
    <WorkToBuild>35</WorkToBuild>
    <Flammability>1.0</Flammability>
  </statBases>
  <placingDraggableDimensions>1</placingDraggableDimensions> ⚠️
  <costList>
    <Steel>2</Steel>
  </costList>
  <comps>
    <li Class="PipeSystem.CompProperties_Resource"> ⚠️
      <pipeNet>VCHE_ChemfuelNet</pipeNet>
    </li>
  </comps>
  <placeWorkers>
    <li>PipeSystem.PlaceWorker_Pipe</li> ⚠️
  </placeWorkers>
  <rotatable>false</rotatable> ⚠️
  <selectable>true</selectable>
  <neverMultiSelect>true</neverMultiSelect>
  <soundImpactDefault>BulletImpact_Metal</soundImpactDefault>
  <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
  <designationCategory>VCHE_PipeNetworks</designationCategory>
  <constructEffect>ConstructMetal</constructEffect>
  <clearBuildingArea>false</clearBuildingArea>
</ThingDef>

Other buildings

Now you are ready to add all the others buildings your net might need:

Put your request here: https://github.com/AndroidQuazar/VanillaExpandedFramework/issues/39

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