Table of Contents

Class InventoryPosition

Namespace
Squiggles.Core.Math
Assembly
SquigglesCommon4X.dll

For some reason Vector2I is not working well for equating for a SortedDictionary in the Item system. This serves to replace the Vector2I in that case. Note that all comparisons of InventoryPositions are operating on the HashCode which is generated as an integer index for an imaginary container of size HASH_CODE_CONTAINER_SIZE, which currently is 128 HASH_CODE_CONTAINER_SIZE

See also Godot.Vector2I
public class InventoryPosition : IEqualityComparer<InventoryPosition>, IComparable<InventoryPosition>
Inheritance
InventoryPosition
Implements
Inherited Members

Constructors

InventoryPosition()

public InventoryPosition()

InventoryPosition(int, int)

public InventoryPosition(int x, int y)

Parameters

x int
y int

Fields

HASH_CODE_CONTAINER_SIZE

private const int HASH_CODE_CONTAINER_SIZE = 128

Field Value

int

One

public static readonly InventoryPosition One

Field Value

InventoryPosition

Zero

public static readonly InventoryPosition Zero

Field Value

InventoryPosition

Properties

X

public int X { get; set; }

Property Value

int

Y

public int Y { get; set; }

Property Value

int

Methods

CompareTo(InventoryPosition)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(InventoryPosition other)

Parameters

other InventoryPosition

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

Copy()

public InventoryPosition Copy()

Returns

InventoryPosition

Equals(InventoryPosition, InventoryPosition)

Determines whether the specified objects are equal.

public bool Equals(InventoryPosition x, InventoryPosition y)

Parameters

x InventoryPosition

The first object of type T to compare.

y InventoryPosition

The second object of type T to compare.

Returns

bool

true if the specified objects are equal; otherwise, false.

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FromIndex(int, int)

public static InventoryPosition FromIndex(int index, int container_width)

Parameters

index int
container_width int

Returns

InventoryPosition

FromVector2I(Vector2I)

public static InventoryPosition FromVector2I(Vector2I vec)

Parameters

vec Vector2I

Returns

InventoryPosition

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetHashCode(InventoryPosition)

Returns a hash code for the specified object.

public int GetHashCode(InventoryPosition obj)

Parameters

obj InventoryPosition

The object for which a hash code is to be returned.

Returns

int

A hash code for the specified object.

Exceptions

ArgumentNullException

The type of obj is a reference type and obj is null.

ToIndex(int)

public int ToIndex(int container_width)

Parameters

container_width int

Returns

int

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

ToVector2I()

public Vector2I ToVector2I()

Returns

Vector2I

Operators

operator +(InventoryPosition, InventoryPosition)

public static InventoryPosition operator +(InventoryPosition vec, InventoryPosition vec2)

Parameters

vec InventoryPosition
vec2 InventoryPosition

Returns

InventoryPosition

operator +(InventoryPosition, int)

public static InventoryPosition operator +(InventoryPosition vec, int value)

Parameters

vec InventoryPosition
value int

Returns

InventoryPosition

operator /(InventoryPosition, InventoryPosition)

public static InventoryPosition operator /(InventoryPosition vec, InventoryPosition vec2)

Parameters

vec InventoryPosition
vec2 InventoryPosition

Returns

InventoryPosition

operator /(InventoryPosition, int)

public static InventoryPosition operator /(InventoryPosition vec, int value)

Parameters

vec InventoryPosition
value int

Returns

InventoryPosition

operator ==(InventoryPosition, InventoryPosition)

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

Parameters

a InventoryPosition
b InventoryPosition

Returns

bool

operator >(InventoryPosition, InventoryPosition)

public static bool operator >(InventoryPosition a, InventoryPosition b)

Parameters

a InventoryPosition
b InventoryPosition

Returns

bool

operator >=(InventoryPosition, InventoryPosition)

public static bool operator >=(InventoryPosition a, InventoryPosition b)

Parameters

a InventoryPosition
b InventoryPosition

Returns

bool

implicit operator Vector2I(InventoryPosition)

public static implicit operator Vector2I(InventoryPosition vec)

Parameters

vec InventoryPosition

Returns

Vector2I

operator !=(InventoryPosition, InventoryPosition)

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

Parameters

a InventoryPosition
b InventoryPosition

Returns

bool

operator <(InventoryPosition, InventoryPosition)

public static bool operator <(InventoryPosition a, InventoryPosition b)

Parameters

a InventoryPosition
b InventoryPosition

Returns

bool

operator <=(InventoryPosition, InventoryPosition)

public static bool operator <=(InventoryPosition a, InventoryPosition b)

Parameters

a InventoryPosition
b InventoryPosition

Returns

bool

operator *(InventoryPosition, InventoryPosition)

public static InventoryPosition operator *(InventoryPosition vec, InventoryPosition vec2)

Parameters

vec InventoryPosition
vec2 InventoryPosition

Returns

InventoryPosition

operator *(InventoryPosition, int)

public static InventoryPosition operator *(InventoryPosition vec, int value)

Parameters

vec InventoryPosition
value int

Returns

InventoryPosition

operator -(InventoryPosition, InventoryPosition)

public static InventoryPosition operator -(InventoryPosition vec, InventoryPosition vec2)

Parameters

vec InventoryPosition
vec2 InventoryPosition

Returns

InventoryPosition

operator -(InventoryPosition, int)

public static InventoryPosition operator -(InventoryPosition vec, int value)

Parameters

vec InventoryPosition
value int

Returns

InventoryPosition