Class AutoSyncLayeredSpatialMap<T>
A version of LayeredSpatialMap<T> which takes items that implement IPositionable, and uses that interface's properties/events to automatically ensure items are recorded at the proper positions in the spatial map when they move and that the position fields are updated if the spatial map's move functions are used.
Implements
Inherited Members
Namespace: SadRogue.Primitives.SpatialMaps
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class AutoSyncLayeredSpatialMap<T> : AutoSyncAdvancedLayeredSpatialMap<T>, ISpatialMap<T>, IReadOnlyLayeredSpatialMap<T>, IReadOnlySpatialMap<T>, IEnumerable<ItemPositionPair<T>>, IEnumerable where T : class, IHasID, IPositionable, IHasLayer
Type Parameters
Name | Description |
---|---|
T | The type of object that will be contained by this spatial map. |
Remarks
This class automatically keeps the spatial map position of each object synced up with their Position property; you may either use the Move functions of the spatial map, in which case the Position fields of the objects are updated as appropriate, or you may change the Position field, in which case the spatial map position is updated to match.
If you want to manually control the positions of items in the spatial map, you should use LayeredSpatialMap<T> instead.
Constructors
AutoSyncLayeredSpatialMap(Int32, Func<Int32, IListPool<T>>, IEqualityComparer<Point>, Int32, UInt32)
Constructor.
Declaration
public AutoSyncLayeredSpatialMap(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 AdvancedLayeredSpatialMap 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. |