Show / Hide Table of Contents

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.

Inheritance
Object
AdvancedLayeredSpatialMap<T>
LayeredSpatialMap<T>
Implements
ISpatialMap<T>
IReadOnlyLayeredSpatialMap<T>
IReadOnlySpatialMap<T>
IEnumerable<ItemPositionPair<T>>
IEnumerable
Inherited Members
AdvancedLayeredSpatialMap<T>.AsReadOnly()
AdvancedLayeredSpatialMap<T>.Contains(Point, UInt32)
AdvancedLayeredSpatialMap<T>.Contains(Int32, Int32, UInt32)
AdvancedLayeredSpatialMap<T>.GetItemsAt(Point, UInt32)
AdvancedLayeredSpatialMap<T>.GetItemsAt(Int32, Int32, UInt32)
AdvancedLayeredSpatialMap<T>.GetLayer(Int32)
AdvancedLayeredSpatialMap<T>.GetLayersInMask(UInt32)
AdvancedLayeredSpatialMap<T>.CanMoveAll(Point, Point, UInt32)
AdvancedLayeredSpatialMap<T>.CanMoveAll(Int32, Int32, Int32, Int32, UInt32)
AdvancedLayeredSpatialMap<T>.Add(T, Point)
AdvancedLayeredSpatialMap<T>.Add(T, Int32, Int32)
AdvancedLayeredSpatialMap<T>.TryAdd(T, Point)
AdvancedLayeredSpatialMap<T>.TryAdd(T, Int32, Int32)
AdvancedLayeredSpatialMap<T>.IReadOnlySpatialMap<T>.AsReadOnly()
AdvancedLayeredSpatialMap<T>.Clear()
AdvancedLayeredSpatialMap<T>.Contains(T)
AdvancedLayeredSpatialMap<T>.IReadOnlySpatialMap<T>.Contains(Point)
AdvancedLayeredSpatialMap<T>.IReadOnlySpatialMap<T>.Contains(Int32, Int32)
AdvancedLayeredSpatialMap<T>.GetEnumerator()
AdvancedLayeredSpatialMap<T>.IReadOnlySpatialMap<T>.GetItemsAt(Point)
AdvancedLayeredSpatialMap<T>.IReadOnlySpatialMap<T>.GetItemsAt(Int32, Int32)
AdvancedLayeredSpatialMap<T>.GetPositionOfOrNull(T)
AdvancedLayeredSpatialMap<T>.TryGetPositionOf(T, Point)
AdvancedLayeredSpatialMap<T>.GetPositionOf(T)
AdvancedLayeredSpatialMap<T>.Move(T, Point)
AdvancedLayeredSpatialMap<T>.Move(T, Int32, Int32)
AdvancedLayeredSpatialMap<T>.TryMove(T, Point)
AdvancedLayeredSpatialMap<T>.TryMove(T, Int32, Int32)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.MoveValid(Point, Point)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.MoveValid(Point, Point, List<T>)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.MoveValid(Int32, Int32, Int32, Int32)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.MoveValid(Int32, Int32, Int32, Int32, List<T>)
AdvancedLayeredSpatialMap<T>.Remove(T)
AdvancedLayeredSpatialMap<T>.TryRemove(T)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.Remove(Point)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.TryRemove(Point)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.Remove(Int32, Int32)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.TryRemove(Int32, Int32)
AdvancedLayeredSpatialMap<T>.ToString(Func<T, String>)
AdvancedLayeredSpatialMap<T>.CanAdd(T, Point)
AdvancedLayeredSpatialMap<T>.CanAdd(T, Int32, Int32)
AdvancedLayeredSpatialMap<T>.CanMove(T, Point)
AdvancedLayeredSpatialMap<T>.CanMove(T, Int32, Int32)
AdvancedLayeredSpatialMap<T>.IReadOnlySpatialMap<T>.CanMoveAll(Point, Point)
AdvancedLayeredSpatialMap<T>.IReadOnlySpatialMap<T>.CanMoveAll(Int32, Int32, Int32, Int32)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.MoveAll(Point, Point)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.TryMoveAll(Point, Point)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.TryMoveAll(Int32, Int32, Int32, Int32)
AdvancedLayeredSpatialMap<T>.ISpatialMap<T>.MoveAll(Int32, Int32, Int32, Int32)
AdvancedLayeredSpatialMap<T>.MoveValid(Point, Point, UInt32)
AdvancedLayeredSpatialMap<T>.MoveValid(Int32, Int32, Int32, Int32, UInt32)
AdvancedLayeredSpatialMap<T>.MoveValid(Point, Point, List<T>, UInt32)
AdvancedLayeredSpatialMap<T>.MoveValid(Int32, Int32, Int32, Int32, List<T>, UInt32)
AdvancedLayeredSpatialMap<T>.Remove(Point, UInt32)
AdvancedLayeredSpatialMap<T>.TryRemove(Point, UInt32)
AdvancedLayeredSpatialMap<T>.Remove(Int32, Int32, UInt32)
AdvancedLayeredSpatialMap<T>.TryRemove(Int32, Int32, UInt32)
AdvancedLayeredSpatialMap<T>.ToString()
AdvancedLayeredSpatialMap<T>.MoveAll(Point, Point, UInt32)
AdvancedLayeredSpatialMap<T>.MoveAll(Int32, Int32, Int32, Int32, UInt32)
AdvancedLayeredSpatialMap<T>.TryMoveAll(Point, Point, UInt32)
AdvancedLayeredSpatialMap<T>.TryMoveAll(Int32, Int32, Int32, Int32, UInt32)
AdvancedLayeredSpatialMap<T>.LayerMasker
AdvancedLayeredSpatialMap<T>.Layers
AdvancedLayeredSpatialMap<T>.NumberOfLayers
AdvancedLayeredSpatialMap<T>.StartingLayer
AdvancedLayeredSpatialMap<T>.Count
AdvancedLayeredSpatialMap<T>.Items
AdvancedLayeredSpatialMap<T>.Positions
AdvancedLayeredSpatialMap<T>.ItemAdded
AdvancedLayeredSpatialMap<T>.ItemMoved
AdvancedLayeredSpatialMap<T>.ItemRemoved
Namespace: SadRogue.Primitives.SpatialMaps
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class LayeredSpatialMap<T> : AdvancedLayeredSpatialMap<T>, ISpatialMap<T>, IReadOnlyLayeredSpatialMap<T>, IReadOnlySpatialMap<T>, IEnumerable<ItemPositionPair<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

LayeredSpatialMap(Int32, Func<Int32, IListPool<T>>, IEqualityComparer<Point>, Int32, UInt32)

Constructor.

Declaration
public LayeredSpatialMap(int numberOfLayers, Func<int, IListPool<T>> customListPoolCreator = null, IEqualityComparer<Point> pointComparer = null, int startingLayer = 0, uint layersSupportingMultipleItems = 0U)
Parameters
Type Name Description
Int32 numberOfLayers

Number of layers to include.

Func<Int32, IListPool<T>> customListPoolCreator

A function used to determine the list pool implementation used for the spatial maps which support multiple items in a location (if any). The function takes the layer it is creating the pool for as a parameter. If no custom creator is specified, a ListPool is used.

IEqualityComparer<Point> pointComparer

Equality comparer to use for comparison and hashing of points, as object are added to/removed from/moved around the spatial map. Be especially mindful of the efficiency of its GetHashCode function, as it will determine the efficiency of many LayeredSpatialMap functions. Defaults to the default equality comparer for Point, which uses a fairly efficient generalized hashing algorithm.

Int32 startingLayer

Index to use for the first layer.

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.

Implements

ISpatialMap<T>
IReadOnlyLayeredSpatialMap<T>
IReadOnlySpatialMap<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods

PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>)
PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>, EventHandler<ValueChangedEventArgs<TProperty>>)
In This Article
Back to top Generated by DocFX