Class SettableTranslationMap<T1, T2>
Settable map view class capable of taking complex data and providing a simpler view of it. For a version that provides only "get" functionality, see TranslationMap<T1, T2>.
Inherited Members
Namespace: GoRogue.MapViews
Assembly: GoRogue.dll
Syntax
public abstract class SettableTranslationMap<T1, T2> : ISettableMapView<T2>, IMapView<T2>
Type Parameters
Name | Description |
---|---|
T1 | The type of your underlying data. |
T2 | The type of the data being exposed to the algorithm. |
Remarks
See TranslationMap<T1, T2>. The use case is the same, except that this class implements ISettableMapView<T> instead, and thus also allows you to specify set-translations via TranslateSet.
Constructors
| Improve this Doc View SourceSettableTranslationMap(ISettableMapView<T1>)
Constructor. Takes an existing map view to create a view from.
Declaration
protected SettableTranslationMap(ISettableMapView<T1> baseMap)
Parameters
Type | Name | Description |
---|---|---|
ISettableMapView<T1> | baseMap | Your underlying map data. |
SettableTranslationMap(ISettableMapView<T1>, ISettableMapView<T2>)
Constructor. Takes an existing map view to create a view from and applies view data to it.
Declaration
protected SettableTranslationMap(ISettableMapView<T1> baseMap, ISettableMapView<T2> overlay)
Parameters
Type | Name | Description |
---|---|---|
ISettableMapView<T1> | baseMap | Your underlying map data. |
ISettableMapView<T2> | overlay | The view data to apply to the map. Must have identical dimensions to |
Remarks
Since this constructor must call TranslateSet to perform its function, do NOT call this constructor if the TranslateSet implementation depends on the derived class's constructor being completed to function properly.
Properties
| Improve this Doc View SourceBaseMap
The underlying map.
Declaration
public ISettableMapView<T1> BaseMap { get; }
Property Value
Type | Description |
---|---|
ISettableMapView<T1> |
Height
The height of the underlying map.
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[Coord]
Given a position, translates and returns/sets the "value" associated with that position. The other indexers call this indexer for its functionality, so overriding this functionality also changes those overloads.
Declaration
public virtual T2 this[Coord pos] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Coord | pos | Location to get/set the value for. |
Property Value
Type | Description |
---|---|
T2 | The translated "value" associated with the provided location. |
Item[Int32]
Given an 1D-array-style index, determines the position associated with that index, and returns/sets the "value" associated with that location. This function calls Item[Coord], so override that indexer to change functionality.
Declaration
public T2 this[int index1D] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index1D | 1D-array-style index for location to retrieve/set value for. |
Property Value
Type | Description |
---|---|
T2 | The "value" associated with the given location, according to the translation function. |
Item[Int32, Int32]
Given an X and Y value, translates and returns/sets the "value" associated with that location. This function calls Item[Coord], so override that indexer to change functionality.
Declaration
public T2 this[int x, int y] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | X-value of location. |
System.Int32 | y | Y-value of location. |
Property Value
Type | Description |
---|---|
T2 | The translated "value" associated with that location. |
Width
The width of the underlying map.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceToString()
Returns a string representation of the SettableTranslationMap.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representation of the SettableTranslationMap. |
Overrides
ToString(Func<T2, String>)
Returns a string representation of the map view, using elementStringifier
to determine what string represents each value.
Declaration
public string ToString(Func<T2, string> elementStringifier)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T2, System.String> | elementStringifier | Function determining the string representation of each element. |
Returns
Type | Description |
---|---|
System.String | A string representation of the SettableTranslationMap. |
Remarks
This could be used, for example, on an SettableTranslationMap of boolean values, to output '#' for false values, and '.' for true values.
ToString(Int32, Func<T2, String>)
Prints the values in the map view, using the function specified to turn elements into strings, and using the "field length" specified.
Declaration
public string ToString(int fieldSize, Func<T2, string> elementStringifier = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fieldSize | The size of the field to give each value. A positive-number right-aligns the text within the field, while a negative number left-aligns the text. |
System.Func<T2, System.String> | elementStringifier | Function to use to convert each element to a string. null defaults to the ToString function of type T. |
Returns
Type | Description |
---|---|
System.String | A string representation of the SettableTranslationMap. |
Remarks
Each element of type T will have spaces added to cause it to take up exactly
fieldSize
characters, provided fieldSize
is less than the length of the element's string represention.
TranslateGet(T1)
Translates your map data into the view type. Takes only a value from the underlying map. If a position is also needed to perform the translation, use TranslateGet(Coord, T1) instead.
Declaration
protected virtual T2 TranslateGet(T1 value)
Parameters
Type | Name | Description |
---|---|---|
T1 | value | The data value from your map. |
Returns
Type | Description |
---|---|
T2 | A value of the mapped data type |
TranslateGet(Coord, T1)
Translates your map data into the view type. Takes a value from the underlying map and the corresponding position for that value. If a position is not needed to perform the translation, use TranslateGet(T1) instead.
Declaration
protected virtual T2 TranslateGet(Coord position, T1 value)
Parameters
Type | Name | Description |
---|---|---|
Coord | position | The position of the given data value from your map. |
T1 | value | The data value from your map. |
Returns
Type | Description |
---|---|
T2 | A value of the mapped data type |
TranslateSet(T2)
Translates the view type into the appropriate form for your map data. Takes only a value from the underlying map. If a position is also needed to perform the translation, use TranslateSet(Coord, T2) instead.
Declaration
protected virtual T1 TranslateSet(T2 value)
Parameters
Type | Name | Description |
---|---|---|
T2 | value | A value of the mapped data type |
Returns
Type | Description |
---|---|
T1 | The data value for your map. |
TranslateSet(Coord, T2)
Translates the view type into the appropriate form for your map data. Takes a value from the underlying map, and it corresponding position. If a position is not needed to perform the translation, use TranslateSet(T2) instead.
Declaration
protected virtual T1 TranslateSet(Coord position, T2 value)
Parameters
Type | Name | Description |
---|---|---|
Coord | position | The position of the given mapped data type. |
T2 | value | A value of the mapped data type |
Returns
Type | Description |
---|---|
T1 | The data value for your map. |