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:
Component | Default Tag |
---|---|
ItemList<TItem> | "Tunnels" |
ISettableGridView<T> where T is bool | "WallFloor" |
Inherited Members
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
View SourceTunnelDeadEndTrimming(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
View SourceMaxTrimIterations
Maximum number of passes to make looking for dead ends per area. Defaults to infinity.
Declaration
public int MaxTrimIterations
Field Value
Type | Description |
---|---|
int |
RNG
RNG to use for percentage checks. Defaults to DefaultRNG.
Declaration
public IEnhancedRandom RNG
Field Value
Type | Description |
---|---|
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 |
---|---|
float |
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
View SourceOnPerform(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> |