Class LambdaSettableTranslationMap<T1, T2>
A simple SettableTranslationMap<T1, T2> implementation that allows you to provide functions/lambdas for the translation functions. For a version offering only "get" functionality, see LambdaTranslationMap<T1, T2>.
Inherited Members
Namespace: GoRogue.MapViews
Assembly: GoRogue.dll
Syntax
public sealed class LambdaSettableTranslationMap<T1, T2> : 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
If you have a view that simply exposes a property of your underlying data, it can be tedious to write a SettableTranslationMap<T1, T2> implementation for all of them. This class simplifies that task by letting you just provide the translation methods as funtions/lambdas without needing to build the rest of the class infrastructure.
Constructors
| Improve this Doc View SourceLambdaSettableTranslationMap(ISettableMapView<T1>, ISettableMapView<T2>, Func<T1, T2>, Func<T2, T1>)
Constructor. Takes an existing map view to create a view from and applies view data to it.
Declaration
public LambdaSettableTranslationMap(ISettableMapView<T1> baseMap, ISettableMapView<T2> overlay, Func<T1, T2> getter, Func<T2, T1> setter)
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 |
System.Func<T1, T2> | getter | The TranslateGet implementation. |
System.Func<T2, T1> | setter | The TranslateSet implementation. |
LambdaSettableTranslationMap(ISettableMapView<T1>, ISettableMapView<T2>, Func<Coord, T1, T2>, Func<Coord, T2, T1>)
Constructor. Takes an existing map view to create a view from and applies view data to it.
Declaration
public LambdaSettableTranslationMap(ISettableMapView<T1> baseMap, ISettableMapView<T2> overlay, Func<Coord, T1, T2> getter, Func<Coord, T2, T1> setter)
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 |
System.Func<Coord, T1, T2> | getter | The TranslateGet implementation. |
System.Func<Coord, T2, T1> | setter | The TranslateSet implementation. |
LambdaSettableTranslationMap(ISettableMapView<T1>, Func<T1, T2>, Func<T2, T1>)
Constructor. Takes an existing map view to create a view from, and getter/setter functions taking only a map value.
Declaration
public LambdaSettableTranslationMap(ISettableMapView<T1> baseMap, Func<T1, T2> getter, Func<T2, T1> setter)
Parameters
Type | Name | Description |
---|---|---|
ISettableMapView<T1> | baseMap | Your underlying map data. |
System.Func<T1, T2> | getter | The TranslateGet implementation. |
System.Func<T2, T1> | setter | The TranslateSet implementation. |
Remarks
If a position is also needed to perform the translation, an overload is provided taking corresponding functions.
LambdaSettableTranslationMap(ISettableMapView<T1>, Func<Coord, T1, T2>, Func<Coord, T2, T1>)
Constructor. Takes an existing map view to create a view from, and getter/setter functions taking a map value and its corresponding position.
Declaration
public LambdaSettableTranslationMap(ISettableMapView<T1> baseMap, Func<Coord, T1, T2> getter, Func<Coord, T2, T1> setter)
Parameters
Type | Name | Description |
---|---|---|
ISettableMapView<T1> | baseMap | Your underlying map data. |
System.Func<Coord, T1, T2> | getter | The TranslateGet implementation. |
System.Func<Coord, T2, T1> | setter | The TranslateSet implementation. |
Methods
| Improve this Doc View SourceTranslateGet(Coord, T1)
Translates your map data into the view type by calling the getter function specified in the class constructor.
Declaration
protected override T2 TranslateGet(Coord position, T1 value)
Parameters
Type | Name | Description |
---|---|---|
Coord | position | Position corresponding to given data value of your map. |
T1 | value | The data value from your map. |
Returns
Type | Description |
---|---|
T2 | A value of the mapped data type (via the getter specified in the class constructor). |
Overrides
TranslateSet(Coord, T2)
Translates the view type into the appropriate form for your map data, by calling the setter function specified in the class constructor.
Declaration
protected override T1 TranslateSet(Coord position, T2 value)
Parameters
Type | Name | Description |
---|---|---|
Coord | position | Position corresponding to the given mapped data type. |
T2 | value | A value of the mapped data type. |
Returns
Type | Description |
---|---|
T1 | The data value for your map, (via the setter specified in the class constructor). |