Terrain Based Place Worker - KonradHeinser/EBSGFramework GitHub Wiki

An independent version of the place worker found in the Gatherer Spot comp. This place worker allows for conditions to be set up that check the terrain on and around the placement spot, and prevents placement on that terrain when conditions aren't me. The following things need to be added to the ThingDef to set up these conditions:

        <placeWorkers>
            <li>EBSGFramework.PlaceWorker_EBSGPlaceworker</li>
        </placeWorkers>

        <comps>
            <li Class="EBSGFramework.CompProperties_EBSGPlaceworker">
            </li>
        </comps>

All of these tags can be used in the comp to set up the conditions:

  • nearbyWaterTilesNeeded : Default (0) : Creates requirement that there be water nearby for this option to be valid. If set to -1, it requires that there be no water within the specified range
  • maxWaterDistance : Default (1.9) : How far to look for water
  • nearbyTerrainsNeeded : An li of li's that requires one of each sub-li be met for the option to be valid. For an example of this headache generator, I've added a mini example below that requires the building be placed next to a water source that isn't an ocean, and must be on or next to soil, rich soil, or sand
    • li : This is the only tag available directly within nearbyTerrainsNeeded. Each li at this level is a separate set of conditions that must be met
      • li : Condition to check
        • terrain : The TerrainDef to check for
        • count : Default (1) : How many need to be in the area. If set to 0 or lower, then this will check that none of the terrain is in the area
        • maxDistance : Default (10) : The size of the area to check
        <comps>
            <li Class="EBSGFramework.CompProperties_EBSGPlaceworker">
                <nearbyWaterTilesNeeded>2</nearbyWaterTilesNeeded>
                <maxWaterDistance>3.9</maxWaterDistance>
                <nearbyTerrainsNeeded>
                    <li>
                        <li> <!--Can't be near an ocean-->
                            <terrain>WaterOceanShallow</terrain>
                            <count>0</count>
                            <maxDistance>5</maxDistance>
                        </li>
                    </li>
                    <li> <!--Needs to be on or next to certain types of terrain-->
                        <li>
                            <terrain>Soil</terrain>
                            <count>1</count>
                            <maxDistance>0.9</maxDistance>
                        </li>
                        <li>
                            <terrain>SoilRich</terrain>
                            <count>1</count>
                            <maxDistance>0.9</maxDistance>
                        </li>
                        <li>
                            <terrain>Sand</terrain>
                            <count>1</count>
                            <maxDistance>0.9</maxDistance>
                        </li>
                    </li>
                </nearbyTerrainsNeeded>
            </li>
        </comps>
⚠️ **GitHub.com Fallback** ⚠️