See More

using System; using System.Globalization; namespace CMAPI { ///

Represents a position in Planet Crafter's three-dimensional world. /// /// This CMAPI-owned value can be used by mods without referencing /// UnityEngine.Vector3. Equality compares the three floating-point /// components exactly. /// public readonly struct WorldPosition : IEquatable { /// Gets the horizontal X coordinate. public float X { get; } /// Gets the vertical Y coordinate. public float Y { get; } /// Gets the horizontal Z coordinate. public float Z { get; } /// Creates a world position from three coordinates. /// The horizontal X coordinate. /// The vertical Y coordinate. /// The horizontal Z coordinate. public WorldPosition(float x, float y, float z) { X = x; Y = y; Z = z; } /// Checks whether this position exactly matches another position. /// The position to compare. /// if all three coordinates are equal. public bool Equals(WorldPosition other) { return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z); } /// public override bool Equals(object? obj) { return obj is WorldPosition other && Equals(other); } /// public override int GetHashCode() { return HashCode.Combine(X, Y, Z); } /// Formats the position as (X, Y, Z). /// A culture-invariant, human-readable coordinate string. public override string ToString() { return string.Format( CultureInfo.InvariantCulture, "({0:0.##}, {1:0.##}, {2:0.##})", X, Y, Z ); } /// Checks two positions for exact coordinate equality. /// The first position to compare. /// The second position to compare. /// if all three coordinates are equal. public static bool operator ==(WorldPosition left, WorldPosition right) { return left.Equals(right); } /// Checks two positions for any coordinate difference. /// The first position to compare. /// The second position to compare. /// if any coordinate is different. public static bool operator !=(WorldPosition left, WorldPosition right) { return !left.Equals(right); } } }