Skip to content

Struct Xz

Represents a 2D coordinate.

Namespace: VoxelTycoon

Constructors

Xz(int)

Creates a new Xz from an integer. X and Z members are set to the integer.

Declaration

public Xz(int xz)
Type Name Description
int xz Value given to X and Z

Xz(int, int)

Creates a new Xz from two integers representing X and Z.

Declaration

public Xz(int x, int z)
Type Name Description
int x X coordinate
int z Z coordinate

Xz(Vector3)

Creates a new Xz from a 3D vector. Only the x and z coordinates are used.

Declaration

public Xz(Vector3 vector3)
Type Name Description
Vector3 vector3 vector3.x is given to X and vector3.z to Z

Members

X

X coordinate.

Declaration

public int X
Type Description
int X coordinate

Z

Z coordinate.

Declaration

public int Z
Type Description
int Z coordinate

Properties

Forward

Xz forward instance, equivalent to Xz(0, 1).

Declaration

public static Xz Forward { get; }
Type Description
Xz Xz(0, 1)

Xz right instance, equivalent to Xz(1, 0).

Declaration

public static Xz Right { get; }
Type Description
Xz Xz(1, 0)

One

Xz one instance, equivalent to Xz(1, 1).

Declaration

public static Xz One { get; }
Type Description
Xz Xz(1, 1)

Zero

Xz zero instance, equivalent to Xz(0, 0).

Declaration

public static Xz Zero { get; }
Type Description
Xz Xz(0, 0)

Volume

Xz's volume, obtained by multiplying X and Z members.

Declaration

public int Volume { get; }
Type Description
int Equals X*Z

this[int]

Gets or sets the X and Z coordinates depending on the given value and index.

Declaration

public int this[int i] { get; set; }

Parameters

Type Name Description
int i X corresponds to i=0 and Z to i=1

Returns

Type Description
int X or Z depending on i's value

Methods

Abs()

Gets the absolute version of the Xz, equivalent to Xz(abs(x), abs(z)).

Declaration

public Xz Abs()
Type Description
Xz Xz(abs(x), abs(z))z

Deconstruct(int, int)

Deconstructs the Xz. Returns x and z values.

Declaration

public void Deconstruct(out int x, out int z)
Type Name Description
out int x X coordinate
out int z Z coordinate

Distance(Xz, Xz)

Returns the distance between two Xz.

Declaration

public static float Distance(Xz xz1, Xz xz2)

Parameters

Type Name Description
Xz xz1 First Xz
Xz xz2 Second Xz

Returns

Type Description
float Distance between xz1 and xz2

DistanceManhattan(Xz, Xz)

Returns the manhattan (taxicab) distance between two Xz.

Declaration

public static float DistanceManhattan(Xz xz1, Xz xz2)

Parameters

Type Name Description
Xz xz1 First Xz
Xz xz2 Second Xz

Returns

Type Description
float Manhattan distance between xz1 and xz2

Equals(object)

Tests if the Xz is equals to the object. They are equal if they are both Xz and their coordinates are equal.

Declaration

public override bool Equals(object obj)

Parameters

Type Name Description
object obj Object to compare the Xz with

Returns

Type Description
bool Returns true if obj is equals to the Xz

Equals(Xz)

Tests if two Xz are equals. Two Xzs are equal if their X and Z coordinates are equal.

Declaration

public bool Equals(Xz other)

Parameters

Type Name Description
Xz other Xz to compare with

Returns

Type Description
bool Returns true if the two Xz are equal

GetHashCode()

Returns the hash code of the Xz.

Declaration

public override int GetHashCode()

Returns

Type Description
int Value of the hash code

Max()

Returns the max of the coordinates of the Xz.

Declaration

public int Max()

Returns

Type Description
int Max between X and Z

Min()

Returns the min of the coordinates of the Xz.

Declaration

public int Min()

Returns

Type Description
int Min between X and Z

Max(Xz, Xz)

Returns a new Xz with the maximum of the coordinates between the two Xzs.

Declaration

public static Xz Max(Xz xz1, Xz xz2)

Parameters

Type Name Description
Xz xz1 First Xz
Xz xz2 Second Xz

Returns

Type Description
Xz Max Xz between xz1 and xz2

Min(Xz, Xz)

Returns a new Xz with the minimum of the coordinates between the two Xzs.

Declaration

public static Xz Min(Xz xz1, Xz xz2)

Parameters

Type Name Description
Xz xz1 First Xz
Xz xz2 Second Xz

Returns

Type Description
Xz Min Xz between xz1 and xz2

Rotate(BuildingRotation, Xz)

Rotate and translates a Xz.

Declaration

public Xz Rotate(BuildingRotation rotation, Xz translation = null)

Parameters

Type Name Description
BuildingRotation rotation Rotation to apply to the Xz
Xz translation Optional translation to apply to the Xz

Returns

Type Description
Xz Rotated and translated version of the Xz

SquaredDistance(Xz, Xz)

Returns the squared distance between two Xz.

Declaration

public static int SquaredDistance(Xz xz1, Xz xz2)

Parameters

Type Name Description
Xz xz1 First Xz
Xz xz2 Second Xz

Returns

Type Description
int Squared distance between xz1 and xz2

ToString()

Returns a string representing the Xz.

Declaration

public override string ToString()

Returns

Type Description
string String representing the Xz

Operators

+(Xz, Xz)

Returns the sum of two Xz which is calculated by the sum of each coordinates.

Declaration

public static Xz operator +(Xz xz, Xz xz2)

Parameters

Type Name Description
Xz xz First Xz
Xz xz2 Second Xz

Returns

Type Description
Xz Sum of xz and xz2

-(Xz, Xz)

Returns the substraction of two Xz which is calculated by the substraction of each coordinates.

Declaration

public static Xz operator -(Xz xz, Xz xz2)

Parameters

Type Name Description
Xz xz First Xz
Xz xz2 Second Xz

Returns

Type Description
Xz Substraction of xz and xz2

*(Xz, Xz)

Returns the multiplication of two Xz which is calculated by the multiplication of each coordinates.

Declaration

public static Xz operator *(Xz xz1, Xz xz2)

Parameters

Type Name Description
Xz xz1 First Xz
Xz xz2 Second Xz

Returns

Type Description
Xz Multiplication of xz1 and xz2

/(Xz, Xz)

Returns the division of two Xz which is calculated by the division of each coordinates.

Declaration

public static Xz operator /(Xz xz1, Xz xz2)

Parameters

Type Name Description
Xz xz1 First Xz
Xz xz2 Second Xz

Returns

Type Description
Xz Division of xz1 and xz2

*(Xz, int)

Returns the multiplication between an integer and a Xz. The result is calculated by multiplying each Xz coordinate by the integer.

Declaration

public static Xz operator *(Xz xz, int a)

Parameters

Type Name Description
Xz xz Xz to multiply
int a Integer to multiply

Returns

Type Description
Xz Multiplication of xz by a

/(Xz, int)

Returns the division of a Xz by an integer. The result is calculated by dividing each Xz coordinate by the integer.

Declaration

public static Xz operator /(Xz xz, int a)

Parameters

Type Name Description
Xz xz Divendent
int a Divider

Returns

Type Description
Xz Division of xz by a

/(Xz, float)

Returns the division of Xz by a float in a Vector3. The result is calculated by dividing each Xz coordinate by the float. The Y coordinate is set to 0.

Declaration

public static Vector3 operator /(Xz xz, float a)

Parameters

Type Name Description
Xz xz Divendent
float a Divider

Returns

Type Description
Vector3 Contains the division of xz by a

-(Xz)

Returns the opposite of the Xz which is calculated by getting the opposite of each coordinate.

Declaration

public static Xz operator -(Xz xz)

Parameters

Type Name Description
Xz xz Xz provided

Returns

Type Description
Xz Opposite of xz

Vector2(Xz)

Returns a Vector2 from a Xz.

Declaration

public static implicit operator Vector2(Xz xz)

Parameters

Type Name Description
Xz xz Xz provided

Returns

Type Description
Vector2 Contains xz's coordinates in its X and Y coordinates

Vector3(Xz)

Returns a Vector3 from a Xz. The Y coordinate is set to 0.

Declaration

public static explicit operator Vector3(Xz xz)

Parameters

Type Name Description
Xz xz Xz provided

Returns

Type Description
Vector3 Contains xz's coordinates in its X and Z coordinates

Xyz(Xz)

Returns a Xyz with a Xz's coordinates. The Y coordinate is set to 0.

Declaration

public static explicit operator Xyz(Xz xz)

Parameters

Type Name Description
Xz xz Xz provided

Returns

Type Description
Xyz Contains xz's coordinates in its X and Z coordinates

Xz(Xyz)

Returns a Xz with a Xyz's coordinates. The Y coordinate is not kept.

Declaration

public static explicit operator Xyz(Xz xz)

Parameters

Type Name Description
Xyz xyz Xyz provided

Returns

Type Description
Xz Contains xyz's X and Z coordinates

==(Xz, Xz)

Returns true if the two provided Xzs are equal.

Declaration

public static bool operator ==(Xz a, Xz b)

Parameters

Type Name Description
Xz a First Xz
Xz b Second Xz

Returns

Type Description
bool True if a and b are equal

!=(Xz, Xz)

Returns false if the two provided Xzs are equal.

Declaration

public static bool operator !=(Xz a, Xz b)

Parameters

Type Name Description
Xz a First Xz
Xz b Second Xz

Returns

Type Description
bool False if a and b are equal