Show / Hide Table of Contents

Class MultiArea

A class implementing the IReadOnlyMultiArea interface, that derives its area from multiple "sub-areas".

Inheritance
object
MultiArea
Implements
IReadOnlyMultiArea
IReadOnlyArea
IMatchable<IReadOnlyArea>
IEnumerable<Point>
IEnumerable
Inherited Members
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 MultiArea : IReadOnlyMultiArea, IReadOnlyArea, IMatchable<IReadOnlyArea>, IEnumerable<Point>, IEnumerable

Constructors

View Source

MultiArea()

Creates an area with no points/subareas.

Declaration
public MultiArea()
View Source

MultiArea(IReadOnlyArea)

Creates a MultiArea that has only the given sub-area.

Declaration
public MultiArea(IReadOnlyArea area)
Parameters
Type Name Description
IReadOnlyArea area

Sub-area to add.

View Source

MultiArea(IEnumerable<IReadOnlyArea>)

Creates a multi-area that is comprised of the given sub-areas.

Declaration
public MultiArea(IEnumerable<IReadOnlyArea> areas)
Parameters
Type Name Description
IEnumerable<IReadOnlyArea> areas

Sub-areas to add.

Properties

View Source

Bounds

Smallest possible rectangle that encompasses every position in every sub-area.

Declaration
public Rectangle Bounds { get; }
Property Value
Type Description
Rectangle
View Source

Count

Number of positions in all of this area's sub-areas combined.

Declaration
public int Count { get; }
Property Value
Type Description
int
View Source

this[int]

Returns positions from the area (via its sub-areas) in the same fashion you would via a list.

Declaration
public Point this[int index] { get; }
Parameters
Type Name Description
int index

Index of position to retrieve.

Property Value
Type Description
Point
Remarks

The indexing scheme considers index 0 to be index 0 in the first sub-area in SubAreas. The indices proceed in increasing order across all points in that sub-area, then roll over into the next one. Eg. index [SubAreas[0].Count] is actually index 0 in the second sub-area, ie. SubAreas[1][0].

View Source

SubAreas

List of all sub-areas in the MultiArea.

Declaration
public IReadOnlyList<IReadOnlyArea> SubAreas { get; }
Property Value
Type Description
IReadOnlyList<IReadOnlyArea>
View Source

UseIndexEnumeration

Whether or not it is more efficient for this implementation to use enumeration by index, rather than generic IEnumerable, when iterating over positions using ReadOnlyAreaPositionsEnumerator.

Declaration
public bool UseIndexEnumeration { get; }
Property Value
Type Description
bool
Remarks

Set this to true if your indexer implementation scales well (constant time), and is relatively fast. Implementations with more complex indexers should set this to false.

The default interface implementation returns false, in order to preserve backwards compatibility with previous versions.

If you set this to false, your IEnumerable.GetEnumerator() implementations must NOT call return a ReadOnlyAreaPositionsEnumerator, as this will create an infinite loop.

Methods

View Source

Add(IReadOnlyArea)

Adds the given sub-area to the MultiArea.

Declaration
public void Add(IReadOnlyArea subArea)
Parameters
Type Name Description
IReadOnlyArea subArea

The sub-area to add.

View Source

AddRange(IEnumerable<IReadOnlyArea>)

Adds the given sub-areas to the MultiArea.

Declaration
public void AddRange(IEnumerable<IReadOnlyArea> subAreas)
Parameters
Type Name Description
IEnumerable<IReadOnlyArea> subAreas

The sub-areas to add.

View Source

Clear()

Clears all sub-areas from the MultiArea.

Declaration
public void Clear()
View Source

Contains(IReadOnlyArea)

Returns whether or not the given area is completely contained within the summation of this area's subareas.

Declaration
public bool Contains(IReadOnlyArea area)
Parameters
Type Name Description
IReadOnlyArea area

Area to check.

Returns
Type Description
bool

True if the all of the given area's points are contained within one or more subareas, false otherwise.

View Source

Contains(Point)

Determines whether or not the given position is considered within one of this area's subareas or not.

Declaration
public bool Contains(Point position)
Parameters
Type Name Description
Point position

The position to check.

Returns
Type Description
bool

True if the specified position is within one of the subareas, false otherwise.

View Source

Contains(int, int)

Determines whether or not the given position is considered within one of this area's subareas or not.

Declaration
public bool Contains(int positionX, int positionY)
Parameters
Type Name Description
int positionX

X-value of the position to check.

int positionY

X-value of the position to check.

Returns
Type Description
bool

True if the specified position is within one of the subareas, false otherwise.

View Source

GetEnumerator()

Returns an enumerator that iterates through all positions in all sub-areas.

Declaration
public IEnumerator<Point> GetEnumerator()
Returns
Type Description
IEnumerator<Point>

An enumerator that iterates through all positions in all sub-areas.

View Source

Intersects(IReadOnlyArea)

Returns whether or not the given map area intersects any of this area's subareas. If you intend to determine/use the exact intersection based on this return value, it is best to instead call GetIntersection(IReadOnlyArea, IReadOnlyArea, IEqualityComparer<Point>), and check the number of positions in the result (0 if no intersection).

Declaration
public bool Intersects(IReadOnlyArea area)
Parameters
Type Name Description
IReadOnlyArea area

The area to check.

Returns
Type Description
bool

True if the given area intersects one of the current one's subareas, false otherwise.

View Source

Matches(IReadOnlyArea?)

Compares for equality. Returns true if the two areas contain exactly the same points.

Declaration
public bool Matches(IReadOnlyArea? other)
Parameters
Type Name Description
IReadOnlyArea other
Returns
Type Description
bool

True if the areas contain exactly the same points, false otherwise.

View Source

Remove(IReadOnlyArea)

Removes the given sub-area from the MultiArea.

Declaration
public void Remove(IReadOnlyArea subArea)
Parameters
Type Name Description
IReadOnlyArea subArea

The sub-area to remove.

Implements

IReadOnlyMultiArea
IReadOnlyArea
IMatchable<T>
IEnumerable<T>
IEnumerable

Extension Methods

Utility.Yield<T>(T)
LineHelpers.BottomAt(IEnumerable<Point>, int)
LineHelpers.LeftAt(IEnumerable<Point>, int)
LineHelpers.RightAt(IEnumerable<Point>, int)
LineHelpers.TopAt(IEnumerable<Point>, int)
  • View Source
In this article
Back to top Generated by DocFX