Show / Hide Table of Contents

Class TunnelDeadEndTrimming

Searches for tunnels that don't lead anywhere (eg. are surrounded by 3 walls), and removes them from the map. Context Components Required:

ComponentDefault Tag
ItemList<TItem> "Tunnels"
ISettableGridView<T> where T is bool"WallFloor"
Context Components Added: - None
Inheritance
Object
GenerationStep
TunnelDeadEndTrimming
Inherited Members
GenerationStep.Name
GenerationStep.PerformStep(GenerationContext)
GenerationStep.GetStageEnumerator(GenerationContext)
GenerationStep.RequiredComponents
Namespace: GoRogue.MapGeneration.Steps
Assembly: GoRogue.dll
Syntax
public class TunnelDeadEndTrimming : GenerationStep
Remarks

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.

Constructors

TunnelDeadEndTrimming(String, String, String)

Creates a new dead end trimming generation step.

Declaration
public TunnelDeadEndTrimming(string name = null, string wallFloorComponentTag = "WallFloor", string tunnelsComponentTag = "Tunnels")
Parameters
Type Name Description
String name

The name of the generation step. Defaults to TunnelDeadEndTrimming.

String wallFloorComponentTag

Optional tag that must be associated with the component used to set wall/floor status of tiles changed by this algorithm. Defaults to "WallFloor".

String tunnelsComponentTag

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".

Fields

MaxTrimIterations

Maximum number of passes to make looking for dead ends per area. Defaults to infinity.

Declaration
public int MaxTrimIterations
Field Value
Type Description
Int32

RNG

RNG to use for percentage checks. Defaults to DefaultRNG.

Declaration
public IEnhancedRandom RNG
Field Value
Type Description
ShaiRandom.Generators.IEnhancedRandom

SaveDeadEndChance

The chance out of 100 that a dead end is left alone. Defaults to 40.

Declaration
public float SaveDeadEndChance
Field Value
Type Description
Single

TunnelsComponentTag

Optional tag that must be associated with the component used to record areas representing tunnels that this algorithm will trim dead ends from.

Declaration
public readonly string TunnelsComponentTag
Field Value
Type Description
String

WallFloorComponentTag

Optional tag that must be associated with the component used to set wall/floor status of tiles changed by this algorithm.

Declaration
public readonly string WallFloorComponentTag
Field Value
Type Description
String

Methods

OnPerform(GenerationContext)

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().

Declaration
protected override IEnumerator<object> OnPerform(GenerationContext context)
Parameters
Type Name Description
GenerationContext context

Context to perform the generation step on.

Returns
Type Description
IEnumerator<Object>
Overrides
GenerationStep.OnPerform(GenerationContext)

Extension Methods

Utility.Yield<T>(T)
In This Article
Back to top Generated by DocFX