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 Tag
ItemList<TItem> "Rooms"
ISettableGridView<T> where T is bool"WallFloor"
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
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<TItem> 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 map view with the given tag. If the GenerationContext has an existing map view context component, that component is used. If not, an ArrayView<T> where T is bool is created and added to the map context, whose width/height match Width/Height.

Constructors

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

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
Int32

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
Int32

MaxRooms

Maximum amount of rooms to generate. Defaults to 10.

Declaration
public int MaxRooms
Field Value
Type Description
Int32

MinRooms

Minimum amount of rooms to generate. Defaults to 4.

Declaration
public int MinRooms
Field Value
Type Description
Int32

RNG

RNG to use for room creation/placement.

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

RoomMaxSize

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

Declaration
public int RoomMaxSize
Field Value
Type Description
Int32

RoomMinSize

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

Declaration
public int RoomMinSize
Field Value
Type Description
Int32

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

RoomSizeRatioX

The ratio of the room width to the height. Defaults to 1.0.

Declaration
public float RoomSizeRatioX
Field Value
Type Description
Single

RoomSizeRatioY

The ratio of the room height to the width. Defaults to 1.0.

Declaration
public float RoomSizeRatioY
Field Value
Type Description
Single

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