diff --git a/EDNA/Commander.cs b/EDNA/Commander.cs index 3397312..c5beb63 100644 --- a/EDNA/Commander.cs +++ b/EDNA/Commander.cs @@ -50,6 +50,6 @@ namespace alterNERDtive.Edna public StarSystem StarSystem { get; private set; } - public new Location Coordinates { get; private set; } + public new Coordinates Coordinates { get; private set; } } } diff --git a/EDNA/Locatable.cs b/EDNA/Locatable.cs index 1aed4bd..b982367 100644 --- a/EDNA/Locatable.cs +++ b/EDNA/Locatable.cs @@ -30,33 +30,34 @@ namespace alterNERDtive.Edna /// precision (all in ly). /// [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Either this or wrong class/struct order 🤷")] - public struct Location + public struct Coordinates { /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The x coordinate. /// The y coordinate. /// The z coordinate. /// The available precision. - public Location(double x, double y, double z, int precision) + public Coordinates(double x, double y, double z, int precision) => (this.X, this.Y, this.Z, this.Precision) = (x, y, z, precision); /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The x coordinate. /// The y coordinate. /// The z coordinate. - public Location(double x, double y, double z) + public Coordinates(double x, double y, double z) => (this.X, this.Y, this.Z, this.Precision) = (x, y, z, 0); /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// - /// An EDTS Location to convert. - public Location(Edts.Location location) - => (this.X, this.Y, this.Z, this.Precision) = (location.X, location.Y, location.Z, location.Precision); + /// An EDTS system/location to convert. + public Coordinates(Edts.StarSystem edtsSystem) + => (this.X, this.Y, this.Z, this.Precision) + = ((int)edtsSystem.Position.X, (int)edtsSystem.Position.Y, (int)edtsSystem.Position.Z, (int)edtsSystem.Uncertainty); /// /// Gets the x coordinate. @@ -79,15 +80,15 @@ namespace alterNERDtive.Edna /// public int Precision { get; } - public static bool operator ==(Location a, Location b) + public static bool operator ==(Coordinates a, Coordinates b) => a.X == b.X && a.Y == b.Y && a.Z == b.Z && a.Precision == 0 && b.Precision == 0; - public static bool operator !=(Location a, Location b) + public static bool operator !=(Coordinates a, Coordinates b) => !(a == b); /// public override bool Equals(object o) - => o is Location location && this == location; + => o is Coordinates location && this == location; /// public override int GetHashCode() @@ -100,7 +101,7 @@ namespace alterNERDtive.Edna /// /// The other location. /// The distance between both locations. - public Distance DistanceTo(Location location) + public Distance DistanceTo(Coordinates location) { if (this == location && this.Precision == 0) { @@ -173,7 +174,7 @@ namespace alterNERDtive.Edna /// /// Gets the object’s location in the galaxy. /// - public Location Coordinates { get; private set; } + public Coordinates Coordinates { get; private set; } /// /// The distance to another Locatable object. @@ -190,7 +191,7 @@ namespace alterNERDtive.Edna /// /// The Location to compare to. /// The distance to said Location. - public Distance DistanceTo(Location location) + public Distance DistanceTo(Coordinates location) { return this.Coordinates.DistanceTo(location); } diff --git a/Test/EDNA/DistanceTest.cs b/Test/EDNA/DistanceTest.cs index 42b4c27..88b9467 100644 --- a/Test/EDNA/DistanceTest.cs +++ b/Test/EDNA/DistanceTest.cs @@ -40,7 +40,7 @@ namespace Test.Edna { Distance distance; - distance = new Location(0, 0, 0).DistanceTo(new Location(10, 10, 10)); + distance = new Coordinates(0, 0, 0).DistanceTo(new Coordinates(10, 10, 10)); Assert.Equal(expected: Math.Round(17.3205080756888, 4), actual: Math.Round(distance.Value, 4)); Assert.Equal(expected: 0, actual: distance.Precision); } diff --git a/Test/EDNA/LocationTest.cs b/Test/EDNA/LocationTest.cs index bc2d8b3..a7e94ad 100644 --- a/Test/EDNA/LocationTest.cs +++ b/Test/EDNA/LocationTest.cs @@ -38,8 +38,8 @@ namespace Test.Edna [Fact] public void ZeroLocationEquals() { - Assert.Equal(new Location(0, 0, 0), new Location(0, 0, 0)); - Assert.Equal(new Location(0, 0, 0), new Location(0, 0, 0, 0)); + Assert.Equal(new Coordinates(0, 0, 0), new Coordinates(0, 0, 0)); + Assert.Equal(new Coordinates(0, 0, 0), new Coordinates(0, 0, 0, 0)); } /// @@ -49,14 +49,14 @@ namespace Test.Edna [Fact] public void NotEqualIfPrecisionDifferent() { - Assert.NotEqual(new Location(0, 0, 0), new Location(0, 0, 0, 1)); - Assert.NotEqual(new Location(0, 0, 0, 0), new Location(0, 0, 0, 1)); + Assert.NotEqual(new Coordinates(0, 0, 0), new Coordinates(0, 0, 0, 1)); + Assert.NotEqual(new Coordinates(0, 0, 0, 0), new Coordinates(0, 0, 0, 1)); - Assert.NotEqual(new Location(1, 2, 3), new Location(1, 2, 3, 1)); - Assert.NotEqual(new Location(1, 2, 3, 0), new Location(1, 2, 3, 1)); + Assert.NotEqual(new Coordinates(1, 2, 3), new Coordinates(1, 2, 3, 1)); + Assert.NotEqual(new Coordinates(1, 2, 3, 0), new Coordinates(1, 2, 3, 1)); - Assert.NotEqual(new Location(1.1, 2.2, 3.3), new Location(1.1, 2.2, 3.3, 1)); - Assert.NotEqual(new Location(1.1, 2.2, 3.3, 0), new Location(1.1, 2.2, 3.3, 1)); + Assert.NotEqual(new Coordinates(1.1, 2.2, 3.3), new Coordinates(1.1, 2.2, 3.3, 1)); + Assert.NotEqual(new Coordinates(1.1, 2.2, 3.3, 0), new Coordinates(1.1, 2.2, 3.3, 1)); } /// @@ -66,8 +66,8 @@ namespace Test.Edna [Fact] public void NotEqualIfSameImprecision() { - Assert.NotEqual(new Location(0, 0, 0, 5), new Location(0, 0, 0, 5)); - Assert.NotEqual(new Location(1, 2, 3, 5), new Location(1, 2, 3, 5)); + Assert.NotEqual(new Coordinates(0, 0, 0, 5), new Coordinates(0, 0, 0, 5)); + Assert.NotEqual(new Coordinates(1, 2, 3, 5), new Coordinates(1, 2, 3, 5)); } } } diff --git a/Test/EDNA/StarSystemTest.cs b/Test/EDNA/StarSystemTest.cs index 7c6f02b..29d58ca 100644 --- a/Test/EDNA/StarSystemTest.cs +++ b/Test/EDNA/StarSystemTest.cs @@ -35,11 +35,11 @@ namespace Test.Edna { Distance distance; - distance = StarSystem.Find("Sol").DistanceTo(new Location(0, 0, 0)); + distance = StarSystem.Find("Sol").DistanceTo(new Coordinates(0, 0, 0)); Assert.Equal(expected: 0, actual: distance.Value); Assert.Equal(expected: 0, actual: distance.Precision); - distance = StarSystem.Find("Sol").DistanceTo(new Location(0, 0, 0, 0)); + distance = StarSystem.Find("Sol").DistanceTo(new Coordinates(0, 0, 0, 0)); Assert.Equal(expected: 0, actual: distance.Value); Assert.Equal(expected: 0, actual: distance.Precision); }