Struct Point3D
Represents Point3D.
public struct Point3D : IPoint3D, IPoint2D, IComparable<Point3D>, IComparable<IPoint3D>, IEquatable<object>, IEquatable<Point3D>, IEquatable<IPoint3D>, ISpanFormattable, IFormattable, ISpanParsable<Point3D>, IParsable<Point3D>
- Implements
- Inherited Members
Constructors
Point3D(Point2D, int)
public Point3D(Point2D p, int z)
Parameters
Point3D(Point3D)
public Point3D(Point3D p)
Parameters
pPoint3D
Point3D(IPoint3D)
public Point3D(IPoint3D p)
Parameters
pIPoint3D
Point3D(int, int, int)
public Point3D(int x, int y, int z)
Parameters
Fields
Zero
public static readonly Point3D Zero
Field Value
Properties
X
Gets the X coordinate.
public int X { readonly get; set; }
Property Value
Y
Gets the Y coordinate.
public int Y { readonly get; set; }
Property Value
Z
Gets the Z coordinate.
public int Z { readonly get; set; }
Property Value
Methods
CompareTo(Point3D)
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(Point3D other)
Parameters
otherPoint3DAn 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.
CompareTo(IPoint3D)
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(IPoint3D other)
Parameters
otherIPoint3DAn 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.
Equals(Point3D)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Point3D other)
Parameters
otherPoint3DAn object to compare with this object.
Returns
Equals(IPoint3D)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(IPoint3D other)
Parameters
otherIPoint3DAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetBaseDirection(DirectionType)
Removes running flag from direction
public static DirectionType GetBaseDirection(DirectionType direction)
Parameters
directionDirectionTypeDirection with or without running flag
Returns
- DirectionType
Base direction without running flag
GetDirectionTo(Point3D)
Gets direction from current point to target point
public DirectionType GetDirectionTo(Point3D target)
Parameters
targetPoint3DTarget point
Returns
- DirectionType
Direction to target
GetDistance(Point3D)
Gets the 2D distance to another point (ignoring Z coordinate)
public double GetDistance(Point3D target)
Parameters
targetPoint3DTarget point
Returns
- double
Distance in tiles as double
GetDistance(IPoint3D)
Gets the 2D distance to another point (ignoring Z coordinate)
public double GetDistance(IPoint3D target)
Parameters
targetIPoint3DTarget point
Returns
- double
Distance in tiles as double
GetDistance3D(Point3D)
Gets the 3D distance to another point (including Z coordinate)
public double GetDistance3D(Point3D target)
Parameters
targetPoint3DTarget point
Returns
- double
Distance in tiles as double
GetDistance3D(IPoint3D)
Gets the 3D distance to another point (including Z coordinate)
public double GetDistance3D(IPoint3D target)
Parameters
targetIPoint3DTarget point
Returns
- double
Distance in tiles as double
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
InRange(Point3D, int)
Checks if another point is within the specified range of this point Uses 2D distance calculation (ignoring Z coordinate) like UO does
public bool InRange(Point3D target, int range)
Parameters
Returns
- bool
True if target is within range, false otherwise
InRange(IPoint3D, int)
Checks if another point is within the specified range of this point Uses 2D distance calculation (ignoring Z coordinate) like UO does
public bool InRange(IPoint3D target, int range)
Parameters
Returns
- bool
True if target is within range, false otherwise
InRange3D(Point3D, int)
Checks if another point is within the specified range of this point Uses 3D distance calculation (including Z coordinate)
public bool InRange3D(Point3D target, int range)
Parameters
Returns
- bool
True if target is within 3D range, false otherwise
InRange3D(IPoint3D, int)
Checks if another point is within the specified range of this point Uses 3D distance calculation (including Z coordinate)
public bool InRange3D(IPoint3D target, int range)
Parameters
Returns
- bool
True if target is within 3D range, false otherwise
IsRunning(DirectionType)
Checks if a direction includes running flag
public static bool IsRunning(DirectionType direction)
Parameters
directionDirectionTypeDirection to check
Returns
- bool
True if running flag is set
Move(DirectionType)
Adds a direction offset to current position
public Point3D Move(DirectionType direction)
Parameters
directionDirectionTypeDirection to move
Returns
- Point3D
New Point3D with offset applied
Parse(ReadOnlySpan<char>, IFormatProvider)
Parses a span of characters into a value.
public static Point3D Parse(ReadOnlySpan<char> s, IFormatProvider provider)
Parameters
sReadOnlySpan<char>The span of characters to parse.
providerIFormatProviderAn object that provides culture-specific formatting information about
s.
Returns
- Point3D
The result of parsing
s.
Exceptions
- FormatException
sis not in the correct format.- OverflowException
sis not representable by Point3D.
Parse(string)
public static Point3D Parse(string s)
Parameters
sstring
Returns
Parse(string, IFormatProvider)
Parses a string into a value.
public static Point3D Parse(string s, IFormatProvider provider)
Parameters
sstringThe string to parse.
providerIFormatProviderAn object that provides culture-specific formatting information about
s.
Returns
- Point3D
The result of parsing
s.
Exceptions
- ArgumentNullException
sis null.- FormatException
sis not in the correct format.- OverflowException
sis not representable by Point3D.
SetRunning(DirectionType)
Adds running flag to direction
public static DirectionType SetRunning(DirectionType direction)
Parameters
directionDirectionTypeBase direction
Returns
- DirectionType
Direction with running flag
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToString(string, IFormatProvider)
Formats the value of the current instance using the specified format.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider)
Tries to format the value of the current instance into the provided span of characters.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider provider)
Parameters
destinationSpan<char>The span in which to write this instance's value formatted as a span of characters.
charsWrittenintWhen this method returns, contains the number of characters that were written in
destination.formatReadOnlySpan<char>A span containing the characters that represent a standard or custom format string that defines the acceptable format for
destination.providerIFormatProviderAn optional object that supplies culture-specific formatting information for
destination.
Returns
TryParse(ReadOnlySpan<char>, IFormatProvider, out Point3D)
Tries to parse a span of characters into a value.
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider provider, out Point3D result)
Parameters
sReadOnlySpan<char>The span of characters to parse.
providerIFormatProviderAn object that provides culture-specific formatting information about
s.resultPoint3DWhen this method returns, contains the result of successfully parsing
s, or an undefined value on failure.
Returns
TryParse(string, IFormatProvider, out Point3D)
Tries to parse a string into a value.
public static bool TryParse(string s, IFormatProvider provider, out Point3D result)
Parameters
sstringThe string to parse.
providerIFormatProviderAn object that provides culture-specific formatting information about
s.resultPoint3DWhen this method returns, contains the result of successfully parsing
sor an undefined value on failure.
Returns
Operators
operator +(Point3D, Point3D)
Addition operator for Point3D
public static Point3D operator +(Point3D a, Point3D b)
Parameters
Returns
operator +(Point3D, DirectionType)
Addition operator for Point3D + DirectionType Moves the point in the specified direction
public static Point3D operator +(Point3D point, DirectionType direction)
Parameters
pointPoint3DdirectionDirectionType
Returns
operator +(DirectionType, Point3D)
Addition operator for DirectionType + Point3D Moves the point in the specified direction (commutative)
public static Point3D operator +(DirectionType direction, Point3D point)
Parameters
directionDirectionTypepointPoint3D
Returns
operator ==(Point3D, Point3D)
public static bool operator ==(Point3D l, Point3D r)
Parameters
Returns
operator ==(Point3D, IPoint3D)
public static bool operator ==(Point3D l, IPoint3D r)
Parameters
Returns
operator >(Point3D, Point3D)
public static bool operator >(Point3D l, Point3D r)
Parameters
Returns
operator >(Point3D, IPoint3D)
public static bool operator >(Point3D l, IPoint3D r)
Parameters
Returns
operator >=(Point3D, Point3D)
public static bool operator >=(Point3D l, Point3D r)
Parameters
Returns
operator >=(Point3D, IPoint3D)
public static bool operator >=(Point3D l, IPoint3D r)
Parameters
Returns
implicit operator DirectionType(Point3D)
Implicit conversion from Point3D to DirectionType Converts movement offset to direction (ignores Z coordinate)
public static implicit operator DirectionType(Point3D point)
Parameters
pointPoint3DPoint3D offset to convert
Returns
- DirectionType
DirectionType representing the movement direction
implicit operator Point3D(DirectionType)
Implicit conversion from DirectionType to Point3D offset Converts direction to movement offset coordinates
public static implicit operator Point3D(DirectionType direction)
Parameters
directionDirectionTypeDirection to convert
Returns
- Point3D
Point3D with offset coordinates
operator !=(Point3D, Point3D)
public static bool operator !=(Point3D l, Point3D r)
Parameters
Returns
operator !=(Point3D, IPoint3D)
public static bool operator !=(Point3D l, IPoint3D r)
Parameters
Returns
operator <(Point3D, Point3D)
public static bool operator <(Point3D l, Point3D r)
Parameters
Returns
operator <(Point3D, IPoint3D)
public static bool operator <(Point3D l, IPoint3D r)
Parameters
Returns
operator <=(Point3D, Point3D)
public static bool operator <=(Point3D l, Point3D r)
Parameters
Returns
operator <=(Point3D, IPoint3D)
public static bool operator <=(Point3D l, IPoint3D r)
Parameters
Returns
operator -(Point3D, Point3D)
Subtraction operator for Point3D
public static Point3D operator -(Point3D a, Point3D b)
Parameters
Returns
operator -(Point3D, DirectionType)
Subtraction operator for Point3D - DirectionType Moves the point in the opposite direction
public static Point3D operator -(Point3D point, DirectionType direction)
Parameters
pointPoint3DdirectionDirectionType