Class ClosestMapAreaConnection
Connects areas of the map by connecting each area to its closest neighboring area, with distance between areas based on the connection point selector specified. Context Components Required:
Component | Default Tag |
---|---|
ItemList<TItem> | "Areas" |
ISettableGridView<T> where T is bool | "WallFloor" |
Component | Default Tag |
---|---|
ItemList<TItem> | "Tunnels" |
Inherited Members
Namespace: GoRogue.MapGeneration.Steps
Assembly: GoRogue.dll
Syntax
public class ClosestMapAreaConnection : GenerationStep
Remarks
This generation steps takes as input a ItemList<TItem> context component (with the tag "Areas", by default) containing areas to connect, and "WallFloor" map view context component that indicates wall/floor status for each location on the map. It then connects the map areas in the list, generating tunnels in the process. Each location comprising the generated tunnels is set to "true" in the "WallFloor" component. Additionally, an Area representing each tunnel created is added to the ItemList<TItem> context component (with the tag "Tunnels", by default). If an appropriate component with the specified tag exists for the resulting tunnels, the Areas are added to that component. Otherwise, a new component is created. Areas are connected by drawing a tunnel between each Area and its closest neighboring area, based on distance between the points selected by the given ConnectionPointSelector. The actual points selected in each area to connect, as well as the method for drawing tunnels between those areas, is customizable via the ConnectionPointSelector and TunnelCreator parameters.
Constructors
View SourceClosestMapAreaConnection(string?, string?, string?, string?)
Creates a new closest area connection step.
Declaration
public ClosestMapAreaConnection(string? name = null, string? wallFloorComponentTag = "WallFloor", string? areasComponentTag = "Areas", string? tunnelsComponentTag = "Tunnels")
Parameters
Type | Name | Description |
---|---|---|
string | name |
|
string | wallFloorComponentTag | Optional tag that must be associated with the map view component used to store/set floor/wall status. Defaults to "WallFloor". |
string | areasComponentTag | Optional tag that must be associated with the component used to store map areas connected by this algorithm. Defaults to "Areas". |
string | tunnelsComponentTag | Optional tag that must be associated with the component created/used to store the tunnels created by this connection method. Defaults to "Tunnels". |
Fields
View SourceAreasComponentTag
Optional tag that must be associated with the component used to store map areas connected by this algorithm.
Declaration
public readonly string? AreasComponentTag
Field Value
Type | Description |
---|---|
string |
ConnectionPointSelector
The area connection strategy to use. Not all methods function on maps with concave areas -- see respective class documentation for details.
Declaration
public IConnectionPointSelector ConnectionPointSelector
Field Value
Type | Description |
---|---|
IConnectionPointSelector |
DistanceCalc
The distance calculation that defines distance/neighbors.
Declaration
public Distance DistanceCalc
Field Value
Type | Description |
---|---|
Distance |
TunnelCreator
The tunnel creation strategy to use. Defaults to DirectLineTunnelCreator with the cardinal adjacency rules.
Declaration
public ITunnelCreator TunnelCreator
Field Value
Type | Description |
---|---|
ITunnelCreator |
TunnelsComponentTag
Optional tag that must be associated with the component created/used to store the tunnels created by this connection method.
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> |