Show / Hide Table of Contents

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.

Inheritance
object
ComponentCollection
GenerationContext
Implements
IComponentCollection
IEnumerable<ComponentTagPair>
IEnumerable
Inherited Members
ComponentCollection.Add<T>(T, string)
ComponentCollection.Clear()
ComponentCollection.Remove(object)
ComponentCollection.Remove(params object[])
ComponentCollection.Remove(string)
ComponentCollection.Remove(params string[])
ComponentCollection.Contains(params Type[])
ComponentCollection.Contains(params ComponentTypeTagPair[])
ComponentCollection.Contains(Type, string)
ComponentCollection.Contains<T>(string)
ComponentCollection.GetFirstOrDefault<T>(string)
ComponentCollection.GetFirst<T>(string)
ComponentCollection.GetAll<T>()
ComponentCollection.GetEnumerator()
ComponentCollection.Count
ComponentCollection.ParentForAddedComponents
ComponentCollection.ComponentAdded
ComponentCollection.ComponentRemoved
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: GoRogue.MapGeneration
Assembly: GoRogue.dll
Syntax
public class GenerationContext : ComponentCollection, IComponentCollection, IEnumerable<ComponentTagPair>, IEnumerable

Constructors

View Source

GenerationContext(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 Source

Height

Height of the map this context represents.

Declaration
public readonly int Height
Field Value
Type Description
int
View Source

Width

Width of the map this context represents.

Declaration
public readonly int Width
Field Value
Type Description
int

Methods

View Source

GetFirstOrNew<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.

Implements

IComponentCollection
IEnumerable<T>
IEnumerable

Extension Methods

Utility.Yield<T>(T)
  • View Source
In this article
Back to top Generated by DocFX