From 64096816e6f7cd5c72aabc8fcef0373b63c88d7f Mon Sep 17 00:00:00 2001
From: Chris Ridley Implements GoRogue.IReadOnlyLayeredSpatialMap< T >. CEffectArgs Default argument for any effect. Any class that is used as the template argument for an effect must either be this or a class that inherits from this. CEffectTrigger Represents an "event" that can trigger one or more Effects of the appropriate type. Typically instnaces of this class can simply be created, however a subclass may be required for custom add/remove actions and ordering.
- CFOV Class responsible for caculating basic FOV (see SenseMap for more advanced lighting). Effectively a simplified, slightly faster interface compared to SenseMap, that supports only a single source and only shadowcasting. This is more conducive to the typical use case for FOV. It can calculate the FOV with a finite or infinite max radius, and can use a variety of radius types, as specified in Radius class (all the same ones that SenseMap supports). It also supports both 360 degree FOV and a "field of view" (cone) FOV. One may access this class like a 2D array of doubles (FOV values), wherein the values will range from 0.0 to 1.0, where 1.0 means the corresponding map grid coordinate is at maximum visibility, and 0.0 means the cooresponding coordinate is outside of FOV entirely (not visible). Values fall off linearly with respect to radius as distance from the center increases.
- CIDComparer Class intended for comparing/hashing objects that implement IHasID. Type T must be a reference type.
- CIDGenerator Class designed as a helper for situations where you need to generate and assign a unique integer to each instance of a class, eg. for a class implementing IHasID (see that interface documentation for usage example). One may initialize it with a starting unsigned integer, or 0 if none is specified. Then, every time one wants to use an integer, one should call UseID(), and use the one it returns. It is not thread-safe on its own – if it needs to be, one might consider using a lock around any UseID calls.
- CIHasID Interface for a class that has an ID, typically used for hashing purposes. The ID should be unique or close to unique over all instances of the class (for efficiency). Typical implementation could be simply random-genning the ID, or for completely unique IDs can involve using an IDGenerator, potentially as follows:
- CIHasLayer Interface to be implemented by objects that will be used in LayeredSpatialMap/Map classes.
- CIReadOnlyDisjointSet Basic read-only representation of a Disjoint set data structure. Assumes it is holding integers between 0 and size - 1.
- CIReadOnlyFOV Read-only interface of the FOV class.
- CIReadOnlyLayeredSpatialMap Read-only interface for LayeredSpatialMap – useful for exposing LayeredSpatialMap instances as read-only properties.
- CIReadOnlyRadiusAreaProvider Read-only interface of a RadiusAreaProvider.
- CIReadOnlySpatialMap See ISpatialMap documentation. Similar in principle to the C# standard IReadOnlyList/IReadOnlyCollection interface. Simply exposes only those functions of the ISpatialMap interface 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.
- CISpatialMap General interface for a data structure that records objects on a map.
- CISpatialTuple Interface specifying return type for item-location pairs in a spatial map implementation.
- CItemEventArgs Event args for spatial map events pertaining to an item (item added, item removed, etc.)
- CItemMovedEventArgs Event args for SpatialMap's ItemMoved event.
- CLayeredSpatialMap ISpatialMap implementation that can be used to efficiently represent "layers" of objects, with each layer represented as a SpatialMap. It uses layer masking (bit-masking per layer) to allow functions to operate on specific layers. Items must implement IHasID and IHasLayer, be a reference type, and their Layer value MUST NOT change while they are in the data structure.
- CLayerMasker Allows convenient interpretation and creation of layer masks (bit-masks) mask layers represented by integers [0-NumberOfLayers - 1].
- CLines Provides implementations of various (line-drawing) algorithms for generating points closest to a line between two points on a grid.
- CMathHelpers Static class consisting of mathematical "helper" functions and constants – things like angle unit conversions, and other helpful functions.
- CMultiSpatialMap See SpatialMap documentation – similar in principle. However, this implementation allows multiple items to exist at one point in the SpatialMap, in exchange for the loss of the convenience functions like GetItem vs GetItems, as well as potential performance differences (although unless the number of objects at any given location is large, the performance is asymptotically the same).
- CRadius Class representing different radius types. Similar in architecture to Coord in architecture – it cannot be instantiated. Instead it simply has pre-allocated static variables for each type of radius, that should be used whenever a variable of type Radius is required.
- CRadiusAreaProvider Class capable of getting all unique positions inside of a given radius and (optional) bounds.
- CRectangle Represents a rectangle in terms of grid squares. Provides numerous functions pertaining to area.
- CSpatialMap Designed as an more efficient data structure for recording objects on a map. The simple version: if you're about to use a List to store a bunch of objects in your map, consider using this or MultiSpatialMap instead!
+ CUtility Static class full of miscellaneous helper methods.
+ CIDGenerator Class designed as a helper for situations where you need to generate and assign a unique integer to each instance of a class, eg. for a class implementing IHasID (see that interface documentation for usage example). One may initialize it with a starting unsigned integer, or 0 if none is specified. Then, every time one wants to use an integer, one should call UseID(), and use the one it returns. It is not thread-safe on its own – if it needs to be, one might consider using a lock around any UseID calls.
+ CIHasID Interface for a class that has an ID, typically used for hashing purposes. The ID should be unique or close to unique over all instances of the class (for efficiency). Typical implementation could be simply random-genning the ID, or for completely unique IDs can involve using an IDGenerator, potentially as follows:
+ CIHasLayer Interface to be implemented by objects that will be used in LayeredSpatialMap/Map classes.
+ CIReadOnlyDisjointSet Basic read-only representation of a Disjoint set data structure. Assumes it is holding integers between 0 and size - 1.
+ CIReadOnlyFOV Read-only interface of the FOV class.
+ CIReadOnlyLayeredSpatialMap Read-only interface for LayeredSpatialMap – useful for exposing LayeredSpatialMap instances as read-only properties.
+ CIReadOnlyRadiusAreaProvider Read-only interface of a RadiusAreaProvider.
+ CIReadOnlySpatialMap See ISpatialMap documentation. Similar in principle to the C# standard IReadOnlyList/IReadOnlyCollection interface. Simply exposes only those functions of the ISpatialMap interface 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.
+ CISpatialMap General interface for a data structure that records objects on a map.
+ CISpatialTuple Interface specifying return type for item-location pairs in a spatial map implementation.
+ CItemEventArgs Event args for spatial map events pertaining to an item (item added, item removed, etc.)
+ CItemMovedEventArgs Event args for SpatialMap's ItemMoved event.
+ CLayeredSpatialMap ISpatialMap implementation that can be used to efficiently represent "layers" of objects, with each layer represented as a SpatialMap. It uses layer masking (bit-masking per layer) to allow functions to operate on specific layers. Items must implement IHasID and IHasLayer, be a reference type, and their Layer value MUST NOT change while they are in the data structure.
+ CLayerMasker Allows convenient interpretation and creation of layer masks (bit-masks) mask layers represented by integers [0-NumberOfLayers - 1].
+ CLines Provides implementations of various (line-drawing) algorithms for generating points closest to a line between two points on a grid.
+ CMathHelpers Static class consisting of mathematical "helper" functions and constants – things like angle unit conversions, and other helpful functions.
+ CMultiSpatialMap See SpatialMap documentation – similar in principle. However, this implementation allows multiple items to exist at one point in the SpatialMap, in exchange for the loss of the convenience functions like GetItem vs GetItems, as well as potential performance differences (although unless the number of objects at any given location is large, the performance is asymptotically the same).
+ CRadius Class representing different radius types. Similar in architecture to Coord in architecture – it cannot be instantiated. Instead it simply has pre-allocated static variables for each type of radius, that should be used whenever a variable of type Radius is required.
+ CRadiusAreaProvider Class capable of getting all unique positions inside of a given radius and (optional) bounds.
+ CRectangle Represents a rectangle in terms of grid squares. Provides numerous functions pertaining to area.
+ CSpatialMap Designed as an more efficient data structure for recording objects on a map. The simple version: if you're about to use a List to store a bunch of objects in your map, consider using this or MultiSpatialMap instead!
diff --git a/docs/class_go_rogue_1_1_advanced_layered_spatial_map.html b/docs/class_go_rogue_1_1_advanced_layered_spatial_map.html
index da9c45f7..2378dac2 100644
--- a/docs/class_go_rogue_1_1_advanced_layered_spatial_map.html
+++ b/docs/class_go_rogue_1_1_advanced_layered_spatial_map.html
@@ -95,21 +95,45 @@
CUtility Static class full of miscellaneous helper methods. AdvancedLayeredSpatialMap (IEqualityComparer< T > comparer, int numberOfLayers, int startingLayer=0, uint layersSupportingMultipleItems=0) Constructor. Takes a comparator to use, number of layers to include, as well as a starting layer index (defaulting to 0) and a layer mask indicating which layers support multiple items at a single position (defaulting to no layers). More...
-
-IReadOnlySpatialMap< T > GetLayer (int layer)
- Gets a read-only spatial map representing the layer given. More...
-
-IEnumerable< IReadOnlySpatialMap< T > > GetLayers (uint layerMask=uint.MaxValue)
- Returns read-only spatial maps that represent each layer included in the given layer mask. Defaults to all layers. More... bool Add (T newItem, Coord position) Adds the given item at the given position. Item is automatically added to correct layer. More... bool Add (T newItem, int x, int y) Adds the given item at the given position, or returns false if the item cannot be added. Item is automatically added to correct layer. More...
+
+IReadOnlyLayeredSpatialMap< T > AsReadOnly ()
+ Returns a read-only reference to the data structure. Convenient for "safely" exposing the structure as a property. More... void Clear () Clears all items from all layers. More...
+
+bool Contains (T item)
+ Returns whether or not the data structure contains the given item. More...
+
+bool Contains (Coord position, uint layerMask=uint.MaxValue)
+ Returns whether or not there is an item in the data structure at the given position that is on a layer included in the given layer mask. Defaults to searching on all layers. More...
+
+bool Contains (int x, int y, uint layerMask=uint.MaxValue)
+ Returns whether or not there is an item in the data structure at the given position, that is on a layer included in the given layer mask. More...
+
+IEnumerator< ISpatialTuple< T > > GetEnumerator ()
+ Used by foreach loop, so that the class will give ISpatialTuple objects when used in a foreach loop. Generally should never be called explicitly. More...
+
+IEnumerable< T > GetItems (Coord position, uint layerMask=uint.MaxValue)
+ Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More...
+
+IEnumerable< T > GetItems (int x, int y, uint layerMask=uint.MaxValue)
+ Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More...
+
+IReadOnlySpatialMap< T > GetLayer (int layer)
+ Gets a read-only spatial map representing the layer given. More...
+
+IEnumerable< IReadOnlySpatialMap< T > > GetLayers (uint layerMask=uint.MaxValue)
+ Returns read-only spatial maps that represent each layer included in the given layer mask. Defaults to all layers. More...
+
+Coord GetPosition (T item)
+ Gets the position associated with the item in the data structure, or null if that item is not found. More... bool Move (T item, Coord target) Moves the given item to the given position, or returns false if the item cannot be moved. More...
@@ -131,57 +155,33 @@
IEnumerable< T > Remove (int x, int y, uint layerMask=uint.MaxValue) Removes all items at the specified location that are on any layer included in the given layer mask from the data structure. Returns any items that were removed. Defaults to all layers. More...
-
-IReadOnlyLayeredSpatialMap< T > AsReadOnly ()
- Returns a read-only reference to the data structure. Convenient for "safely" exposing the structure as a property. More...
-
-bool Contains (T item)
- Returns whether or not the data structure contains the given item. More...
-
-bool Contains (Coord position, uint layerMask=uint.MaxValue)
- Returns whether or not there is an item in the data structure at the given position that is on a layer included in the given layer mask. Defaults to searching on all layers. More...
-
-bool Contains (int x, int y, uint layerMask=uint.MaxValue)
- Returns whether or not there is an item in the data structure at the given position, that is on a layer included in the given layer mask. More...
-
-IEnumerable< T > GetItems (Coord position, uint layerMask=uint.MaxValue)
- Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More...
-
-IEnumerable< T > GetItems (int x, int y, uint layerMask=uint.MaxValue)
- Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More...
-
-Coord GetPosition (T item)
- Gets the position associated with the item in the data structure, or null if that item is not found. More...
-
-IEnumerator< ISpatialTuple< T > > GetEnumerator ()
- Used by foreach loop, so that the class will give ISpatialTuple objects when used in a foreach loop. Generally should never be called explicitly. More...
+
Public Attributes
+int Count => _layers.Sum(map => map.Count)
+ Gets the number of entities on all layers. More... IEnumerable< IReadOnlySpatialMap< T > > Layers => _layers Gets read-only spatial maps representing each layer. To access a specific layer, instead use GetLayer. More... int NumberOfLayers => _layers.Length Gets the number of layers represented. More...
-
-int Count => _layers.Sum(map => map.Count)
- Gets the number of entities on all layers. More...
-
Properties
-int StartingLayer [get]
- Starting index for layers included in theis LayeredSpatialMap. Specified at construction. More...
-
-LayerMasker LayerMasker [get]
- Object that helps get layer masks as they pertain to this LayeredSpatialMap More... IEnumerable< T > Items [get]
Gets all the items on all layers. More...
+
+LayerMasker LayerMasker [get]
+ Object that helps get layer masks as they pertain to this LayeredSpatialMap More... IEnumerable< Coord > Positions [get]
Gets all positions that have items for each layer. No positions are duplicated if multiple layers have an item at a position. More...
+
+int StartingLayer [get]
+ Starting index for layers included in theis LayeredSpatialMap. Specified at construction. More... Properties inherited from GoRogue.IReadOnlySpatialMap< T > int Count [get]
@@ -193,18 +193,18 @@
The number of items in the data structure. More... Enumerable of all positions that contain items. Likely this won't be used as much, since most objects that are contained in a spatial map implementation will record their position as a member, however in case that is not the case for a particular use, or just as a convenience if you only care about the coordinates, this is provided. More...
- Properties inherited from GoRogue.IReadOnlyLayeredSpatialMap< T >
-int StartingLayer [get]
- Starting index for layers included in this structure. More...
-
-IEnumerable< IReadOnlySpatialMap< T > > Layers [get]
- Gets read-only spatial maps representing each layer. To access a specific layer, instead use GetLayer. More... LayerMasker LayerMasker [get]
Object that helps get layer masks as they pertain to this LayeredSpatialMap More...
+
+IEnumerable< IReadOnlySpatialMap< T > > Layers [get]
+ Gets read-only spatial maps representing each layer. To access a specific layer, instead use GetLayer. More... int NumberOfLayers [get]
Gets the number of layers represented. More...
+
+int StartingLayer [get]
+ Starting index for layers included in this structure. More...
+
- position The position to return the item(s) for.
+ layerMask Layer mask that indicates which layers to check. Defaults to all layers. layerMask Layer mask that indicates which layers to check. Defaults to all layers.
x X-value of the position to return the item(s) for.
- y Y-value of the position to return the item(s) for.
+ layerMask Layer mask that indicates which layers to check. Defaults to all layers.
@@ -700,7 +700,7 @@ layerMask Layer mask that indicates which layers to check. Defaults to all layers.
-
+ layerMask Layer mask indicating which layers to return. Defaults to all layers. layerMask Layer mask indicating which layers to return. Defaults to all layers.
current Position to move all items from.
- target Position to move all items to.
+ layerMask Layer mask specifying which layers to search for items on. Defaults to all layers.
@@ -922,7 +922,7 @@ layerMask Layer mask specifying which layers to search for items on. Defaults to all layers. currentY
Y-value of the position to move items from.
targetX X-value of the position to move items to.
- targetY Y-value of the position to move itesm from.
+ layerMask Layer mask specifying which layers to search for items on. Defaults to all layers.
@@ -989,7 +989,7 @@ layerMask Layer mask specifying which layers to search for items on. Defaults to all layers.
- position Position to remove items from.
+ layerMask The layer mask indicating which layers to search for items. Defaults to all layers. layerMask The layer mask indicating which layers to search for items. Defaults to all layers.
x X-value of the position to remove items from.
- y Y-value of the position to remove items from.
+ layerMask The layer mask indicating which layers to search for items. Defaults to all layers.
diff --git a/docs/class_go_rogue_1_1_advanced_multi_spatial_map.html b/docs/class_go_rogue_1_1_advanced_multi_spatial_map.html
index 1c272875..f069b359 100644
--- a/docs/class_go_rogue_1_1_advanced_multi_spatial_map.html
+++ b/docs/class_go_rogue_1_1_advanced_multi_spatial_map.html
@@ -236,7 +236,7 @@ layerMask The layer mask indicating which layers to search for items. Defaults to all layers. MultiSpatialMap.
comparer | Equality comparer to use for comparison and hashing of type T. Be mindful of the efficiency of this instances GetHashCode function, as it will determine the efficiency of many AdvancedMultiSpatialMap functions. |
comparer | Equality comparer to use for comparison and hashing of type T. Be mindful of the efficiency of this instances GetHashCode function, as it will determine the efficiency of many AdvancedMultiSpatialMap functions. |
initialCapacity | The initial maximum number of elements the MultiSpatialMap can hold before it has to internally resize data structures. Defaults to 32. |
comparer | Equality comparer to use for comparison and hashing of type T. Be mindful of the efficiency of this instances GetHashCode function, as it will determine the efficiency of many AdvancedSpatialMap functions. |
comparer | Equality comparer to use for comparison and hashing of type T. Be mindful of the efficiency of this instances GetHashCode function, as it will determine the efficiency of many AdvancedSpatialMap functions. |
initialCapacity | The initial maximum number of elements the SpatialMap can hold before it has to internally resize data structures. Defaults to 32. |
[get]
[get]
[get]
[get]
[get]
Properties | |
virtual Coord | Position [get, set] |
The position of this object on the grid. Any time this value is changed, the Moved event is fired. More... | |
virtual bool | IsWalkable [get, set] |
Whether or not the object is to be considered "walkable", eg. whether or not the square it resides on can be traversed by other, non-walkable objects on the same map. Effectively, whether or not this object collides according to the collision layer. More... | |
virtual bool | IsTransparent [get, set] |
Whether or not the object is considered "transparent", eg. whether or not light passes through it for the sake of a Map's FOV. More... | |
bool | IsStatic [get] |
Whether or not the object is "static". Static objects CANNOT be moved, and only static objects may be placed on a Map's layer 0. More... | |
Map< BaseSubclass > | CurrentMap [get, set] |
The current Map which this object resides on. Null if the object has not been assigned an object. A GameObject is allowed to reside on only one map. More... | |
uint | ID [get] |
ID of the object. Used for the sake of putting instances of this class in ISpatialMap implementations, and is NOT guaranteed to be entirely unique, though this can be modified by overriding the GenerateID function. More... | |
bool | IsStatic [get] |
Whether or not the object is "static". Static objects CANNOT be moved, and only static objects may be placed on a Map's layer 0. More... | |
virtual bool | IsTransparent [get, set] |
Whether or not the object is considered "transparent", eg. whether or not light passes through it for the sake of a Map's FOV. More... | |
virtual bool | IsWalkable [get, set] |
Whether or not the object is to be considered "walkable", eg. whether or not the square it resides on can be traversed by other, non-walkable objects on the same map. Effectively, whether or not this object collides according to the collision layer. More... | |
int | Layer [get] |
Layer of a Map that this object can reside on. More... | |
Map< BaseSubclass > | CurrentMap [get, set] |
The current Map which this object resides on. Null if the object has not been assigned an object. A GameObject is allowed to reside on only one map. More... | |
virtual Coord | Position [get, set] |
The position of this object on the grid. Any time this value is changed, the Moved event is fired. More... | |
Properties inherited from GoRogue.IHasID | |
uint | ID [get] |
ID assigned to this entity. More... |
Base class for any object that has a grid position and can be added to a Map. BaseSubclass must be the type that is deriving from this types, eg. class MyDerivingGameObject : GameObject<MyDerivingGameObject>
-This class is designed to serve as a base class for your own game objects in your game. It implements basic common functionality such as walkability and transparency, and provides some infrastructure that allows it to be added to instances of Map<GameObject<BaseSubclass>>. It also implements the necessary functionality that allows GameObjects to be added to an ISpatialMap implementation.
-It is intended that you create a class (say, MyGameObject), that derives from this one (GameObject<MyGameObject>), and use this as the base class for your game's objects. This way, a Map<MyGameObject> class will return its objects as type MyGameObject, meaning you can implement any common, game-specific functionality you need and have easy access to that information when objects are retrieved from the map.
+This class is designed to serve as a base class for your own game objects in your game. It implements basic common functionality such as walkability and transparency, and provides some infrastructure that allows it to be added to instances of Map<GameObject<BaseSubclass>>. It also implements the necessary functionality that allows GameObjects to be added to an ISpatialMap implementation. /// It is intended that you create a class (say, MyGameObject), that derives from this one (GameObject<MyGameObject>), and use this as the base class for your game's objects. This way, a Map<MyGameObject> class will return its objects as type MyGameObject, meaning you can implement any common, game-specific functionality you need and have easy access to that information when objects are retrieved from the map.
BaseSubclass | Type of the class that is deriving from this one. |
position | Position to start the object at. |
layer | The layer of of a Map the object is assigned to. |
isStatic | Whether or not the object can be moved (true if the object CANNOT be moved, false otherwise). |
isWalkable | Whether or not the object is considered "transparent", eg. whether or not light passes through it for the sake of a Map's FOV. |
isTransparent | Whether or not the object is considered "transparent", eg. whether or not light passes through it for the sake of a Map's FOV. |
isStatic | Whether or not the object can be moved (true if the object CANNOT be moved, false otherwise). |
isWalkable | Whether or not the object is considered "transparent", eg. whether or not light passes through it for the sake of a Map's FOV. |
isTransparent | Whether or not the object is considered "transparent", eg. whether or not light passes through it for the sake of a Map's FOV. |
Public Attributes | |
IMapView< BaseObject > | Terrain => _terrain |
Terrain of the map. Terrain at each location may be set via the SetTerrain function. More... | |
ArrayMap< bool > | Explored |
Whether or not each tile is considered explored. Tiles start off unexplored, and become explored as soon as they are within a calculated FOV. This ArrayMap may also have values set to it, to easily allow for serialization or wizard-mode like functionality. More... | |
Distance | DistanceMeasurement => AStar.DistanceMeasurement |
Distance measurement used for pathing and measuring distance on the map. More... | |
IReadOnlyLayeredSpatialMap< BaseObject > | Entities => _entities.AsReadOnly() |
IReadOnlyLayeredSpatialMap of all entities (non-terrain objects) on the map. More... | |
LayerMasker | LayerMasker => _entities.LayerMasker |
LayerMasker that should be used to create layer masks for this Map. More... | |
IReadOnlyFOV | FOV => _fov.AsReadOnly() |
Current FOV results for the map. Calculate FOV via the Map's CalculateFOV functions. More... | |
Distance | DistanceMeasurement => AStar.DistanceMeasurement |
Distance measurement used for pathing and measuring distance on the map. More... | |
int | Height => _terrain.Height |
Height of the map, in grid spaces. More... | |
LayerMasker | LayerMasker => _entities.LayerMasker |
LayerMasker that should be used to create layer masks for this Map. More... | |
IMapView< BaseObject > | Terrain => _terrain |
Terrain of the map. Terrain at each location may be set via the SetTerrain function. More... | |
int | Width => _terrain.Width |
Width of the map, in grid spaces. More... | |
Properties | |
uint | LayersBlockingWalkability [get] |
Layer mask that contains only layers that block walkability. A non-walkable BaseObject can only be added to this map if the layer it is on is contained within this layer mask. More... | |
AStar | AStar [get] |
AStar pathfinder for the map. Uses WalkabilityView to determine which locations can be reached. More... | |
uint | LayersBlockingTransparency [get] |
Layer mask that contains only layers that block transparency. A non-transparent BaseObject can only be added to this map if the layer it is on is contained within this layer mask. More... | |
uint | LayersBlockingWalkability [get] |
Layer mask that contains only layers that block walkability. A non-walkable BaseObject can only be added to this map if the layer it is on is contained within this layer mask. More... | |
IMapView< bool > | TransparencyView [get] |
IMapView representing transparency values for each tile. Each location is true if the location is transparent (there are no non-transparent objects at that location), false otherwise. More... | |
IMapView< bool > | WalkabilityView [get] |
IMapView representing walkability values for each tile. Each location is true if the location is walkable (there are no non-walkable objects at that location), false otherwise. More... | |
AStar | AStar [get] |
AStar pathfinder for the map. Uses WalkabilityView to determine which locations can be reached. More... | |
Events | |
EventHandler< ItemEventArgs< BaseObject > > | ObjectAdded |
Event that is fired whenever some object is added to the map. More... | |
EventHandler< ItemEventArgs< BaseObject > > | ObjectRemoved |
Event that is fired whenever some object is removed from the map. More... | |
EventHandler< ItemMovedEventArgs< BaseObject > > | ObjectMoved |
Event that is fired whenever some object that is part of the map is successfully moved. More... | |
EventHandler< ItemEventArgs< BaseObject > > | ObjectRemoved |
Event that is fired whenever some object is removed from the map. More... | |
Base class for a map that consists of one or more objects of type BaseObject. It implements basic functionality to manage these objects, as well as commonly needed functinonality like tile exploration, FOV, and pathfinding. BaseObject must be a type that derives from GameObject<BaseObject>.
-A Map consists of BaseObjects on one or more layers. These layers are numbered, from the lowest layer of 0 upward. Each Map contains at minimum a "terrain" layer. This is considered to be layer 0. All objects added to this layer must have their IsStatic flag set to true, and must reside on layer 0.
-A map will typically also have some other layers, for non terrain objects like the player, monsters, items, etc. The number of these layers present on the map, along with which of all the layers participate in collision detection, etc., can be specified in the constructor.
-While this class has some flexibility, it does, unlike the rest of the library, tend to impose itself on your architecture. In cases where this is undesireable, each component of this map class exists as a separate component (layer masking, the SpatialMap(s) storing the entity layers, FOV, and pathfinding all exist as their own (more flexible) components). This class is not intended to cover every possible use case, but instead may act as an example or starting point in the case where you would like to use the components in a different way or within a different architecture.
+A Map consists of BaseObjects on one or more layers. These layers are numbered, from the lowest layer of 0 upward. Each Map contains at minimum a "terrain" layer. This is considered to be layer 0. All objects added to this layer must have their IsStatic flag set to true, and must reside on layer 0. /// A map will typically also have some other layers, for non terrain objects like the player, monsters, items, etc. The number of these layers present on the map, along with which of all the layers participate in collision detection, etc., can be specified in the constructor. /// While this class has some flexibility, it does, unlike the rest of the library, tend to impose itself on your architecture. In cases where this is undesireable, each component of this map class exists as a separate component (layer masking, the SpatialMap(s) storing the entity layers, FOV, and pathfinding all exist as their own (more flexible) components). This class is not intended to cover every possible use case, but instead may act as an example or starting point in the case where you would like to use the components in a different way or within a different architecture.
BaseObject | The class deriving from GameObject that this map will hold. |
BaseObject | The class deriving from GameObject that this map will hold. |
terrainLayer | The ISettableMapView that represents the terrain layer for this map. It is intended that this be modified ONLY via the SetTerrain function – if it is modified outside of that, the ItemAdded/Removed events are NOT guaranteed to be called! |
terrainLayer | The ISettableMapView that represents the terrain layer for this map. It is intended that this be modified ONLY via the SetTerrain function – if it is modified outside of that, the ItemAdded/Removed events are NOT guaranteed to be called! |
numberOfEntityLayers | Number of non-terrain layers for the map. |
distanceMeasurement | Distance measurement to use for pathing/measuring distance on the map. |
layersBlockingWalkability | Layer mask containing those layers that should be allowed to have items that block walkability. Defaults to all layers. |
layersBlockingTransparency | Layer mask containing those layers that should be allowed to have items that block FOV. Defaults to all layers. |
entityLayersSupportingMultipleItems | Layer mask containing those layers that should be allowed to have multiple objects at the same location on the same layer. Defaults to no layers. |
distanceMeasurement | Distance measurement to use for pathing/measuring distance on the map. |
layersBlockingWalkability | Layer mask containing those layers that should be allowed to have items that block walkability. Defaults to all layers. |
layersBlockingTransparency | Layer mask containing those layers that should be allowed to have items that block FOV. Defaults to all layers. |
entityLayersSupportingMultipleItems | Layer mask containing those layers that should be allowed to have multiple objects at the same location on the same layer. Defaults to no layers. |
position | Position to get object for. |
layerMask | Layer mask for which layers can return an object. Defaults to all layers. |
layerMask | Layer mask for which layers can return an object. Defaults to all layers. |
position | Position to get objects for. |
layerMask | Layer mask for which layers can return an object. Defaults to all layers. |
layerMask | Layer mask for which layers can return an object. Defaults to all layers. |
- GoRogue
-
- C# roguelike/2D game utility library.
- |
-
This is the complete list of members for GoRogue.IDComparer< T >, including all inherited members.
-Equals(T x, T y) | GoRogue.IDComparer< T > | |
GetHashCode(T obj) | GoRogue.IDComparer< T > |
- GoRogue
-
- C# roguelike/2D game utility library.
- |
-
Class intended for comparing/hashing objects that implement IHasID. Type T must be a reference type. - More...
--Public Member Functions | |
bool | Equals (T x, T y) |
Equality comparison. Performs comparison via the object's ReferenceEquals function. More... | |
int | GetHashCode (T obj) |
Generates a hash based on the object's ID.GetHashCode() function. More... | |
Class intended for comparing/hashing objects that implement IHasID. Type T must be a reference type.
-T | Type of object being compared. Type T must be a reference type that implements IHasID. |
T | : | class | |
T | : | IHasID |
bool GoRogue.IDComparer< T >.Equals | -( | -T | -x, | -
- | - | T | -y | -
- | ) | -- |
Equality comparison. Performs comparison via the object's ReferenceEquals function.
-x | First object to compare. |
y | Second object to compare. |
int GoRogue.IDComparer< T >.GetHashCode | -( | -T | -obj | ) | -- |
Generates a hash based on the object's ID.GetHashCode() function.
-obj | Object to generate the hash for. |
Public Attributes | |
AdvancedLayeredSpatialMap (IEqualityComparer< T > comparer, int numberOfLayers, int startingLayer=0, uint layersSupportingMultipleItems=0) | |
Constructor. Takes a comparator to use, number of layers to include, as well as a starting layer index (defaulting to 0) and a layer mask indicating which layers support multiple items at a single position (defaulting to no layers). More... | |
IReadOnlySpatialMap< T > | GetLayer (int layer) |
Gets a read-only spatial map representing the layer given. More... | |
IEnumerable< IReadOnlySpatialMap< T > > | GetLayers (uint layerMask=uint.MaxValue) |
Returns read-only spatial maps that represent each layer included in the given layer mask. Defaults to all layers. More... | |
bool | Add (T newItem, Coord position) |
Adds the given item at the given position. Item is automatically added to correct layer. More... | |
bool | Add (T newItem, int x, int y) |
Adds the given item at the given position, or returns false if the item cannot be added. Item is automatically added to correct layer. More... | |
IReadOnlyLayeredSpatialMap< T > | AsReadOnly () |
Returns a read-only reference to the data structure. Convenient for "safely" exposing the structure as a property. More... | |
void | Clear () |
Clears all items from all layers. More... | |
bool | Contains (T item) |
Returns whether or not the data structure contains the given item. More... | |
bool | Contains (Coord position, uint layerMask=uint.MaxValue) |
Returns whether or not there is an item in the data structure at the given position that is on a layer included in the given layer mask. Defaults to searching on all layers. More... | |
bool | Contains (int x, int y, uint layerMask=uint.MaxValue) |
Returns whether or not there is an item in the data structure at the given position, that is on a layer included in the given layer mask. More... | |
IEnumerator< ISpatialTuple< T > > | GetEnumerator () |
Used by foreach loop, so that the class will give ISpatialTuple objects when used in a foreach loop. Generally should never be called explicitly. More... | |
IEnumerable< T > | GetItems (Coord position, uint layerMask=uint.MaxValue) |
Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More... | |
IEnumerable< T > | GetItems (int x, int y, uint layerMask=uint.MaxValue) |
Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More... | |
IReadOnlySpatialMap< T > | GetLayer (int layer) |
Gets a read-only spatial map representing the layer given. More... | |
IEnumerable< IReadOnlySpatialMap< T > > | GetLayers (uint layerMask=uint.MaxValue) |
Returns read-only spatial maps that represent each layer included in the given layer mask. Defaults to all layers. More... | |
Coord | GetPosition (T item) |
Gets the position associated with the item in the data structure, or null if that item is not found. More... | |
bool | Move (T item, Coord target) |
Moves the given item to the given position, or returns false if the item cannot be moved. More... | |
IEnumerable< T > | Remove (int x, int y, uint layerMask=uint.MaxValue) |
Removes all items at the specified location that are on any layer included in the given layer mask from the data structure. Returns any items that were removed. Defaults to all layers. More... | |
IReadOnlyLayeredSpatialMap< T > | AsReadOnly () |
Returns a read-only reference to the data structure. Convenient for "safely" exposing the structure as a property. More... | |
bool | Contains (T item) |
Returns whether or not the data structure contains the given item. More... | |
bool | Contains (Coord position, uint layerMask=uint.MaxValue) |
Returns whether or not there is an item in the data structure at the given position that is on a layer included in the given layer mask. Defaults to searching on all layers. More... | |
bool | Contains (int x, int y, uint layerMask=uint.MaxValue) |
Returns whether or not there is an item in the data structure at the given position, that is on a layer included in the given layer mask. More... | |
IEnumerable< T > | GetItems (Coord position, uint layerMask=uint.MaxValue) |
Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More... | |
IEnumerable< T > | GetItems (int x, int y, uint layerMask=uint.MaxValue) |
Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More... | |
Coord | GetPosition (T item) |
Gets the position associated with the item in the data structure, or null if that item is not found. More... | |
IEnumerator< ISpatialTuple< T > > | GetEnumerator () |
Used by foreach loop, so that the class will give ISpatialTuple objects when used in a foreach loop. Generally should never be called explicitly. More... | |
Additional Inherited Members | |
Public Attributes inherited from GoRogue.AdvancedLayeredSpatialMap< T > | |
int | Count => _layers.Sum(map => map.Count) |
Gets the number of entities on all layers. More... | |
IEnumerable< IReadOnlySpatialMap< T > > | Layers => _layers |
Gets read-only spatial maps representing each layer. To access a specific layer, instead use GetLayer. More... | |
int | NumberOfLayers => _layers.Length |
Gets the number of layers represented. More... | |
int | Count => _layers.Sum(map => map.Count) |
Gets the number of entities on all layers. More... | |
Properties inherited from GoRogue.AdvancedLayeredSpatialMap< T > | |
int | StartingLayer [get] |
Starting index for layers included in theis LayeredSpatialMap. Specified at construction. More... | |
LayerMasker | LayerMasker [get] |
Object that helps get layer masks as they pertain to this LayeredSpatialMap More... | |
IEnumerable< T > | Items [get] |
Gets all the items on all layers. More... | |
LayerMasker | LayerMasker [get] |
Object that helps get layer masks as they pertain to this LayeredSpatialMap More... | |
IEnumerable< Coord > | Positions [get] |
Gets all positions that have items for each layer. No positions are duplicated if multiple layers have an item at a position. More... | |
int | StartingLayer [get] |
Starting index for layers included in theis LayeredSpatialMap. Specified at construction. More... | |
Properties inherited from GoRogue.IReadOnlySpatialMap< T > | |
int | Count [get] |
The number of items in the data structure. More... | |
Enumerable of all positions that contain items. Likely this won't be used as much, since most objects that are contained in a spatial map implementation will record their position as a member, however in case that is not the case for a particular use, or just as a convenience if you only care about the coordinates, this is provided. More... | |
Properties inherited from GoRogue.IReadOnlyLayeredSpatialMap< T > | |
int | StartingLayer [get] |
Starting index for layers included in this structure. More... | |
IEnumerable< IReadOnlySpatialMap< T > > | Layers [get] |
Gets read-only spatial maps representing each layer. To access a specific layer, instead use GetLayer. More... | |
LayerMasker | LayerMasker [get] |
Object that helps get layer masks as they pertain to this LayeredSpatialMap More... | |
IEnumerable< IReadOnlySpatialMap< T > > | Layers [get] |
Gets read-only spatial maps representing each layer. To access a specific layer, instead use GetLayer. More... | |
int | NumberOfLayers [get] |
Gets the number of layers represented. More... | |
int | StartingLayer [get] |
Starting index for layers included in this structure. More... | |
Events inherited from GoRogue.AdvancedLayeredSpatialMap< T > | |
EventHandler< ItemEventArgs< T > > | ItemAdded |
Fires whenever an item is added to any layer. More... |
T | Type of items in the layers. Type T must implement IHasID and IHasLayer, must be a reference type, and its IHasLayer.Layer value MUST NOT change while the item is in the LayeredSpatialMap. |
T | Type of items in the layers. Type T must implement IHasID and IHasLayer, must be a reference type, and its IHasLayer.Layer value MUST NOT change while the item is in the LayeredSpatialMap. |
map | The map to set values to. | ||||||||||||||||
rng | The RNG to use to place rooms and determine room size. If null is specified, the default RNG is used. | ||||||||||||||||
rng | The RNG to use to place rooms and determine room size. If null is specified, the default RNG is used. | ||||||||||||||||
maxRooms | The maximum number of rooms to attempt to place on the map. | ||||||||||||||||
roomMinSize | The minimum size in width and height of each room. | ||||||||||||||||
roomMaxSize | The maximum size in width and height of each room. |
Generate(ISettableMapView< bool > map, IGenerator rng=null, int crawlerChangeDirectionImprovement=10, int saveDeadEndChance=0) | GoRogue.MapGeneration.Generators.MazeGenerator | static |
Generate(ISettableMapView< bool > map, int crawlerChangeDirectionImprovement=10, int saveDeadEndChance=0) | GoRogue.MapGeneration.Generators.MazeGenerator | static |
Generate(ISettableMapView< bool > map, IGenerator rng=null, int crawlerChangeDirectionImprovement=10, int saveDeadEndChance=0) | GoRogue.MapGeneration.Generators.MazeGenerator | static |
Static Public Member Functions | |||||||||||||||||
static void | Generate (ISettableMapView< bool > map, int crawlerChangeDirectionImprovement=10, int saveDeadEndChance=0) | ||||||||||||||||
Generates a maze in map using crawlers that walk the map carving tunnels. More... | |||||||||||||||||
static void | Generate (ISettableMapView< bool > map, IGenerator rng=null, int crawlerChangeDirectionImprovement=10, int saveDeadEndChance=0) | ||||||||||||||||
Generates a maze in map using crawlers that walk the map carving tunnels. More... | |||||||||||||||||
+
|
+ +static | +
Generates a maze in map using crawlers that walk the map carving tunnels.
+map | The map to modify. |
crawlerChangeDirectionImprovement | Out of 100, how much to increase the chance of the crawler changing direction each step. Once it changes direction, the chance resets to 0 and increases by this amount. Defaults to 10. |
saveDeadEndChance | After the crawler finishes, the small dead ends will be trimmed out. This value indicates the chance out of 100 that the dead end remains. Defaults to 0. |
Static Public Member Functions | |
static IEnumerable< Rectangle > | GenerateRandomRoomsMap (ISettableMapView< bool > map, int maxRooms, int roomMinSize, int roomMaxSize, int attemptsPerRoom=10) |
Generates a map by attempting to randomly place the specified number of rooms, ranging in size between the specified min size and max size, trying the specified number of times to position a room without overlap before discarding the room entirely. The given map will have a value of false set to all non-passable tiles, and true set to all passable ones. More... | |
static IEnumerable< Rectangle > | GenerateRandomRoomsMap (ISettableMapView< bool > map, IGenerator rng, int maxRooms, int roomMinSize, int roomMaxSize, int attemptsPerRoom=10) |
Generates a map by attempting to randomly place the specified number of rooms, ranging in size between the specified min size and max size, trying the specified number of times to position a room without overlap before discarding the room entirely. The given map will have a value of false set to all non-passable tiles, and true set to all passable ones. More... | |
static IEnumerable< MapArea > | GenerateCellularAutomataMap (ISettableMapView< bool > map, IGenerator rng=null, int fillProbability=40, int totalIterations=7, int cutoffBigAreaFill=4) |
Generates a cave-like map using the cellular automata algorithm here: http://www.roguebasin.com/index.php?title=Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels. See CellularAutomataAreaGenerator for details. This algorithm is identical, except that it connects the areas automatically afterward. More... | |
static IEnumerable<(Rectangle Room, Coord[][] Connections)> | GenerateDungeonMazeMap (ISettableMapView< bool > map, int minRooms, int maxRooms, int roomMinSize, int roomMaxSize, float roomSizeRatioX=1f, float roomSizeRatioY=1f, int maxCreationAttempts=10, int maxPlacementAttempts=10, int crawlerChangeDirectionImprovement=10, int saveDeadEndChance=0, int minSidesToConnect=1, int maxSidesToConnect=4, int cancelSideConnectionSelectChance=50, int cancelConnectionPlacementChance=70, int cancelConnectionPlacementChanceIncrease=10) |
Generates a dungeon map based on the process outlined here: http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/. More... | |
static IEnumerable<(Rectangle Room, Coord[][] Connections)> | GenerateDungeonMazeMap (ISettableMapView< bool > map, IGenerator rng, int minRooms, int maxRooms, int roomMinSize, int roomMaxSize, float roomSizeRatioX=1f, float roomSizeRatioY=1f, int maxCreationAttempts=10, int maxPlacementAttempts=10, int crawlerChangeDirectionImprovement=10, int saveDeadEndChance=0, int minSidesToConnect=1, int maxSidesToConnect=4, int cancelSideConnectionSelectChance=50, int cancelConnectionPlacementChance=70, int cancelConnectionPlacementChanceIncrease=10) |
Generates a dungeon map based on the process outlined here: http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/. More... | |
static IEnumerable< Rectangle > | GenerateRandomRoomsMap (ISettableMapView< bool > map, int maxRooms, int roomMinSize, int roomMaxSize, int attemptsPerRoom=10) |
Generates a map by attempting to randomly place the specified number of rooms, ranging in size between the specified min size and max size, trying the specified number of times to position a room without overlap before discarding the room entirely. The given map will have a value of false set to all non-passable tiles, and true set to all passable ones. More... | |
static IEnumerable< Rectangle > | GenerateRandomRoomsMap (ISettableMapView< bool > map, IGenerator rng, int maxRooms, int roomMinSize, int roomMaxSize, int attemptsPerRoom=10) |
Generates a map by attempting to randomly place the specified number of rooms, ranging in size between the specified min size and max size, trying the specified number of times to position a room without overlap before discarding the room entirely. The given map will have a value of false set to all non-passable tiles, and true set to all passable ones. More... | |
static void | GenerateRectangleMap (ISettableMapView< bool > map) |
Generates a map, as a simple rectangular box, setting the map given as a "walkability map". Wall tiles (the edges of the map) will have a value of false set in the given map, whereas true will be set to all non-wall tiles. More... | |
Generates a map, as a simple rectangular box, setting the map given as a "walkability
+map". Wall tiles (the edges of the map) will have a value of false set in the given map, whereas true will be set to all non-wall tiles. More... | |
static IEnumerable< MapArea > | GenerateCellularAutomataMap (ISettableMapView< bool > map, IGenerator rng=null, int fillProbability=40, int totalIterations=7, int cutoffBigAreaFill=4) |
Generates a cave-like map using the cellular automata algorithm here: http://www.roguebasin.com/index.php?title=Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels. See CellularAutomataAreaGenerator for details. This algorithm is identical, except that it connects the areas automatically afterward. More... | |
Collection of algorithms that put map generation pieces together, in ways that allow you to quickly and easily generate a given type of map in a single function call. The implementation of these functions may also be used as the basis for implementing more customized generation processes.
@@ -292,17 +293,17 @@map | The map to set values to. | ||||||||
rng | The RNG to use to place rooms and determine room size. If null is specified, the default RNG is used. | ||||||||
rng | The RNG to use to place rooms and determine room size. If null is specified, the default RNG is used. | ||||||||
maxRooms | The maximum number of rooms to attempt to place on the map. | ||||||||
roomMinSize | The minimum size in width and height of each room. | ||||||||
roomMaxSize | The maximum size in width and height of each room. |
map | The map to set values to. |
Static Public Member Functions | |
static void | ApplyOverlay< T > (this ISettableMapView< T > self, IMapView< T > overlay) |
Extension method that applies values of the overlay to the current one – effectively sets all the values of the current map to be corresponding to the one you pass in. More... | |
static Rectangle | Bounds< T > (this IMapView< T > mapView) |
Gets a rectangle representing the bounds of the MapView. More... | |
static string | ExtendToString< T > (this IMapView< T > map, string begin="", string beginRow="", Func< T, string > elementStringifier=null, string rowSeparator="\, string elementSeparator=" ", string endRow="", string end="") |
Extension method for IMapViews allowing printing the contents. Takes characters to surround the map printout, and each row, the method used to get the string representation of each element (defaulting to the ToString function of type T), and separation characters for each element and row. More... | |
static string | ExtendToString< T > (this IMapView< T > map, int fieldSize, string begin="", string beginRow="", Func< T, string > elementStringifier=null, string rowSeparator="\, string elementSeparator=" ", string endRow="", string end="") |
Extension method for IMapViews allowing printing the contents. Takes characters to surround the map, and each row, the method used to get the string representation of each element (defaulting to the ToString function of type T), and separation characters for each element and row. Takes the size of the field to give each element, characters to surround the MapView printout, and each row, the method used to get the string representation of each element (defaulting to the ToString function of type T), and separation characters for each element and row. More... | |
static IEnumerable< Coord > | Positions< T > (this IMapView< T > mapView) |
Iterates through each position in the map view. Equivalent to nested for loop for (y = 0...) for (x = 0...) More... | |
static Coord | RandomPosition< T > (this IMapView< T > mapView, IGenerator rng=null) |
Gets a random position within the MapView. More... | |
static string | ExtendToString< T > (this IMapView< T > map, string begin="", string beginRow="", Func< T, string > elementStringifier=null, string rowSeparator="\, string elementSeparator=" ", string endRow="", string end="") |
Extension method for IMapViews allowing printing the contents. Takes characters to surround the map printout, and each row, the method used to get the string representation of each element (defaulting to the ToString function of type T), and separation characters for each element and row. More... | |
static string | ExtendToString< T > (this IMapView< T > map, int fieldSize, string begin="", string beginRow="", Func< T, string > elementStringifier=null, string rowSeparator="\, string elementSeparator=" ", string endRow="", string end="") |
Extension method for IMapViews allowing printing the contents. Takes characters to surround the map, and each row, the method used to get the string representation of each element (defaulting to the ToString function of type T), and separation characters for each element and row. Takes the size of the field to give each element, characters to surround the MapView printout, and each row, the method used to get the string representation of each element (defaulting to the ToString function of type T), and separation characters for each element and row. More... | |
static void | ApplyOverlay< T > (this ISettableMapView< T > self, IMapView< T > overlay) |
Extension method that applies values of the overlay to the current one – effectively sets all the values of the current map to be corresponding to the one you pass in. More... | |
Extensions for the IMapView class that effectively act as methods with default implementations for them.
@@ -156,7 +156,7 @@self | The current ISettableMapView. Never specified manually as this is an extension method. |
self | The current ISettableMapView. Never specified manually as this is an extension method. |
overlay | The data apply to the map. Must have identical dimensions to the current map. |
position | Position corresponding to given data value of your map. |
position | Position corresponding to given data value of your map. |
value | The data value from your map. |
Although SpatialMap should generally be preferred in cases where only one item is allowed at a location in the first place, this implementation may be particularly useful for situations such as inventory items, where multiple items may be desired at one location. If one is implementing something akin to "buckets", one may also subclass this implementation and provide handlers to the various events it exposes to keep track of the object on top, etc. The two implementations could also in many cases be used in combination as necessary, since they both implement the ISpatialMap interface.
T | The type of items being stored. Must implement IHasID and be a reference-type. |
T | The type of items being stored. Must implement IHasID and be a reference-type. |
goalMap | The IMapView of nullable double values to operate on. Never specified manually since this is an extension method. |
goalMap | The IMapView of nullable double values to operate on. Never specified manually since this is an extension method. |
position | The position to get the minimum value for. |
adjacencyRule | The adjacency rule to use to determine neighbors. |
Properties | |
double | Angle [get, set] |
If IsAngleRestricted is true, the angle in degrees that represents a line from the source's start to the outermost center point of the cone formed by the source's calculated values. 0 degrees points right. If IsAngleRestricted is false, this will be 0.0 degrees. More... | |
Distance | DistanceCalc [get, set] |
The distance calculation used to determine what shape the radius has (or a type implicitly convertible to Distance, eg. Radius) More... | |
bool | Enabled [get, set] |
Whether or not this source is enabled. If a source is disabled when its SenseMap's Calculate function is called, the source does not calculate values and is effectively assumed to be "off". More... | |
Coord | Position [get, set] |
The position on a map that the source is located at. More... | |
bool | IsAngleRestricted [get, set] |
Whether or not the spreading of values from this source is restricted to an angle and span. More... | |
double | Angle [get, set] |
If IsAngleRestricted is true, the angle in degrees that represents a line from the source's start to the outermost center point of the cone formed by the source's calculated values. 0 degrees points right. If IsAngleRestricted is false, this will be 0.0 degrees. More... | |
double | Span [get, set] |
If IsAngleRestricted is true, the angle in degrees that represents the full arc of the cone formed by the source's calculated values. If IsAngleRestricted is false, it will be 360 degrees. More... | |
Coord | Position [get, set] |
The position on a map that the source is located at. More... | |
double | Radius [get, set] |
The maximum radius of the source – this is the maximum distance the source values will emanate, provided the area is completely unobstructed. Changing this will trigger resizing (re-allocation) of the underlying arrays. However, data is not copied over – there is no need to since Calculate in SenseMap immediately copies values from local array to its "master" array. More... | |
double | Span [get, set] |
If IsAngleRestricted is true, the angle in degrees that represents the full arc of the cone formed by the source's calculated values. If IsAngleRestricted is false, it will be 360 degrees. More... | |
SourceType | Type [get, set] |
The spread mechanics to use for source values. More... | |
The position on a map that the source is located at. | |
radius | The maximum radius of the source – this is the maximum distance the source values will emanate, provided the area is completely unobstructed. |
distanceCalc | The distance calculation used to determine what shape the radius has (or a type implicitly convertible to Distance, eg. Radius). |
angle | The angle in degrees that specifies the outermost center point of the cone formed by the source's values. 0 degrees points right. |
angle | The angle in degrees that specifies the outermost center point of the cone formed by the source's values. 0 degrees points right. |
span | The angle, in degrees, that specifies the full arc contained in the cone formed by the source's values – angle/2 degrees are included on either side of the cone's center line. |
Typical roguelikes will use a 2D array (or 1D array accessed as a 2D array), for terrain, and lists of objects for things like entities, items, etc. This is simple but ultimately not efficient; for example, in that implementation, determining if there is an object at a location takes an amount of time proportional to the number of objects in this list. However, the other simple option is to use an array with size equal to the size of the map (as many do for terrain) for all object lists. This is even less ideal, as in that case, the time to iterate over all objects becomes proportional to the size of the map (since one has to do that for rendering, ouch!), which is typically much larger than the number of objects in a list. This is the problem SpatialMap is designed to solve. It provides fast, near-constant-time operations for getting the object at a location, adding entities, removing entities, and will allow you to iterate through all objects in the SpatialMap in time proportional to the number of objects in it (the best possible). Effectively, it is a more efficient list for objects that have a position associated with them. This implementation can only allow one item at a given location at a time – for an implementation that allows multiple items, see MultiSpatialMap. The objects stored in a SpatialMap must implement the IHasID (see that interface's documentation for an easy implementation example). This is used internally to keep track of the objects, since uints are easily (efficiently) hashable.
T | The type of object that will be contained by this SpatialMap. Must implement IHasID and be a reference-type. |
T | The type of object that will be contained by this SpatialMap. Must implement IHasID and be a reference-type. |
| Distance (GoRogue) | IMapViewExtensions (GoRogue.MapViews) | LambdaTranslationMap (GoRogue.MapViews) | RandomConnectionPointSelector (GoRogue.MapGeneration.Connectors) | |||||
DistributionHelpers (GoRogue.Random) | ImpossibleDieException (GoRogue.DiceNotation.Exceptions) | LayeredSpatialMap (GoRogue) | Rectangle (GoRogue) | ||||||
AddTerm (GoRogue.DiceNotation.Terms) | DivideTerm (GoRogue.DiceNotation.Terms) | InvalidChooseException (GoRogue.DiceNotation.Exceptions) | LayerMasker (GoRogue) | RoomDoorConnector (GoRogue.MapGeneration.Connectors) | |||||
AdjacencyRule (GoRogue) |
| InvalidMultiplicityException (GoRogue.DiceNotation.Exceptions) | Lines (GoRogue) | RoomsGenerator (GoRogue.MapGeneration.Generators) | |||||
AdvancedLayeredSpatialMap (GoRogue) | InvalidSyntaxException (GoRogue.DiceNotation.Exceptions) |
|
| DisjointSet (GoRogue) | IMapView (GoRogue.MapViews) | LambdaSettableMapView (GoRogue.MapViews) | RadiusAreaProvider (GoRogue) | ||
Distance (GoRogue) | IMapViewExtensions (GoRogue.MapViews) | LambdaSettableTranslationMap (GoRogue.MapViews) | RandomConnectionPointSelector (GoRogue.MapGeneration.Connectors) | ||||||
AddTerm (GoRogue.DiceNotation.Terms) | DistributionHelpers (GoRogue.Random) | ImpossibleDieException (GoRogue.DiceNotation.Exceptions) | LambdaTranslationMap (GoRogue.MapViews) | Rectangle (GoRogue) | |||||
AdjacencyRule (GoRogue) | DivideTerm (GoRogue.DiceNotation.Terms) | InvalidChooseException (GoRogue.DiceNotation.Exceptions) | LayeredSpatialMap (GoRogue) | RoomDoorConnector (GoRogue.MapGeneration.Connectors) | |||||
AdvancedLayeredSpatialMap (GoRogue) |
| InvalidMultiplicityException (GoRogue.DiceNotation.Exceptions) | LayerMasker (GoRogue) | RoomsGenerator (GoRogue.MapGeneration.Generators) | |||||
AdvancedMultiSpatialMap (GoRogue) | InvalidSyntaxException (GoRogue.DiceNotation.Exceptions) | Lines (GoRogue) |
| ||||||
AdvancedMultiSpatialMap (GoRogue) | Effect (GoRogue) | IParser (GoRogue.DiceNotation) | |||||||
AdvancedSpatialMap (GoRogue) | EffectArgs (GoRogue) | IReadOnlyDisjointSet (GoRogue) | Map (GoRogue.GameFramework) | SenseMap (GoRogue.SenseMapping) | |||||
ArrayMap (GoRogue.MapViews) | EffectTrigger (GoRogue) | IReadOnlyFOV (GoRogue) | MapArea (GoRogue.MapGeneration) | SenseSource (GoRogue.SenseMapping) | |||||
AStar (GoRogue.Pathing) |
| IReadOnlyLayeredSpatialMap (GoRogue) | MapAreaFinder (GoRogue.MapGeneration) | SettableTranslationMap (GoRogue.MapViews) | |||||
AdvancedSpatialMap (GoRogue) | Effect (GoRogue) | IParser (GoRogue.DiceNotation) |
| ||||||
ArrayMap (GoRogue.MapViews) | EffectArgs (GoRogue) | IReadOnlyDisjointSet (GoRogue) | SenseMap (GoRogue.SenseMapping) | ||||||
AStar (GoRogue.Pathing) | EffectTrigger (GoRogue) | IReadOnlyFOV (GoRogue) | Map (GoRogue.GameFramework) | SenseSource (GoRogue.SenseMapping) | |||||
| IReadOnlyMapArea (GoRogue.MapGeneration) | MathHelpers (GoRogue) | SettableViewport (GoRogue.MapViews) | ||||||
FleeMap (GoRogue.Pathing) | IReadOnlyRadiusAreaProvider (GoRogue) | MaxRandom (GoRogue.Random) | SingletonRandom (GoRogue.Random) | ||||||
BasicRoomsGenerator (GoRogue.MapGeneration.Generators) | FOV (GoRogue) | IReadOnlySenseMap (GoRogue.SenseMapping) | MazeGenerator (GoRogue.MapGeneration.Generators) | SpatialMap (GoRogue) | |||||
BoundedRectangle (GoRogue) |
| IReadOnlySpatialMap (GoRogue) | MinRandom (GoRogue.Random) | SubtractTerm (GoRogue.DiceNotation.Terms) |
| IReadOnlyLayeredSpatialMap (GoRogue) | MapArea (GoRogue.MapGeneration) | SettableTranslationMap (GoRogue.MapViews) | +|
IReadOnlyMapArea (GoRogue.MapGeneration) | MapAreaFinder (GoRogue.MapGeneration) | SettableViewport (GoRogue.MapViews) | |||||||
BasicRoomsGenerator (GoRogue.MapGeneration.Generators) | FleeMap (GoRogue.Pathing) | IReadOnlyRadiusAreaProvider (GoRogue) | MathHelpers (GoRogue) | SingletonRandom (GoRogue.Random) | |||||
BoundedRectangle (GoRogue) | FOV (GoRogue) | IReadOnlySenseMap (GoRogue.SenseMapping) | MaxRandom (GoRogue.Random) | SpatialMap (GoRogue) | |||||
| ISettableMapView (GoRogue.MapViews) | MultiplyTerm (GoRogue.DiceNotation.Terms) |
| ||||||
GameObject (GoRogue.GameFramework) | ISpatialMap (GoRogue) | MultiSpatialMap (GoRogue) | |||||||
CellularAutomataAreaGenerator (GoRogue.MapGeneration.Generators) | GoalMap (GoRogue.Pathing) | ISpatialTuple (GoRogue) |
| TranslationMap (GoRogue.MapViews) | |||||
CenterBoundsConnectionPointSelector (GoRogue.MapGeneration.Connectors) | GoalMapExtensions (GoRogue.Pathing) | ItemEventArgs (GoRogue) |
|
| IReadOnlySpatialMap (GoRogue) | MazeGenerator (GoRogue.MapGeneration.Generators) | SubtractTerm (GoRogue.DiceNotation.Terms) | ||
ISettableMapView (GoRogue.MapViews) | MinRandom (GoRogue.Random) |
| |||||||
ClosestMapAreaConnector (GoRogue.MapGeneration.Connectors) |
| ItemMovedEventArgs (GoRogue) | OrderedMapAreaConnector (GoRogue.MapGeneration.Connectors) | ||||||
ConstantTerm (GoRogue.DiceNotation.Terms) | ITerm (GoRogue.DiceNotation.Terms) |
| Utility (GoRogue) | ||||||
Coord (GoRogue) | HorizontalVerticalTunnelCreator (GoRogue.MapGeneration.Connectors) | ITunnelCreator (GoRogue.MapGeneration.Connectors) |
| ||||||
CellularAutomataAreaGenerator (GoRogue.MapGeneration.Generators) | GameObject (GoRogue.GameFramework) | ISpatialMap (GoRogue) | MultiplyTerm (GoRogue.DiceNotation.Terms) | ||||||
CenterBoundsConnectionPointSelector (GoRogue.MapGeneration.Connectors) | GoalMap (GoRogue.Pathing) | ISpatialTuple (GoRogue) | MultiSpatialMap (GoRogue) | TranslationMap (GoRogue.MapViews) | |||||
ClosestMapAreaConnector (GoRogue.MapGeneration.Connectors) | GoalMapExtensions (GoRogue.Pathing) | ItemEventArgs (GoRogue) |
|
| |||||
ConstantTerm (GoRogue.DiceNotation.Terms) |
| ItemMovedEventArgs (GoRogue) | |||||||
Coord (GoRogue) | ITerm (GoRogue.DiceNotation.Terms) | OrderedMapAreaConnector (GoRogue.MapGeneration.Connectors) | Utility (GoRogue) | ||||||
|
| HorizontalVerticalTunnelCreator (GoRogue.MapGeneration.Connectors) | ITunnelCreator (GoRogue.MapGeneration.Connectors) |
|
| ||||
|
| Parser (GoRogue.DiceNotation) | |||||||
Path (GoRogue.Pathing) | Viewport (GoRogue.MapViews) | ||||||||
Dice (GoRogue.DiceNotation) | IAreaConnectionPointSelector (GoRogue.MapGeneration.Connectors) | KeepTerm (GoRogue.DiceNotation.Terms) |
|
| |||||
DiceExpression (GoRogue.DiceNotation) | IDComparer (GoRogue) | KnownSeriesGenerator (GoRogue.Random) | |||||||
DiceTerm (GoRogue.DiceNotation.Terms) | IDGenerator (GoRogue) |
| QuickGenerators (GoRogue.MapGeneration) | WeightedGoalMap (GoRogue.Pathing) | |||||
Direction (GoRogue) | IDiceExpression (GoRogue.DiceNotation) |
| |||||||
Dice (GoRogue.DiceNotation) | Parser (GoRogue.DiceNotation) | Viewport (GoRogue.MapViews) | |||||||
DiceExpression (GoRogue.DiceNotation) | IAreaConnectionPointSelector (GoRogue.MapGeneration.Connectors) | KeepTerm (GoRogue.DiceNotation.Terms) | Path (GoRogue.Pathing) |
| |||||
DiceTerm (GoRogue.DiceNotation.Terms) | IDGenerator (GoRogue) | KnownSeriesGenerator (GoRogue.Random) |
| ||||||
Direction (GoRogue) | IDiceExpression (GoRogue.DiceNotation) |
| WeightedGoalMap (GoRogue.Pathing) | ||||||
DirectLineTunnelCreator (GoRogue.MapGeneration.Connectors) | IHasID (GoRogue) | QuickGenerators (GoRogue.MapGeneration) | |||||||
DiscreteConverter (GoRogue.Random) | IHasLayer (GoRogue) | LambdaMapView (GoRogue.MapViews) |
| ||||||
DirectLineTunnelCreator (GoRogue.MapGeneration.Connectors) | IHasID (GoRogue) | LambdaMapView (GoRogue.MapViews) | |||||||
DiscreteConverter (GoRogue.Random) | IHasLayer (GoRogue) | LambdaSettableMapView (GoRogue.MapViews) | Radius (GoRogue) | ||||||
DisjointSet (GoRogue) | IMapView (GoRogue.MapViews) | LambdaSettableTranslationMap (GoRogue.MapViews) | RadiusAreaProvider (GoRogue) | ||||||
Radius (GoRogue) | |||||||||
Properties | |
IMapView< bool > | BooleanFOV [get] |
A view of the FOV results in boolean form, where true indicates a location is in FOV, and false indicates it is not. More... | |
IEnumerable< Coord > | CurrentFOV [get] |
IEnumerable of only positions currently in FOV. More... | |
IEnumerable< Coord > | NewlyUnseen [get] |
IEnumerable of positions that are NOT in FOV as of the most current Calculate call, but WERE in FOV after the previous time Calculate was called. More... | |
IMapView< bool > | BooleanFOV [get] |
A view of the FOV results in boolean form, where true indicates a location is in FOV, and false indicates it is not. More... | |
Properties inherited from GoRogue.MapViews.IMapView< double > | |
int | Height [get] |
The height of the map being represented. More... | |
new IReadOnlyLayeredSpatialMap< T > | AsReadOnly () |
Returns a read-only reference to the data structure. Convenient for "safely" exposing the structure as a property. More... | |
IEnumerable< T > | GetItems (Coord position, uint layerMask=uint.MaxValue) |
Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More... | |
IEnumerable< T > | GetItems (int x, int y, uint layerMask=uint.MaxValue) |
Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More... | |
bool | Contains (Coord position, uint layerMask=uint.MaxValue) |
Returns whether or not there is an item in the data structure at the given position that is on a layer included in the given layer mask. Defaults to searching on all layers. More... | |
bool | Contains (int x, int y, uint layerMask=uint.MaxValue) |
Returns whether or not there is an item in the data structure at the given position, that is on a layer included in the given layer mask. More... | |
IEnumerable< T > | GetItems (Coord position, uint layerMask=uint.MaxValue) |
Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More... | |
IEnumerable< T > | GetItems (int x, int y, uint layerMask=uint.MaxValue) |
Gets the item(s) associated with the given position that reside on any layer included in the given layer mask. Returns nothing if there is nothing at that position on a layer included in the given layer mask. More... | |
IReadOnlySpatialMap< T > | GetLayer (int layer) |
Gets a read-only spatial map representing the layer given. More... | |
Properties | |
int | StartingLayer [get] |
Starting index for layers included in this structure. More... | |
IEnumerable< IReadOnlySpatialMap< T > > | Layers [get] |
Gets read-only spatial maps representing each layer. To access a specific layer, instead use GetLayer. More... | |
LayerMasker | LayerMasker [get] |
Object that helps get layer masks as they pertain to this LayeredSpatialMap More... | |
IEnumerable< IReadOnlySpatialMap< T > > | Layers [get] |
Gets read-only spatial maps representing each layer. To access a specific layer, instead use GetLayer. More... | |
int | NumberOfLayers [get] |
Gets the number of layers represented. More... | |
int | StartingLayer [get] |
Starting index for layers included in this structure. More... | |
Properties inherited from GoRogue.IReadOnlySpatialMap< T > | |
int | Count [get] |
The number of items in the data structure. More... |
T | Type of element stored in the layered spatial map – must implement IHasLayer. |
T | Type of element stored in the layered spatial map – must implement IHasLayer. |
position | The position to check for. |
layerMask | Layer mask that indicates which layers to check. Defaults to all layers. |
layerMask | Layer mask that indicates which layers to check. Defaults to all layers. |
Implemented in GoRogue.AdvancedLayeredSpatialMap< T >.
@@ -272,11 +272,11 @@Implemented in GoRogue.AdvancedLayeredSpatialMap< T >.
@@ -312,7 +312,7 @@position | The position to return the item(s) for. |
layerMask | Layer mask that indicates which layers to check. Defaults to all layers. |
layerMask | Layer mask that indicates which layers to check. Defaults to all layers. |
layerMask | Layer mask indicating which layers to return. Defaults to all layers. |
layerMask | Layer mask indicating which layers to return. Defaults to all layers. |
Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedSpatialMap< T >, GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.IReadOnlyLayeredSpatialMap< T >.
+Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedMultiSpatialMap< T >, GoRogue.AdvancedSpatialMap< T >, and GoRogue.IReadOnlyLayeredSpatialMap< T >.
@@ -179,7 +179,7 @@Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedSpatialMap< T >, and GoRogue.AdvancedMultiSpatialMap< T >.
+Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.AdvancedSpatialMap< T >.
@@ -208,7 +208,7 @@Implemented in GoRogue.AdvancedSpatialMap< T >, and GoRogue.AdvancedMultiSpatialMap< T >.
+Implemented in GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.AdvancedSpatialMap< T >.
@@ -248,7 +248,7 @@Implemented in GoRogue.AdvancedSpatialMap< T >, and GoRogue.AdvancedMultiSpatialMap< T >.
+Implemented in GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.AdvancedSpatialMap< T >.
diff --git a/docs/interface_go_rogue_1_1_i_spatial_map.html b/docs/interface_go_rogue_1_1_i_spatial_map.html index 5f0d2dfb..30a351d8 100644 --- a/docs/interface_go_rogue_1_1_i_spatial_map.html +++ b/docs/interface_go_rogue_1_1_i_spatial_map.html @@ -216,7 +216,7 @@Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedSpatialMap< T >, and GoRogue.AdvancedMultiSpatialMap< T >.
+Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.AdvancedSpatialMap< T >.
@@ -263,7 +263,7 @@Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedSpatialMap< T >, and GoRogue.AdvancedMultiSpatialMap< T >.
+Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.AdvancedSpatialMap< T >.
@@ -284,7 +284,7 @@Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.AdvancedSpatialMap< T >.
@@ -324,7 +324,7 @@Implemented in GoRogue.AdvancedSpatialMap< T >, GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.AdvancedLayeredSpatialMap< T >.
+Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedSpatialMap< T >, and GoRogue.AdvancedMultiSpatialMap< T >.
@@ -371,7 +371,7 @@Implemented in GoRogue.AdvancedSpatialMap< T >, GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.AdvancedLayeredSpatialMap< T >.
+Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedSpatialMap< T >, and GoRogue.AdvancedMultiSpatialMap< T >.
@@ -494,7 +494,7 @@Implemented in GoRogue.AdvancedSpatialMap< T >, GoRogue.AdvancedMultiSpatialMap< T >, and GoRogue.AdvancedLayeredSpatialMap< T >.
+Implemented in GoRogue.AdvancedLayeredSpatialMap< T >, GoRogue.AdvancedSpatialMap< T >, and GoRogue.AdvancedMultiSpatialMap< T >.
diff --git a/docs/namespace_go_rogue.html b/docs/namespace_go_rogue.html index f297428e..f60e30f5 100644 --- a/docs/namespace_go_rogue.html +++ b/docs/namespace_go_rogue.html @@ -111,8 +111,8 @@