Show / Hide Table of Contents

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

Inheritance
System.Object
SettableTranslationMap<T1, T2>
LambdaSettableTranslationMap<T1, T2>
Implements
ISettableMapView<T2>
IMapView<T2>
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)
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 Source

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

| Improve this Doc View Source

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

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 Source

BaseMap

The underlying map.

Declaration
public ISettableMapView<T1> BaseMap { get; }
Property Value
Type Description
ISettableMapView<T1>
| Improve this Doc View Source

Height

The height of the underlying map.

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

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

Width

The width of the underlying map.

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

Methods

| Improve this Doc View Source

ToString()

Returns a string representation of the SettableTranslationMap.

Declaration
public override string ToString()
Returns
Type Description
System.String

A string representation of the SettableTranslationMap.

Overrides
System.Object.ToString()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

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