Interface IReadOnlySpatialMap<T>
Implements the read-only interface of ISpatialMap<T>.
Inherited Members
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public interface IReadOnlySpatialMap<T> : IEnumerable<ISpatialTuple<T>>, IEnumerable
Type Parameters
Name | Description |
---|---|
T |
Remarks
Simply exposes only those functions of ISpatialMap<T> that do not allow direct modification of the data (eg. adding/moving/removing items). This can allow for direct exposure of an ISpatialMap as a property of type IReadOnlySpatialMap, without allowing such an exposure to break data encapsulation principles of something like a game map.
Properties
| Improve this Doc View SourceCount
The number of items in the spatial map.
Declaration
int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Items
Enumerable of the items stored in the spatial map: for use to iterate over all items with a foreach loop.
Declaration
IEnumerable<T> Items { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> |
Positions
Enumerable of all positions that contain items.
Declaration
IEnumerable<Coord> Positions { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coord> |
Methods
| Improve this Doc View SourceAsReadOnly()
Returns a read-only reference to the spatial map. Convenient for "safely" exposing the spatial as a property, without allowing direct modification.
Declaration
IReadOnlySpatialMap<T> AsReadOnly()
Returns
Type | Description |
---|---|
IReadOnlySpatialMap<T> | The current spatial map, as a "read-only" reference. |
Contains(T)
Returns whether or not the spatial map contains the given item.
Declaration
bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to check for. |
Returns
Type | Description |
---|---|
System.Boolean | True if the given item is contained in the spatial map, false if not. |
Contains(Coord)
Returns if there is an item in the spatial map at the given position or not.
Declaration
bool Contains(Coord position)
Parameters
Type | Name | Description |
---|---|---|
Coord | position | The position to check for. |
Returns
Type | Description |
---|---|
System.Boolean | True if there is some item at the given position, false if not. |
Contains(Int32, Int32)
Returns if there is an item in the spatial map at the given position or not.
Declaration
bool Contains(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The x-value of the position to check for. |
System.Int32 | y | The y-value of the position to check for. |
Returns
Type | Description |
---|---|
System.Boolean | True if there is some item at the given position, false if not. |
GetItems(Coord)
Gets the item(s) at the given position if there are any items, or returns nothing if there is nothing at that position.
Declaration
IEnumerable<T> GetItems(Coord position)
Parameters
Type | Name | Description |
---|---|---|
Coord | position | The position to return the item(s) for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | The item(s) at the given position if there are any items, or nothing if there is nothing at that position. |
GetItems(Int32, Int32)
Gets the item(s) at the given position if there are any items, or returns nothing if there is nothing at that position.
Declaration
IEnumerable<T> GetItems(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The x-value of the position to return the item(s) for. |
System.Int32 | y | The y-value of the position to return the item(s) for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | The item(s) at the given position if there are any items, or nothing if there is nothing at that position. |
GetPosition(T)
Gets the position associated with the given item in the spatial map, or null if that item is not found.
Declaration
Coord GetPosition(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to get the position for. |
Returns
Type | Description |
---|---|
Coord | The position associated with the given item, if it exists in the spatial map, or NONE if the item does not exist. |
ToString(Func<T, String>)
Returns a string representation of the IReadOnlySpatialMap, allowing display of the spatial map's items in a specified way.
Declaration
string ToString(Func<T, string> itemStringifier)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, System.String> | itemStringifier | Function that turns an item into a string. |
Returns
Type | Description |
---|---|
System.String | A string representation of the spatial map. |
Events
| Improve this Doc View SourceItemAdded
Event that is fired directly after an item has been added to the spatial map.
Declaration
event EventHandler<ItemEventArgs<T>> ItemAdded
Event Type
Type | Description |
---|---|
System.EventHandler<ItemEventArgs<T>> |
ItemMoved
Event that is fired directly after an item in the sptial map has been moved.
Declaration
event EventHandler<ItemMovedEventArgs<T>> ItemMoved
Event Type
Type | Description |
---|---|
System.EventHandler<ItemMovedEventArgs<T>> |
ItemRemoved
Event that is fired directly after an item has been removed from the spatial map.
Declaration
event EventHandler<ItemEventArgs<T>> ItemRemoved
Event Type
Type | Description |
---|---|
System.EventHandler<ItemEventArgs<T>> |