Struct FaceData<ContainedData>
A generic struct that contains an instance of the specified type for each of the 6 faces on a cube.
Inherited Members
System.ValueType.Equals(System.Object)
System.ValueType.GetHashCode()
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Syntax
public struct FaceData<ContainedData>
Type Parameters
Name |
Description |
ContainedData |
|
Fields
back
Declaration
public ContainedData back
Field Value
Type |
Description |
ContainedData |
|
down
Declaration
public ContainedData down
Field Value
Type |
Description |
ContainedData |
|
forward
Declaration
public ContainedData forward
Field Value
Type |
Description |
ContainedData |
|
left
Declaration
public ContainedData left
Field Value
Type |
Description |
ContainedData |
|
right
Declaration
public ContainedData right
Field Value
Type |
Description |
ContainedData |
|
up
Declaration
Field Value
Type |
Description |
ContainedData |
|
Properties
Item[Face]
Get or set the data instance corresponding to a specific face.
Declaration
public ContainedData this[Face face] { get; set; }
Parameters
Type |
Name |
Description |
Face |
face |
|
Property Value
Type |
Description |
ContainedData |
|
Methods
Create(Func<ContainedData>)
Create a new FaceData, with each face taking a new value from creator
.
This is intended to allow you to generate a new instance of ContainedData for each face, for example you can create an empty list for each face of the new FaceData.
Declaration
public static FaceData<ContainedData> Create(Func<ContainedData> creator)
Parameters
Type |
Name |
Description |
Func<ContainedData> |
creator |
|
Returns
Type |
Description |
FaceData<ContainedData> |
|
Create<InitType>(Func<InitType, ContainedData>, InitType, InitType, InitType, InitType, InitType, InitType)
Create a new FaceData from a set of simple parameters and a converter that produces a more complex type.
This is intended to reduce boilerplate when generating FaceData for strongly typed ints e.g. FaceLayoutIndex.
Declaration
public static FaceData<ContainedData> Create<InitType>(Func<InitType, ContainedData> converter, InitType northInit, InitType eastInit, InitType southInit, InitType westInit, InitType upInit, InitType downInit)
Parameters
Type |
Name |
Description |
Func<InitType, ContainedData> |
converter |
|
InitType |
northInit |
|
InitType |
eastInit |
|
InitType |
southInit |
|
InitType |
westInit |
|
InitType |
upInit |
|
InitType |
downInit |
|
Returns
Type |
Description |
FaceData<ContainedData> |
|
Type Parameters
Name |
Description |
InitType |
|
Examples
In this example we can reduce boilerplate and increase readability when generating a FaceData<FaceLayoutIndex>:
var faceLayouts = FaceData<FaceLayoutIndex>.Create(
rawValue => FaceLayoutIndex.FromRawInt(rawValue),
1,
2,
3,
4,
5,
6
);
Create<InitType>(Func<InitType, ContainedData>, FaceData<InitType>)
Create a new FaceData from another FaceData with a different generic specialisation.
Each face will be passed through the converter
before being stored in the same face on the new FaceData.
Declaration
public static FaceData<ContainedData> Create<InitType>(Func<InitType, ContainedData> converter, FaceData<InitType> source)
Parameters
Type |
Name |
Description |
Func<InitType, ContainedData> |
converter |
|
FaceData<InitType> |
source |
|
Returns
Type |
Description |
FaceData<ContainedData> |
|
Type Parameters
Name |
Description |
InitType |
|
GetFace(Face)
Get the data instance corresponding to a specific face.
Declaration
public ContainedData GetFace(Face face)
Parameters
Type |
Name |
Description |
Face |
face |
|
Returns
Type |
Description |
ContainedData |
|
SetFace(Face, ContainedData)
Set the data instance corresponding to a specific face.
Declaration
public void SetFace(Face face, ContainedData newValue)
Parameters
Type |
Name |
Description |
Face |
face |
|
ContainedData |
newValue |
|