Show / Hide Table of Contents

Class LayerMasker

Allows convenient interpretation and creation of layer masks (bit-masks) that can be used to interact with LayeredSpatialMap<T> and Map.

Inheritance
System.Object
LayerMasker
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public sealed class LayerMasker
Remarks

A layer mask is simply a list of layers. It is frequently used in LayeredSpatialMap<T> and Map as an optional parameter that indicates what layers should apply to an operation or given set of functionality.

LayeredSpatialMap and Map both define their own LayerMask variable that should be used to retrieve layer masks whenever possible. For layer masks needed outside of that, or when constructing those classes, use DEFAULT. There are also constants defined in LayerMasker to represent "all layers" and "no layers".

Constructors

| Improve this Doc View Source

LayerMasker(Int32)

Constructor. Takes the number of layers allowed, which must be more than 0 and less than or equal to 32.

Declaration
public LayerMasker(int numberOfLayers = 32)
Parameters
Type Name Description
System.Int32 numberOfLayers

The number of layers supported by this layer mask generator.

Fields

| Improve this Doc View Source

ALL_LAYERS

Layer-mask representing all layers.

Declaration
public readonly uint ALL_LAYERS
Field Value
Type Description
System.UInt32
| Improve this Doc View Source

DEFAULT

Default layer masker, that excludes no possible layers from its results.

Declaration
public static readonly LayerMasker DEFAULT
Field Value
Type Description
LayerMasker
| Improve this Doc View Source

NO_LAYERS

Layer mask representing no layers.

Declaration
public readonly uint NO_LAYERS
Field Value
Type Description
System.UInt32

Properties

| Improve this Doc View Source

NumberOfLayers

Maximum number of layers supported by this layer masker. Functions using layer masks enforce this limit, and will not consider layers outside the range [0, NumberOfLayers - 1]

Declaration
public int NumberOfLayers { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

AddLayers(UInt32, IEnumerable<Int32>)

Adds the given layers to the given layer mask, provided those layers are within the supported number of layers. Any layer outside of this range will not be added.

Declaration
public uint AddLayers(uint mask, IEnumerable<int> layers)
Parameters
Type Name Description
System.UInt32 mask

The mask to add the layers to.

System.Collections.Generic.IEnumerable<System.Int32> layers

Layers to include in the resulting layer mask.

Returns
Type Description
System.UInt32

A layer mask including any original layers that were in the given mask (regardless of whether they were within the supported number of layers), as well as the new layers provided (provided they are within the supported number of layers).

| Improve this Doc View Source

AddLayers(UInt32, Int32[])

Adds the given layers to the given layer mask, provided those layers are within the supported number of layers. Any layer outside of this range will not be added.

Declaration
public uint AddLayers(uint mask, params int[] layers)
Parameters
Type Name Description
System.UInt32 mask

The mask to add the layers to.

System.Int32[] layers

Layers to include in the resulting layer mask.

Returns
Type Description
System.UInt32

A layer mask including any original layers that were in the given mask (regardless of whether they were within the supported number of layers), as well as the new layers provided (provided they are within the supported number of layers).

| Improve this Doc View Source

HasLayer(UInt32, Int32)

Returns whether or not a layer is contained within the given layer mask. Returns false if the layer given is outside the supported number of layers.

Declaration
public bool HasLayer(uint mask, int layer)
Parameters
Type Name Description
System.UInt32 mask

Layer mask to check.

System.Int32 layer

Layer to check for.

Returns
Type Description
System.Boolean

True if the given layer is present in the given layer mask, false if it is not or the layer is outside the supported number of layers for this LayerMasker.

| Improve this Doc View Source

Layers(UInt32)

Returns an IEnumerable of all layers contained within the given layer mask (that fall within the supported number of layers).

Declaration
public IEnumerable<int> Layers(uint mask)
Parameters
Type Name Description
System.UInt32 mask

Layer mask to return layers for.

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Int32>

All layers contained within the given layer mask that fall within the supported number of layers for this LayerMasker.

| Improve this Doc View Source

Mask(IEnumerable<Int32>)

Gets a layer mask including exactly the given layer indices. Any layer given outside the maximum number of layers is ignored, and will not be added to the resulting mask.

Declaration
public uint Mask(IEnumerable<int> layers)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Int32> layers

Layers to include in generated layer mask.

Returns
Type Description
System.UInt32

A layer mask including exactly those layers in the input that were within the supported number of layers.

| Improve this Doc View Source

Mask(Int32[])

Gets a layer mask including exactly the given layer indices. Any layer given outside the maximum number of layers is ignored, and will not be added to the resulting mask.

Declaration
public uint Mask(params int[] layers)
Parameters
Type Name Description
System.Int32[] layers

One or more layers to include in generated layer mask.

Returns
Type Description
System.UInt32

A layer mask including exactly those layers in the input that were within the supported number of layers.

| Improve this Doc View Source

MaskAllAbove(Int32)

Generates and returns a layer mask including the given layer and any layer above (greater than) it. Layers not in the supported number of layers will be ignored, and will not be added to the resulting layer mask.

Declaration
public uint MaskAllAbove(int layer)
Parameters
Type Name Description
System.Int32 layer

Layer to start the mask at.

Returns
Type Description
System.UInt32

A layer mask including the specified layer and all layers above it, provided those layers fall within the supported number of layers.

| Improve this Doc View Source

MaskAllBelow(Int32)

Generates and returns a layer mask including the given layer and any layer below (less than) it. Layers not in the supported number of layers will be ignored, and will not be added to the resulting layer mask.

Declaration
public uint MaskAllBelow(int layer)
Parameters
Type Name Description
System.Int32 layer

Layer to start the mask at.

Returns
Type Description
System.UInt32

A layer mask including the specified layer and all layers below it, provided those layers fall within the supported number of layers.

Extension Methods

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