Show / Hide Table of Contents

Class BasicRoomsGenerator

Carves out non-overlapping rooms in a map using a basic process of generating a room, and trying to place that room without intersecting another. Generated rooms will not overlap with each other or existing open areas on the given map. Generated rooms will not be connected -- for automatic connection of rooms generated by this algorithm, see GenerateRandomRoomsMap(ISettableMapView<Boolean>, Int32, Int32, Int32, Int32) and overloads.

Inheritance
System.Object
BasicRoomsGenerator
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GoRogue.MapGeneration.Generators
Assembly: GoRogue.dll
Syntax
public static class BasicRoomsGenerator

Methods

| Improve this Doc View Source

Generate(ISettableMapView<Boolean>, Int32, Int32, Int32, Int32)

Generates rooms and adds them to the given map. After this function has been completed, room floor tiles will have a value of true in the map given. The value at wall locations will not be modified from the state in which they were passed in.

Declaration
public static IEnumerable<Rectangle> Generate(ISettableMapView<bool> map, int maxRooms, int roomMinSize, int roomMaxSize, int attemptsPerRoom)
Parameters
Type Name Description
ISettableMapView<System.Boolean> map

The map to set values to.

System.Int32 maxRooms

The maximum number of rooms to attempt to place on the map.

System.Int32 roomMinSize

The minimum size in width and height of each room.

System.Int32 roomMaxSize

The maximum size in width and height of each room.

System.Int32 attemptsPerRoom

The maximum number of times the position of a room will be generated to try to position it properly (eg. without overlapping with other rooms), before simply discarding the room.

Returns
Type Description
System.Collections.Generic.IEnumerable<Rectangle>

A collection of rectangles representing the interior of each generated room.

Remarks

It is guaranteed that the "set" function of the map passed in will only be called once per tile at maximum.

| Improve this Doc View Source

Generate(ISettableMapView<Boolean>, IGenerator, Int32, Int32, Int32, Int32)

Generates rooms and adds them to the given map. After this function has been completed, room floor tiles will have a value of true in the map given. The value at wall locations will not be modified from the state in which they were passed in.

Declaration
public static IEnumerable<Rectangle> Generate(ISettableMapView<bool> map, IGenerator rng, int maxRooms, int roomMinSize, int roomMaxSize, int attemptsPerRoom)
Parameters
Type Name Description
ISettableMapView<System.Boolean> map

The map to set values to.

Troschuetz.Random.IGenerator rng

The RNG to use to place rooms and determine room size. If null is specified, the default RNG is used.

System.Int32 maxRooms

The maximum number of rooms to attempt to place on the map.

System.Int32 roomMinSize

The minimum size in width and height of each room.

System.Int32 roomMaxSize

The maximum size in width and height of each room.

System.Int32 attemptsPerRoom

The maximum number of times the position of a room will be generated to try to position it properly (eg. without overlapping with other rooms), before simply discarding the room.

Returns
Type Description
System.Collections.Generic.IEnumerable<Rectangle>

A collection of rectangles representing the interior of each generated room.

Remarks

It is guaranteed that the "set" function of the map passed in will only be called once per tile at maximum.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX