Class LayeredSpatialMap<T>
ISpatialMap<T> implementation that can be used to efficiently represent multiple "layers" of objects, with each layer represented as an ISpatialMap<T> instance. It provides the regular spatial map functionality, as well as adds layer masking functionality that allow functions to operate on specific layers only.
Implements
Inherited Members
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public class LayeredSpatialMap<T> : AdvancedLayeredSpatialMap<T>, ISpatialMap<T>, IReadOnlyLayeredSpatialMap<T>, IReadOnlySpatialMap<T>, IEnumerable<ISpatialTuple<T>>, IEnumerable where T : class, IHasLayer, IHasID
Type Parameters
Name | Description |
---|---|
T | Type of items stored in the layers. Type T must implement IHasID and IHasLayer, must be a reference type, and its Layer value MUST NOT change while the item is in the spatial map. |
Remarks
See the ISpatialMap<T> for documentation on the practical purpose of spatial maps.
The objects stored in a LayeredSpatialMap must be reference types and implement both IHasID and IHasLayer. Each object in a spatial map is presumed to have a "layer", which is assumed to remain constant once the item is added to the layer mask.
Constructors
| Improve this Doc View SourceLayeredSpatialMap(Int32, Int32, UInt32)
Constructor.
Declaration
public LayeredSpatialMap(int numberOfLayers, int startingLayer = 0, uint layersSupportingMultipleItems = 0U)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | numberOfLayers | Number of layers to include. |
System.Int32 | startingLayer | Index to use for the first layer. |
System.UInt32 | layersSupportingMultipleItems | A layer mask indicating which layers should support multiple items residing at the same location on that layer. Defaults to no layers. Generate this layer mask via DEFAULT. |
Remarks
This class allows you to specify the starting index for layers in order to make it easy to
combine with other structures in a map which may represent other layers. For example, if a
startingLayer
of 0 is specified, layers in the spatial map will have numbers
in range[0, numberOfLayers - 1]. If 1 is specified, layers will have numbers in range [1-numberOfLayers],
and anything to do with layer 0 will be ignored. For example, If a layer-mask that includes layers 0,
2, and 3 is passed to a function, only layers 2 and 3 are considered (since they are the only ones that would
be included in the spatial map.