Struct LayerMaskEnumerator
A type designed to be returned from Layers(uint) in order to enumerate over a set of layers in a layer mask efficiently.
Inherited Members
Namespace: SadRogue.Primitives.SpatialMaps
Assembly: TheSadRogue.Primitives.dll
Syntax
public struct LayerMaskEnumerator : IEnumerator<int>, IEnumerator, IDisposable, IEnumerable<int>, IEnumerable
Remarks
This type is a struct, and as such is much more efficient than using the otherwise equivalent type of IEnumerable<int> with "yield return". The type does also implement IEnumerable<T>, so it can be used with functions that require one (like System.LINQ); however using this function is not recommended in situations where runtime performance is a primary concern.
This iterator will enumerate the layers in reverse order; ie. highest active number to lowest active number.
Constructors
View SourceLayerMaskEnumerator(uint, int)
Constructs a new enumerator.
Declaration
public LayerMaskEnumerator(uint mask, int numLayers)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | mask | Layer mask to enumerate. |
| int | numLayers | Number of layers to be considered within the mask. |
Properties
View SourceCurrent
The current value for enumeration.
Declaration
public int Current { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
View SourceGetEnumerator()
Returns this enumerator.
Declaration
public LayerMaskEnumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| LayerMaskEnumerator | This enumerator. |
MoveNext()
Advances the iterator to the next active layer.
Declaration
public bool MoveNext()
Returns
| Type | Description |
|---|---|
| bool | True if an active layer was found; false otherwise. |