Show / Hide Table of Contents

Class RoomsGeneration

Carves out non-overlapping rooms in a map. Rooms generated will not overlap with themselves, or any existing open areas in the map.

Context Components Required: None

Context Components Added/Used:

ComponentDefault TagDescription
ItemList<Rectangle> "Rooms"A list of Rectangle instances which denote the rooms that were created.
ISettableGridView<bool>"WallFloor"A grid view of boolean values the size of the map where "true" indicates a tile is passable, and "false" indicates it is not.

In the case of both components, existing components are used if they are present; new ones are added if not.

Inheritance
object
GenerationStep
RoomsGeneration
Inherited Members
GenerationStep.Name
GenerationStep.PerformStep(GenerationContext)
GenerationStep.GetStageEnumerator(GenerationContext)
GenerationStep.RequiredComponents
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: GoRogue.MapGeneration.Steps
Assembly: GoRogue.dll
Syntax
public class RoomsGeneration : GenerationStep
Remarks

This generation step generates rooms, and adds the rooms generated to the ItemList<Rectangle> context component with the given tag in the GenerationContext. If such a component does not exist, a new one is created. It also sets the interior positions to true in the map context's grid view with the given tag. If the GenerationContext has an existing grid view context component, with the appropriate tag, that component is used. If not, an ArrayView<bool> is created and added to the map context, whose width/height match Width/Height.

Constructors

View Source

RoomsGeneration(string?, string?, string?)

Creates a new rooms generation step.

Declaration
public RoomsGeneration(string? name = null, string? roomsComponentTag = "Rooms", string? wallFloorComponentTag = "WallFloor")
Parameters
Type Name Description
string name

The name of the generation step. Defaults to RoomsGeneration.

string roomsComponentTag

Optional tag that must be associated with the component used to store rooms. Defaults to "Rooms".

string wallFloorComponentTag

Optional tag that must be associated with the map view component used to store/set floor/wall status. Defaults to "WallFloor".

Fields

View Source

MaxCreationAttempts

The maximum times to re-generate a room that fails to place in a valid location before giving up on generating that room entirely. Defaults to 10.

Declaration
public int MaxCreationAttempts
Field Value
Type Description
int
View Source

MaxPlacementAttempts

The maximum times to attempt to place a room in a map without intersection, before giving up and re-generating that room. Defaults to 10.

Declaration
public int MaxPlacementAttempts
Field Value
Type Description
int
View Source

MaxRooms

Maximum amount of rooms to generate. Defaults to 10.

Declaration
public int MaxRooms
Field Value
Type Description
int
View Source

MinRooms

Minimum amount of rooms to generate. Defaults to 4.

Declaration
public int MinRooms
Field Value
Type Description
int
View Source

RNG

RNG to use for room creation/placement.

Declaration
public IEnhancedRandom RNG
Field Value
Type Description
IEnhancedRandom
View Source

RoomMaxSize

The maximum size allowed for rooms. Rounded up to an odd number. Defaults to 7.

Declaration
public int RoomMaxSize
Field Value
Type Description
int
View Source

RoomMinSize

The minimum size allowed for rooms. Rounded up to an odd number. Defaults to 3.

Declaration
public int RoomMinSize
Field Value
Type Description
int
View Source

RoomSizeRatioX

The ratio of the room width compared to a base generated size. Defaults to 1.0.

Declaration
public float RoomSizeRatioX
Field Value
Type Description
float
View Source

RoomSizeRatioY

The ratio of the room height to a base generated size. Defaults to 1.0.

Declaration
public float RoomSizeRatioY
Field Value
Type Description
float
View Source

RoomsComponentTag

Optional tag that must be associated with the component used to store rooms generated by this algorithm.

Declaration
public readonly string? RoomsComponentTag
Field Value
Type Description
string
View Source

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 Source

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)
  • View Source
In this article
Back to top Generated by DocFX