Class GenerationContext
A context object used for map generation. Map generation steps will require and retrieve components that have been added to this context when they need to retrieve data about the map generated by previous steps.
Inherited Members
Namespace: GoRogue.MapGeneration
Assembly: GoRogue.dll
Syntax
public class GenerationContext : ComponentCollection, IComponentCollection, IEnumerable<ComponentTagPair>, IEnumerable
Constructors
View SourceGenerationContext(int, int)
Creates a map context with no components, with the given width/height values.
Declaration
public GenerationContext(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
int | width | The width of the map this context represents. |
int | height | The height of the map this context represents. |
Fields
View SourceHeight
Height of the map this context represents.
Declaration
public readonly int Height
Field Value
Type | Description |
---|---|
int |
Width
Width of the map this context represents.
Declaration
public readonly int Width
Field Value
Type | Description |
---|---|
int |
Methods
View SourceGetFirstOrNew<TComponent>(Func<TComponent>, string?)
Retrieves a context component (optionally with a given tag), or utilizes the specified function to create a new one and adds it if an existing one does not exist.
Declaration
public TComponent GetFirstOrNew<TComponent>(Func<TComponent> newFunc, string? tag = null) where TComponent : class
Parameters
Type | Name | Description |
---|---|---|
Func<TComponent> | newFunc | Function to use to create a new component, if there is no existing component. |
string | tag | An optional tag that must be associated with the retrieved or created component. If null is specified, no tag is associated with a new object, and any object meeting the type requirement will be allowed as the return value. |
Returns
Type | Description |
---|---|
TComponent | An existing component of the appropriate type if one exists, or the newly created/added component if not. |
Type Parameters
Name | Description |
---|---|
TComponent | Type of component to retrieve. |