Show / Hide Table of Contents

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

Inheritance
System.Object
SettableTranslationMap<T1, T2>
LambdaSettableTranslationMap<T1, T2>
Implements
ISettableMapView<T2>
IMapView<T2>
Inherited Members
SettableTranslationMap<T1, T2>.BaseMap
SettableTranslationMap<T1, T2>.Height
SettableTranslationMap<T1, T2>.Width
SettableTranslationMap<T1, T2>.Item[Int32]
SettableTranslationMap<T1, T2>.Item[Coord]
SettableTranslationMap<T1, T2>.Item[Int32, Int32]
SettableTranslationMap<T1, T2>.ToString()
SettableTranslationMap<T1, T2>.ToString(Func<T2, String>)
SettableTranslationMap<T1, T2>.ToString(Int32, Func<T2, String>)
SettableTranslationMap<T1, T2>.TranslateGet(T1)
SettableTranslationMap<T1, T2>.TranslateGet(Coord, T1)
SettableTranslationMap<T1, T2>.TranslateSet(T2)
SettableTranslationMap<T1, T2>.TranslateSet(Coord, T2)
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.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 Source

LambdaSettableTranslationMap(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 baseMap.

System.Func<T1, T2> getter

The TranslateGet implementation.

System.Func<T2, T1> setter

The TranslateSet implementation.

| Improve this Doc View Source

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 baseMap.

System.Func<Coord, T1, T2> getter

The TranslateGet implementation.

System.Func<Coord, T2, T1> setter

The TranslateSet implementation.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

TranslateGet(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
GoRogue.MapViews.SettableTranslationMap<T1, T2>.TranslateGet(GoRogue.Coord, T1)
| Improve this Doc View Source

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).

Overrides
GoRogue.MapViews.SettableTranslationMap<T1, T2>.TranslateSet(GoRogue.Coord, T2)

Implements

ISettableMapView<T>
IMapView<T>

Extension Methods

Utility.Yield<T>(T)
IMapViewExtensions.ApplyOverlay<T>(ISettableMapView<T>, IMapView<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