Class GenerationStep
Base class for implementing custom map generation steps.
Inheritance
Inherited Members
Namespace: GoRogue.MapGeneration
Assembly: GoRogue.dll
Syntax
public abstract class GenerationStep
Constructors
View SourceGenerationStep(string?)
Creates a generation step, optionally with a custom name.
Declaration
protected GenerationStep(string? name = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the generation step being created. Defaults to the name of the (runtime) class. |
GenerationStep(string?, params ComponentTypeTagPair[])
Creates a generation step that requires the given component(s) on the GenerationContext to function.
Declaration
protected GenerationStep(string? name = null, params ComponentTypeTagPair[] requiredComponents)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the generation step being created. Defaults to the name of the (runtime) class. |
ComponentTypeTagPair[] | requiredComponents | Components that OnPerform(GenerationContext) will require from the context, and the tag required for each component. Null means no particular tag is required. |
GenerationStep(string?, params Type[])
Creates a generation step that requires the given component(s) on the GenerationContext to function.
Declaration
protected GenerationStep(string? name = null, params Type[] requiredComponents)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the generation step being created. Defaults to the name of the (runtime) class. |
Type[] | requiredComponents | Components (and associated tags) that OnPerform(GenerationContext) will require from the context. Null specified as a tag means no particular tag is required; only a component of the given type. |
Fields
View SourceName
The name of the generation step.
Declaration
public readonly string Name
Field Value
Type | Description |
---|---|
string |
Properties
View SourceRequiredComponents
Components that are required and enforced to be on the GenerationContext when it is passed to OnPerform(GenerationContext). Each component may optionally have a required tag.
Declaration
public IEnumerable<ComponentTypeTagPair> RequiredComponents { get; }
Property Value
Type | Description |
---|---|
IEnumerable<ComponentTypeTagPair> |
Methods
View SourceGetStageEnumerator(GenerationContext)
Return an enumerator that, when evaluated to completion, will perform each "stage" of the generation step sequentially.
Declaration
public IEnumerator<object?> GetStageEnumerator(GenerationContext context)
Parameters
Type | Name | Description |
---|---|---|
GenerationContext | context | Context to perform the generation step on. |
Returns
Type | Description |
---|---|
IEnumerator<object> | An enumerator which, when evaluated, performs each stage of the step sequentially. |
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 abstract IEnumerator<object?> OnPerform(GenerationContext context)
Parameters
Type | Name | Description |
---|---|---|
GenerationContext | context | Context to perform the generation step on. |
Returns
Type | Description |
---|---|
IEnumerator<object> |
PerformStep(GenerationContext)
Performs the generation step on the given map context. Throws exception if a required component is missing. This function is not virtual -- to implement actual generation logic, implement OnPerform(GenerationContext).
Declaration
public void PerformStep(GenerationContext context)
Parameters
Type | Name | Description |
---|---|---|
GenerationContext | context | Context to perform the generation step on. |