Struct Vector
Represents a 2D coordinate or movement vector.
Inherited Members
Namespace: ExplorerGame.Core
Assembly: explorer-game.dll
Syntax
public struct Vector
Constructors
| Edit this page View SourceVector(int, int)
Initializes a new Vector with the specified coordinates.
Declaration
public Vector(int x, int y)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | The X-coordinate. |
| int | y | The Y-coordinate. |
Fields
| Edit this page View SourceZero
A zero vector at coordinates (0, 0).
Declaration
public static readonly Vector Zero
Field Value
| Type | Description |
|---|---|
| Vector |
Properties
| Edit this page View SourceX
X-coordinate.
Declaration
public int X { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Y
Y-coordinate.
Declaration
public int Y { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceEquals(object?)
Determines whether this instance and a specified object, which must also be a Vector, have the same coordinates.
Declaration
public override readonly bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
| Edit this page View SourceGetHashCode()
Returns a hash code for this vector.
Declaration
public override readonly int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit signed integer hash code. |
Overrides
| Edit this page View SourceToString()
Returns a string representation of the vector in the form (X, Y).
Declaration
public override readonly string ToString()
Returns
| Type | Description |
|---|---|
| string | A string describing this vector. |
Overrides
Operators
| Edit this page View Sourceoperator +(Vector, Vector)
Adds two vectors component-wise.
Declaration
public static Vector operator +(Vector a, Vector b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | a | The first vector. |
| Vector | b | The second vector. |
Returns
| Type | Description |
|---|---|
| Vector | The vector sum |
operator ==(Vector, Vector)
Determines whether two vectors are equal (same coordinates).
Declaration
public static bool operator ==(Vector a, Vector b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | a | The first vector. |
| Vector | b | The second vector. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator ==(Vector?, Vector?)
Determines whether two nullable vectors are equal.
Declaration
public static bool operator ==(Vector? a, Vector? b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector? | a | The first vector, or |
| Vector? | b | The second vector, or |
Returns
| Type | Description |
|---|---|
| bool |
|
operator !=(Vector, Vector)
Determines whether two vectors are not equal.
Declaration
public static bool operator !=(Vector a, Vector b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | a | The first vector. |
| Vector | b | The second vector. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator !=(Vector?, Vector?)
Determines whether two nullable vectors are not equal.
Declaration
public static bool operator !=(Vector? a, Vector? b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector? | a | The first vector, or |
| Vector? | b | The second vector, or |
Returns
| Type | Description |
|---|---|
| bool |
|
operator -(Vector, Vector)
Subtracts vector b from vector a component-wise.
Declaration
public static Vector operator -(Vector a, Vector b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | a | The minuend vector. |
| Vector | b | The subtrahend vector. |
Returns
| Type | Description |
|---|---|
| Vector | The vector difference |