Searches for tunnels that don't lead anywhere (eg. are surrounded by 3 walls), and removes them from the map. Context Components Required:
|ISettableGridView<T> where T is bool||"WallFloor"|
public class TunnelDeadEndTrimming : GenerationStep
This algorithm iterates over all map areas in the ItemList<TItem> context component with the given tag. For each area, it scans for dead ends (locations that, according to the "WallFloor" component given, are surrounded by 3 walls). For each dead end, if that dead end is not currently and hasn't previously been selected as "saved", based on percentage checks, it proceeds to fill it in. It will remove the dead end location, from the appropriate area, and set the location in the "WallFloor" map to true. It proceeds in this manner until either no more (non-saved) dead ends are found, or the given maximum iterations is reached, then proceeds to the next area in the ItemList until it has processed all of the areas.
TunnelDeadEndTrimming(String, String, String)
Creates a new dead end trimming generation step.
public TunnelDeadEndTrimming(string name = null, string wallFloorComponentTag = "WallFloor", string tunnelsComponentTag = "Tunnels")
The name of the generation step. Defaults to TunnelDeadEndTrimming.
Optional tag that must be associated with the component used to set wall/floor status of tiles changed by this algorithm. Defaults to "WallFloor".
Optional tag that must be associated with the component used to record areas representing tunnels that this algorithm will trim dead ends from. Defaults to "Tunnels".
Maximum number of passes to make looking for dead ends per area. Defaults to infinity.
public int MaxTrimIterations
RNG to use for percentage checks. Defaults to DefaultRNG.
public IEnhancedRandom RNG
The chance out of 100 that a dead end is left alone. Defaults to 40.
public float SaveDeadEndChance
Optional tag that must be associated with the component used to record areas representing tunnels that this algorithm will trim dead ends from.
public readonly string TunnelsComponentTag
Optional tag that must be associated with the component used to set wall/floor status of tiles changed by this algorithm.
public readonly string WallFloorComponentTag
Implement to perform the actual work of the generation step. Use "yield return null" to indicate the end of a "stage", eg. a point where execution can be paused when using GetStageEnumerator().
protected override IEnumerator<object> OnPerform(GenerationContext context)
Context to perform the generation step on.