Class InventoryPosition
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.Vector2Ipublic 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
Fields
HASH_CODE_CONTAINER_SIZE
private const int HASH_CODE_CONTAINER_SIZE = 128
Field Value
One
public static readonly InventoryPosition One
Field Value
Zero
public static readonly InventoryPosition Zero
Field Value
Properties
X
public int X { get; set; }
Property Value
Y
public int Y { get; set; }
Property Value
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
otherInventoryPositionAn 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 otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
Copy()
public InventoryPosition Copy()
Returns
Equals(InventoryPosition, InventoryPosition)
Determines whether the specified objects are equal.
public bool Equals(InventoryPosition x, InventoryPosition y)
Parameters
xInventoryPositionThe first object of type
Tto compare.yInventoryPositionThe second object of type
Tto compare.
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current object.
Returns
FromIndex(int, int)
public static InventoryPosition FromIndex(int index, int container_width)
Parameters
Returns
FromVector2I(Vector2I)
public static InventoryPosition FromVector2I(Vector2I vec)
Parameters
vecVector2I
Returns
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
objInventoryPositionThe object for which a hash code is to be returned.
Returns
- int
A hash code for the specified object.
Exceptions
- ArgumentNullException
The type of
objis a reference type andobjis null.
ToIndex(int)
public int ToIndex(int container_width)
Parameters
container_widthint
Returns
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
vecInventoryPositionvec2InventoryPosition
Returns
operator +(InventoryPosition, int)
public static InventoryPosition operator +(InventoryPosition vec, int value)
Parameters
vecInventoryPositionvalueint
Returns
operator /(InventoryPosition, InventoryPosition)
public static InventoryPosition operator /(InventoryPosition vec, InventoryPosition vec2)
Parameters
vecInventoryPositionvec2InventoryPosition
Returns
operator /(InventoryPosition, int)
public static InventoryPosition operator /(InventoryPosition vec, int value)
Parameters
vecInventoryPositionvalueint
Returns
operator ==(InventoryPosition, InventoryPosition)
public static bool operator ==(InventoryPosition a, InventoryPosition b)
Parameters
Returns
operator >(InventoryPosition, InventoryPosition)
public static bool operator >(InventoryPosition a, InventoryPosition b)
Parameters
Returns
operator >=(InventoryPosition, InventoryPosition)
public static bool operator >=(InventoryPosition a, InventoryPosition b)
Parameters
Returns
implicit operator Vector2I(InventoryPosition)
public static implicit operator Vector2I(InventoryPosition vec)
Parameters
Returns
- Vector2I
operator !=(InventoryPosition, InventoryPosition)
public static bool operator !=(InventoryPosition a, InventoryPosition b)
Parameters
Returns
operator <(InventoryPosition, InventoryPosition)
public static bool operator <(InventoryPosition a, InventoryPosition b)
Parameters
Returns
operator <=(InventoryPosition, InventoryPosition)
public static bool operator <=(InventoryPosition a, InventoryPosition b)
Parameters
Returns
operator *(InventoryPosition, InventoryPosition)
public static InventoryPosition operator *(InventoryPosition vec, InventoryPosition vec2)
Parameters
vecInventoryPositionvec2InventoryPosition
Returns
operator *(InventoryPosition, int)
public static InventoryPosition operator *(InventoryPosition vec, int value)
Parameters
vecInventoryPositionvalueint
Returns
operator -(InventoryPosition, InventoryPosition)
public static InventoryPosition operator -(InventoryPosition vec, InventoryPosition vec2)
Parameters
vecInventoryPositionvec2InventoryPosition
Returns
operator -(InventoryPosition, int)
public static InventoryPosition operator -(InventoryPosition vec, int value)
Parameters
vecInventoryPositionvalueint