Show / Hide Table of Contents

Class Map

Base class for a map that consists of one or more objects of base type IGameObject. It implements basic functionality to manage and access these objects, as well as commonly needed functionality like tile exploration, FOV, and pathfinding. It also provides methods to easily access these objects as instances of some derived type, that can be used to access functionality you've implemented in a subclass.

Inheritance
System.Object
Map
Implements
IMapView<System.Collections.Generic.IEnumerable<IGameObject>>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GoRogue.GameFramework
Assembly: GoRogue.dll
Syntax
public class Map : IMapView<IEnumerable<IGameObject>>
Remarks

A Map consists of IGameObject instances 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 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.

Constructors

| Improve this Doc View Source

Map(ISettableMapView<IGameObject>, Int32, Distance, UInt32, UInt32, UInt32)

Constructor. Constructs map with the given terrain layer, determining width/height based on the width/height of that terrain layer.

Declaration
public Map(ISettableMapView<IGameObject> terrainLayer, int numberOfEntityLayers, Distance distanceMeasurement, uint layersBlockingWalkability = 4294967295U, uint layersBlockingTransparency = 4294967295U, uint entityLayersSupportingMultipleItems = 0U)
Parameters
Type Name Description
ISettableMapView<IGameObject> terrainLayer

The ISettableMapView<T> that represents the terrain layer for this map. After the map has been created, you should use the SetTerrain(IGameObject) function to modify the values in this map view, rather than setting the values via the map view itself -- if you re-assign the value at a location via the map view, the ObjectAdded/ObjectRemoved events are NOT guaranteed to be called, and many invariants of map may not be properly enforced.

System.Int32 numberOfEntityLayers

Number of non-terrain layers for the map.

Distance distanceMeasurement

Distance measurement to use for pathing/measuring distance on the map.

System.UInt32 layersBlockingWalkability

Layer mask containing those layers that should be allowed to have items that block walkability. Defaults to all layers.

System.UInt32 layersBlockingTransparency

Layer mask containing those layers that should be allowed to have items that block FOV. Defaults to all layers.

System.UInt32 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.

Remarks

Because of the way polymorphism works for custom classes in C#, the terrainLayer parameter MUST be of type ISettableMapView<T>, rather than ISettableMapView<T> where T is a type that derives from or implements IGameObject. If you need to use a map view storing type T rather than IGameObject, use the CreateMap<T>(ISettableMapView<T>, Int32, Distance, UInt32, UInt32, UInt32) function to create the map.

| Improve this Doc View Source

Map(Int32, Int32, Int32, Distance, UInt32, UInt32, UInt32)

Constructor. Constructs terrain map as ArrayMap<T>; with the given width/height.

Declaration
public Map(int width, int height, int numberOfEntityLayers, Distance distanceMeasurement, uint layersBlockingWalkability = 4294967295U, uint layersBlockingTransparency = 4294967295U, uint entityLayersSupportingMultipleItems = 0U)
Parameters
Type Name Description
System.Int32 width

Width of the map.

System.Int32 height

Height of the map.

System.Int32 numberOfEntityLayers

Number of non-terrain layers for the map.

Distance distanceMeasurement

Distance measurement to use for pathing/measuring distance on the map.

System.UInt32 layersBlockingWalkability

Layer mask containing those layers that should be allowed to have items that block walkability. Defaults to all layers.

System.UInt32 layersBlockingTransparency

Layer mask containing those layers that should be allowed to have items that block FOV. Defaults to all layers.

System.UInt32 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.

Fields

| Improve this Doc View Source

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.

Declaration
public ArrayMap<bool> Explored
Field Value
Type Description
ArrayMap<System.Boolean>

Properties

| Improve this Doc View Source

AStar

A* pathfinder for the map. By default, uses WalkabilityView to determine which locations can be reached, and calculates distance based on the Distance passed to the Map in the constructor.

Declaration
public AStar AStar { get; set; }
Property Value
Type Description
AStar
| Improve this Doc View Source

DistanceMeasurement

Distance measurement used for pathing and measuring distance on the map.

Declaration
public Distance DistanceMeasurement { get; }
Property Value
Type Description
Distance
| Improve this Doc View Source

Entities

IReadOnlyLayeredSpatialMap<T> of all entities (non-terrain objects) on the map.

Declaration
public IReadOnlyLayeredSpatialMap<IGameObject> Entities { get; }
Property Value
Type Description
IReadOnlyLayeredSpatialMap<IGameObject>
| Improve this Doc View Source

FOV

Current FOV results for the map. Calculate FOV via the Map's CalculateFOV functions.

Declaration
public IReadOnlyFOV FOV { get; }
Property Value
Type Description
IReadOnlyFOV
| Improve this Doc View Source

Height

Height of the map, in grid spaces.

Declaration
public int Height { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Item[Coord]

Gets all objects at the given location, from the highest layer (layer with the highest number) down.

Declaration
public IEnumerable<IGameObject> this[Coord pos] { get; }
Parameters
Type Name Description
Coord pos

The position to retrieve objects for.

Property Value
Type Description
System.Collections.Generic.IEnumerable<IGameObject>

All objects at the given location, in order from highest layer to lowest layer.

| Improve this Doc View Source

Item[Int32]

Gets all objects at the given location, from the highest layer (layer with the highest number) down.

Declaration
public IEnumerable<IGameObject> this[int index1D] { get; }
Parameters
Type Name Description
System.Int32 index1D

Location to retrieve objects for, specified as a 1D array-style index.

Property Value
Type Description
System.Collections.Generic.IEnumerable<IGameObject>

All objects at the given location, in order from highest layer to lowest layer.

| Improve this Doc View Source

Item[Int32, Int32]

Gets all objects at the given location, from the highest layer (layer with the highest number) down.

Declaration
public IEnumerable<IGameObject> this[int x, int y] { get; }
Parameters
Type Name Description
System.Int32 x

X-value of the position to retrieve objects for.

System.Int32 y

Y-value of the position to retrieve objects for.

Property Value
Type Description
System.Collections.Generic.IEnumerable<IGameObject>

All objects at the given location, in order from highest layer to lowest layer.

| Improve this Doc View Source

LayerMasker

LayerMasker that should be used to create layer masks for this Map.

Declaration
public LayerMasker LayerMasker { get; }
Property Value
Type Description
LayerMasker
| Improve this Doc View Source

LayersBlockingTransparency

Layer mask that contains only layers that block transparency. A non-transparent IGameObject can only be added to this map if the layer it is on is contained within this layer mask.

Declaration
public uint LayersBlockingTransparency { get; }
Property Value
Type Description
System.UInt32
| Improve this Doc View Source

LayersBlockingWalkability

Layer mask that contains only layers that block walkability. A non-walkable IGameObject can only be added to this map if the layer it resides on is contained within this layer mask.

Declaration
public uint LayersBlockingWalkability { get; }
Property Value
Type Description
System.UInt32
| Improve this Doc View Source

Terrain

Terrain of the map. Terrain at each location may be set via the SetTerrain(IGameObject) function.

Declaration
public IMapView<IGameObject> Terrain { get; }
Property Value
Type Description
IMapView<IGameObject>
| Improve this Doc View Source

TransparencyView

IMapView<T> representing transparency values for each tile. Each location returns true if the location is transparent (there are no non-transparent objects at that location), and false otherwise.

Declaration
public IMapView<bool> TransparencyView { get; }
Property Value
Type Description
IMapView<System.Boolean>
| Improve this Doc View Source

WalkabilityView

IMapView<T> representing walkability values for each tile. Each location is true if the location is walkable (there are no non-walkable objects at that location), and false otherwise.

Declaration
public IMapView<bool> WalkabilityView { get; }
Property Value
Type Description
IMapView<System.Boolean>
| Improve this Doc View Source

Width

Width of the map, in grid spaces.

Declaration
public int Width { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

AddEntity(IGameObject)

Adds the given entity (non-terrain object) to its recorded location, removing it from the map it is currently a part of. Returns true if the entity was added, and false otherwise (eg., collision detection would not allow it, etc.)

Declaration
public bool AddEntity(IGameObject entity)
Parameters
Type Name Description
IGameObject entity

Entity to add.

Returns
Type Description
System.Boolean

True if the entity was successfully added to the map, false otherwise.

| Improve this Doc View Source

ApplyTerrainOverlay(IMapView<IGameObject>)

Sets all terrain on the current map to be equal to the corresponding values from the map view you pass in. Equivalent to calling SetTerrain(IGameObject) once on each object in the map view you pass in. If translation between the overlay and IGameObject is required, see the overloads of this function that take a translation function.

Declaration
public void ApplyTerrainOverlay(IMapView<IGameObject> overlay)
Parameters
Type Name Description
IMapView<IGameObject> overlay

Map view specifying the terrain apply to the map. Must have identical dimensions to the current map.

| Improve this Doc View Source

ApplyTerrainOverlay<T>(IMapView<T>, Func<Coord, T, IGameObject>)

Sets all terrain on the map to the result of running the given translator on the value in overlay at the corresponding position. Useful, for example, for applying the map view resulting from map generation to a Map as terrain.

Declaration
public void ApplyTerrainOverlay<T>(IMapView<T> overlay, Func<Coord, T, IGameObject> translator)
Parameters
Type Name Description
IMapView<T> overlay

Map view to translate.

System.Func<Coord, T, IGameObject> translator

Function that translates values of the type that overlay exposes to values of type IGameObject.

Type Parameters
Name Description
T

Type of values exposed by map view to translate. Generally inferred by the compiler.

| Improve this Doc View Source

CalculateFOV(Coord, Double)

Calculates FOV with the given center point and radius (of shape circle), and stores the result in the FOV property. All tiles that are in the resulting FOV are marked as explored. This function calls the virtual overload CalculateFOV(Int32, Int32, Double, Distance), so if you need to override this functionality, override that overload instead.

Declaration
public void CalculateFOV(Coord position, double radius = 1.7976931348623157E+308)
Parameters
Type Name Description
Coord position

The center point of the new FOV to calculate.

System.Double radius

The radius of the FOV. Defaults to infinite.

| Improve this Doc View Source

CalculateFOV(Coord, Double, Distance)

Calculates FOV with the given center point and radius, and stores the result in the FOV property. All tiles that are in the resulting FOV are marked as explored. This function calls the virtual overload CalculateFOV(Int32, Int32, Double, Distance), so if you need to override this functionality, override that overload instead.

Declaration
public void CalculateFOV(Coord position, double radius, Distance radiusShape)
Parameters
Type Name Description
Coord position

The center point of the new FOV to calculate.

System.Double radius

The radius of the FOV. Defaults to infinite.

Distance radiusShape

The shape of the FOV to calculate. Can be specified as either Distance or Radius types (they are implicitly convertible).

| Improve this Doc View Source

CalculateFOV(Coord, Double, Distance, Double, Double)

Calculates FOV with the given center point and radius, restricted to the given angle and span, and stores the result in the FOV property. All tiles that are in the resulting FOV are marked as explored. This function calls the virtual overload CalculateFOV(Int32, Int32, Double, Distance, Double, Double), so if you need to override this functionality, override that overload instead.

Declaration
public void CalculateFOV(Coord position, double radius, Distance radiusShape, double angle, double span)
Parameters
Type Name Description
Coord position

The center point of the new FOV to calculate.

System.Double radius

The radius of the FOV. Defaults to infinite.

Distance radiusShape

The shape of the FOV to calculate. Can be specified as either Distance or Radius types (they are implicitly convertible).

System.Double angle

The angle in degrees the FOV cone faces. 0 degrees points right.

System.Double span

The angle in degrees specifying the full arc of the FOV cone. span/2 degrees on either side of the given angle are included in the cone.

| Improve this Doc View Source

CalculateFOV(Int32, Int32, Double)

Calculates FOV with the given center point and radius (of shape circle), and stores the result in the FOV property. All tiles that are in the resulting FOV are marked as explored. This function calls the virtual overload CalculateFOV(Int32, Int32, Double, Distance), so if you need to override this functionality, override that overload instead.

Declaration
public void CalculateFOV(int x, int y, double radius = 1.7976931348623157E+308)
Parameters
Type Name Description
System.Int32 x

X-value of the center point for the new FOV to calculate.

System.Int32 y

Y-value of the center point for the new FOV to calculate.

System.Double radius

The radius of the FOV. Defaults to infinite.

| Improve this Doc View Source

CalculateFOV(Int32, Int32, Double, Distance)

Calculates FOV with the given center point and radius, and stores the result in the FOV property. All tiles that are in the resulting FOV are marked as explored. Other non-angle-based overloads call this one, so if you need to override functionality, override this function.

Declaration
public virtual void CalculateFOV(int x, int y, double radius, Distance radiusShape)
Parameters
Type Name Description
System.Int32 x

X-value of the center point for the new FOV to calculate.

System.Int32 y

Y-value of the center point for the new FOV to calculate.

System.Double radius

The radius of the FOV. Defaults to infinite.

Distance radiusShape

The shape of the FOV to calculate. Can be specified as either Distance or Radius types (they are implicitly convertible).

| Improve this Doc View Source

CalculateFOV(Int32, Int32, Double, Distance, Double, Double)

Calculates FOV with the given center point and radius, restricted to the given angle and span, and stores the result in the FOV property. All tiles that are in the resulting FOV are marked as explored. Other angle-based overloads call this one, so if you need to override functionality, override this function.

Declaration
public virtual void CalculateFOV(int x, int y, double radius, Distance radiusShape, double angle, double span)
Parameters
Type Name Description
System.Int32 x

X-value of the center point for the new FOV to calculate.

System.Int32 y

Y-value of the center point for the new FOV to calculate.

System.Double radius

The radius of the FOV. Defaults to infinite.

Distance radiusShape

The shape of the FOV to calculate. Can be specified as either Distance or Radius types (they are implicitly convertible).

System.Double angle

The angle in degrees the FOV cone faces. 0 degrees points right.

System.Double span

The angle in degrees specifying the full arc of the FOV cone. span/2 degrees on either side of the given angle are included in the cone.

| Improve this Doc View Source

CreateMap<T>(ISettableMapView<T>, Int32, Distance, UInt32, UInt32, UInt32)

Effectively a helper-constructor. Constructs a map using an ISettableMapView<T> for the terrain map, where type T can be any type that implements IGameObject. Note that a Map that is constructed using this function will throw an System.InvalidCastException if any IGameObject is given to SetTerrain(IGameObject) that cannot be casted to type T.

Declaration
public static Map CreateMap<T>(ISettableMapView<T> terrainLayer, int numberOfEntityLayers, Distance distanceMeasurement, uint layersBlockingWalkability = 4294967295U, uint layersBlockingTransparency = 4294967295U, uint entityLayersSupportingMultipleItems = 0U)

    where T : IGameObject
Parameters
Type Name Description
ISettableMapView<T> terrainLayer

The ISettableMapView<T> that represents the terrain layer for this map. After the map has been created, you should use the SetTerrain(IGameObject) function to modify the values in this map view, rather than setting the values via the map view itself -- if you re-assign the value at a location via the map view, the ObjectAdded/ObjectRemoved events are NOT guaranteed to be called, and many invariants of map may not be properly enforced.

System.Int32 numberOfEntityLayers

Number of non-terrain layers for the map.

Distance distanceMeasurement

Distance measurement to use for pathing/measuring distance on the map.

System.UInt32 layersBlockingWalkability

Layer mask containing those layers that should be allowed to have items that block walkability. Defaults to all layers.

System.UInt32 layersBlockingTransparency

Layer mask containing those layers that should be allowed to have items that block FOV. Defaults to all layers.

System.UInt32 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.

Returns
Type Description
Map

A new Map whose terrain is created using the given terrainLayer, and with the given parameters.

Type Parameters
Name Description
T

The type of terrain that will be stored in the created Map. Can be any type that implements IGameObject.

Remarks

Suppose you have a class MyTerrain that inherits from BaseClass and implements IGameObject. This construction function allows you to construct your map using an ISettableMapView<T> instance as the terrain map, which you cannot do with the regular constructor since ISettableMapView<T> does not satisfy the constructor's type requirement of ISettableMapView<T>.

Since this function under the hood creates a SettableTranslationMap<T1, T2> that translates to/from IGameObject as needed, any change made using the map's SetTerrain(IGameObject) function will be reflected both in the map and in the original ISettableMapView.

| Improve this Doc View Source

GetEntities<EntityType>(Coord, UInt32)

Gets all (non-terrain) entities encountered at the given position that are castable to type EntityType, in order from the highest existing layer in the layer mask downward. Layer mask defaults to all layers.

Declaration
public IEnumerable<EntityType> GetEntities<EntityType>(Coord position, uint layerMask = 4294967295U)

    where EntityType : IGameObject
Parameters
Type Name Description
Coord position

Position to get entities for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
System.Collections.Generic.IEnumerable<EntityType>

All entities encountered at the given position that are castable to the given type, in order from the highest existing layer in the mask downward.

Type Parameters
Name Description
EntityType

Type of entities to return.

| Improve this Doc View Source

GetEntities<EntityType>(Int32, Int32, UInt32)

Gets all (non-terrain) entities encountered at the given position that are castable to type EntityType, in order from the highest existing layer in the layer mask downward. Layer mask defaults to all layers.

Declaration
public IEnumerable<EntityType> GetEntities<EntityType>(int x, int y, uint layerMask = 4294967295U)

    where EntityType : IGameObject
Parameters
Type Name Description
System.Int32 x

X-value of the position to get entities for.

System.Int32 y

Y-value of the position to get entities for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
System.Collections.Generic.IEnumerable<EntityType>

All entities encountered at the given position that are castable to the given type, in order from the highest existing layer in the mask downward.

Type Parameters
Name Description
EntityType

Type of entities to return.

| Improve this Doc View Source

GetEntity<EntityType>(Coord, UInt32)

Gets the first (non-terrain) entity encountered at the given position that can be casted to the specified type, moving from the highest existing layer in the layer mask downward. Layer mask defaults to all layers. null is returned if no entities of the specified type are found, or if there are no entities at the location.

Declaration
public EntityType GetEntity<EntityType>(Coord position, uint layerMask = 4294967295U)

    where EntityType : IGameObject
Parameters
Type Name Description
Coord position

Position to check get entity for.

System.UInt32 layerMask

Layer mask for which layers can return an entity. Defaults to all layers.

Returns
Type Description
EntityType

The first entity encountered, moving from the highest existing layer in the layer mask downward, or null if there are no entities of the specified type are found.

Type Parameters
Name Description
EntityType

Type of entities to return.

| Improve this Doc View Source

GetEntity<EntityType>(Int32, Int32, UInt32)

Gets the first (non-terrain) entity encountered at the given position that can be casted to the specified type, moving from the highest existing layer in the layer mask downward. Layer mask defaults to all layers. null is returned if no entities of the specified type are found, or if there are no entities at the location.

Declaration
public EntityType GetEntity<EntityType>(int x, int y, uint layerMask = 4294967295U)

    where EntityType : IGameObject
Parameters
Type Name Description
System.Int32 x

X-value of the position to get entity for.

System.Int32 y

Y-value of the position to get entity for.

System.UInt32 layerMask

Layer mask for which layers can return an entity. Defaults to all layers.

Returns
Type Description
EntityType

The first entity encountered, moving from the highest existing layer in the layer mask downward, or null if there are no entities of the specified type are found.

Type Parameters
Name Description
EntityType

Type of entities to return.

| Improve this Doc View Source

GetObject(Coord, UInt32)

Gets the first object encountered at the given position, moving from the highest existing layer in the layer mask downward. Layer mask defaults to all layers.

Declaration
public IGameObject GetObject(Coord position, uint layerMask = 4294967295U)
Parameters
Type Name Description
Coord position

Position to get object for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
IGameObject

The first object encountered, moving from the highest existing layer in the layer mask downward.

| Improve this Doc View Source

GetObject(Int32, Int32, UInt32)

Gets the first object encountered at the given position that can be casted to the specified type, moving from the highest existing layer in the layer mask downward. Layer mask defaults to all layers. null is returned if no objects of the specified type are found, or if there are no objects at the location.

Declaration
public IGameObject GetObject(int x, int y, uint layerMask = 4294967295U)
Parameters
Type Name Description
System.Int32 x

X-value of the position to get object for.

System.Int32 y

Y-value of the position to get object for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
IGameObject

The first object encountered, moving from the highest existing layer in the layer mask downward.

| Improve this Doc View Source

GetObject<ObjectType>(Coord, UInt32)

Gets the first object encountered at the given position that can be casted to the type specified, moving from the highest existing layer in the layer mask downward. Layer mask defaults to all layers. null is returned if no objects of the specified type are found, or if there are no objects at the location.

Declaration
public ObjectType GetObject<ObjectType>(Coord position, uint layerMask = 4294967295U)

    where ObjectType : class, IGameObject
Parameters
Type Name Description
Coord position

Position to get object for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
ObjectType

The first object encountered, moving from the highest existing layer in the layer mask downward, or null if there are no objects of the specified type are found.

Type Parameters
Name Description
ObjectType

Type of objects to return.

| Improve this Doc View Source

GetObject<ObjectType>(Int32, Int32, UInt32)

Gets the first object encountered at the given position that can be casted to the specified type, moving from the highest existing layer in the layer mask downward. Layer mask defaults to all layers. null is returned if no objects of the specified type are found, or if there are no objects at the location.

Declaration
public ObjectType GetObject<ObjectType>(int x, int y, uint layerMask = 4294967295U)

    where ObjectType : class, IGameObject
Parameters
Type Name Description
System.Int32 x

X-value of the position to get object for.

System.Int32 y

Y-value of the position to get object for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
ObjectType

The first object encountered, moving from the highest existing layer in the layer mask downward, or null if there are no objects of the specified type are found.

Type Parameters
Name Description
ObjectType

Type of objects to return.

| Improve this Doc View Source

GetObjects(Coord, UInt32)

Gets all objects encountered at the given position, in order from the highest existing layer in the layer mask downward. Layer mask defaults to all layers.

Declaration
public IEnumerable<IGameObject> GetObjects(Coord position, uint layerMask = 4294967295U)
Parameters
Type Name Description
Coord position

Position to get objects for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
System.Collections.Generic.IEnumerable<IGameObject>

All objects encountered at the given position, in order from the highest existing layer in the mask downward.

| Improve this Doc View Source

GetObjects(Int32, Int32, UInt32)

Gets all objects encountered at the given position, in order from the highest existing layer in the layer mask downward. Layer mask defaults to all layers.

Declaration
public IEnumerable<IGameObject> GetObjects(int x, int y, uint layerMask = 4294967295U)
Parameters
Type Name Description
System.Int32 x

X-value of the position to get objects for.

System.Int32 y

Y-value of the position to get objects for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
System.Collections.Generic.IEnumerable<IGameObject>

All objects encountered at the given position, in order from the highest existing layer in the mask downward.

| Improve this Doc View Source

GetObjects<ObjectType>(Coord, UInt32)

Gets all objects encountered at the given position that are castable to type ObjectType, in order from the highest existing layer in the layer mask downward. Layer mask defaults to all layers.

Declaration
public IEnumerable<ObjectType> GetObjects<ObjectType>(Coord position, uint layerMask = 4294967295U)

    where ObjectType : class, IGameObject
Parameters
Type Name Description
Coord position

Position to get objects for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
System.Collections.Generic.IEnumerable<ObjectType>

All objects encountered at the given position that are castable to the given type, in order from the highest existing layer in the mask downward.

Type Parameters
Name Description
ObjectType

Type of objects to return.

| Improve this Doc View Source

GetObjects<ObjectType>(Int32, Int32, UInt32)

Gets all objects encountered at the given position that are castable to type ObjectType, in order from the highest existing layer in the layer mask downward. Layer mask defaults to all layers.

Declaration
public IEnumerable<ObjectType> GetObjects<ObjectType>(int x, int y, uint layerMask = 4294967295U)

    where ObjectType : class, IGameObject
Parameters
Type Name Description
System.Int32 x

X-value of the position to get objects for.

System.Int32 y

Y-value of the position to get objects for.

System.UInt32 layerMask

Layer mask for which layers can return an object. Defaults to all layers.

Returns
Type Description
System.Collections.Generic.IEnumerable<ObjectType>

All objects encountered at the given position that are castable to the given type, in order from the highest existing layer in the mask downward.

Type Parameters
Name Description
ObjectType

Type of objects to return.

| Improve this Doc View Source

GetTerrain(Coord)

Gets the terrain object at the given location, or null if no terrain is set to that location.

Declaration
public IGameObject GetTerrain(Coord position)
Parameters
Type Name Description
Coord position

The position to get the terrain for.

Returns
Type Description
IGameObject

The terrain at the given postion, or null if no terrain exists at that location.

| Improve this Doc View Source

GetTerrain(Int32, Int32)

Gets the terrain object at the given location, or null if no terrain is set to that location.

Declaration
public IGameObject GetTerrain(int x, int y)
Parameters
Type Name Description
System.Int32 x

X-value of the position to get the terrain for.

System.Int32 y

Y-value of the position to get the terrain for.

Returns
Type Description
IGameObject

The terrain at the given postion, or null if no terrain exists at that location.

| Improve this Doc View Source

GetTerrain<TerrainType>(Coord)

Gets the terrain object at the given location, as a value of type TerrainType. Returns null if no terrain is set, or the terrain cannot be casted to the type specified.

Declaration
public TerrainType GetTerrain<TerrainType>(Coord position)

    where TerrainType : class, IGameObject
Parameters
Type Name Description
Coord position

The position to get the terrain for.

Returns
Type Description
TerrainType

The terrain at the given postion, or null if either no terrain exists at that location or the terrain was not castable to type TerrainType.

Type Parameters
Name Description
TerrainType

Type to check for/return the terrain as.

| Improve this Doc View Source

GetTerrain<TerrainType>(Int32, Int32)

Gets the terrain object at the given location, as a value of type TerrainType. Returns null if no terrain is set, or the terrain cannot be casted to the type specified.

Declaration
public TerrainType GetTerrain<TerrainType>(int x, int y)

    where TerrainType : class, IGameObject
Parameters
Type Name Description
System.Int32 x

X-value of the position to get the terrain for.

System.Int32 y

Y-value of the position to get the terrain for.

Returns
Type Description
TerrainType

The terrain at the given postion, or null if either no terrain exists at that location or the terrain was not castable to type TerrainType.

Type Parameters
Name Description
TerrainType

Type to return the terrain as.

| Improve this Doc View Source

RemoveEntity(IGameObject)

Removes the given entity (non-terrain object) from the map, returning true if it was successfully removed, and false otherwise.

Declaration
public bool RemoveEntity(IGameObject entity)
Parameters
Type Name Description
IGameObject entity

The entity to remove from the map.

Returns
Type Description
System.Boolean

True if the entity was removed successfully, false otherwise (eg, the entity was not part of this map).

| Improve this Doc View Source

SetTerrain(IGameObject)

Sets the terrain at the given objects location to the given object, overwriting any terrain already present there.

Declaration
public void SetTerrain(IGameObject terrain)
Parameters
Type Name Description
IGameObject terrain

Terrain to replace the current terrain with. terrain must have its IsStatic flag set to true and its Layer must be 0, or an exception will be thrown.

Events

| Improve this Doc View Source

ObjectAdded

Event that is fired whenever some object is added to the map.

Declaration
public event EventHandler<ItemEventArgs<IGameObject>> ObjectAdded
Event Type
Type Description
System.EventHandler<ItemEventArgs<IGameObject>>
| Improve this Doc View Source

ObjectMoved

Event that is fired whenever some object that is part of the map is successfully moved.

Declaration
public event EventHandler<ItemMovedEventArgs<IGameObject>> ObjectMoved
Event Type
Type Description
System.EventHandler<ItemMovedEventArgs<IGameObject>>
| Improve this Doc View Source

ObjectRemoved

Event that is fired whenever some object is removed from the map.

Declaration
public event EventHandler<ItemEventArgs<IGameObject>> ObjectRemoved
Event Type
Type Description
System.EventHandler<ItemEventArgs<IGameObject>>

Implements

IMapView<T>

Extension Methods

Utility.Yield<T>(T)
IMapViewExtensions.Bounds<T>(IMapView<T>)
IMapViewExtensions.Contains<T>(IMapView<T>, Int32, Int32)
IMapViewExtensions.Contains<T>(IMapView<T>, Coord)
IMapViewExtensions.ExtendToString<T>(IMapView<T>, String, String, Func<T, String>, String, String, String, String)
IMapViewExtensions.ExtendToString<T>(IMapView<T>, Int32, String, String, Func<T, String>, String, String, String, String)
IMapViewExtensions.Positions<T>(IMapView<T>)
IMapViewExtensions.RandomItem<T>(IMapView<T>, IGenerator)
IMapViewExtensions.RandomItem<T>(IMapView<T>, Func<Coord, T, Boolean>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, T, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IEnumerable<T>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, HashSet<T>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IGenerator, T[])
IMapViewExtensions.RandomPosition<T>(IMapView<T>, Func<Coord, T, Boolean>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IGenerator)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX