diff --git a/src/PolyZone.Debug/PolyZone.Debug.csproj b/src/PolyZone.Debug/PolyZone.Debug.csproj
index 0ad3bca..ffe1701 100644
--- a/src/PolyZone.Debug/PolyZone.Debug.csproj
+++ b/src/PolyZone.Debug/PolyZone.Debug.csproj
@@ -14,4 +14,8 @@
+
+
+
+
diff --git a/src/PolyZone.Debug/Script.cs b/src/PolyZone.Debug/Script.cs
index 49110c4..63e608c 100644
--- a/src/PolyZone.Debug/Script.cs
+++ b/src/PolyZone.Debug/Script.cs
@@ -1,6 +1,8 @@
-namespace PolyZone.Debug;
+using CitizenFX.Core;
-public class Script
+namespace PolyZone.Debug;
+
+public class Script : BaseScript
{
-}
\ No newline at end of file
+}
diff --git a/src/PolyZone.Tests/AssertionExtensions.cs b/src/PolyZone.Tests/AssertionExtensions.cs
deleted file mode 100644
index 5b6c759..0000000
--- a/src/PolyZone.Tests/AssertionExtensions.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace PolyZone.Tests;
-
-public class AssertionExtensions
-{
-
-}
\ No newline at end of file
diff --git a/src/PolyZone.Tests/Internal/Vector2Assertions.cs b/src/PolyZone.Tests/Internal/Vector2Assertions.cs
index 2710a1e..904f11a 100644
--- a/src/PolyZone.Tests/Internal/Vector2Assertions.cs
+++ b/src/PolyZone.Tests/Internal/Vector2Assertions.cs
@@ -2,7 +2,7 @@
using FluentAssertions;
using FluentAssertions.Execution;
using FluentAssertions.Primitives;
-using PolyZone.Shapes;
+using PolyZone.Shapes.Interfaces;
namespace PolyZone.Tests.Internal;
@@ -16,15 +16,14 @@ public static Vector2Assertions Should(this Vector2 instance)
public class Vector2Assertions(Vector2 instance) : ReferenceTypeAssertions(instance)
{
- private readonly Vector2 _instance = instance;
protected override string Identifier => "directory";
- public AndConstraint BeInside(Polygon polygon, string because = "", params object[] becauseArgs)
+ public AndConstraint BeInside(ISpatial2dShape shape, string because = "", params object[] becauseArgs)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
- .ForCondition(polygon.Contains(_instance))
- .FailWith($"Expected point to be inside polygon, point was { _instance.X }, { _instance.Y }");
+ .ForCondition(shape.Contains(instance))
+ .FailWith($"Expected point to be inside polygon, point was { instance.X }, { instance.Y }");
return new AndConstraint(this);
}
diff --git a/src/PolyZone.Tests/PolyZone.Tests.csproj b/src/PolyZone.Tests/PolyZone.Tests.csproj
index 8dacef4..1480849 100644
--- a/src/PolyZone.Tests/PolyZone.Tests.csproj
+++ b/src/PolyZone.Tests/PolyZone.Tests.csproj
@@ -6,7 +6,7 @@
false
true
- default
+ 12
diff --git a/src/PolyZone.Tests/Shapes/PolygonTests.cs b/src/PolyZone.Tests/Shapes/PolygonTests.cs
index 0a2db6a..596d9b6 100644
--- a/src/PolyZone.Tests/Shapes/PolygonTests.cs
+++ b/src/PolyZone.Tests/Shapes/PolygonTests.cs
@@ -1,25 +1,12 @@
-using System.Collections.Generic;
-using CitizenFX.Core;
+using CitizenFX.Core;
using FluentAssertions;
-using FluentAssertions.Execution;
-using FluentAssertions.Primitives;
using PolyZone.Shapes;
using PolyZone.Tests.Internal;
-using Xunit.Abstractions;
-
-// ReSharper disable ArrangeObjectCreationWhenTypeNotEvident
namespace PolyZone.Tests.Shapes;
public class PolygonTests
{
- private readonly ITestOutputHelper _testOutputHelper;
-
- public PolygonTests(ITestOutputHelper testOutputHelper)
- {
- _testOutputHelper = testOutputHelper;
- }
-
[Fact]
public void Polygon_A_IsInside_ShouldPassTest()
{
@@ -35,17 +22,17 @@ public void Polygon_A_IsInside_ShouldPassTest()
new Vector2 { X = -2f, Y = -8f }, // O (-3,-8)
new Vector2 { X = 2.26106f, Y = -9.30121f }, // P (2.26106,-9.30121)
};
-
- List points =
- [
- new() { X = 9.12f, Y = 4.2f }, // A (9.12,4.2)
- new() { X = -3.98f, Y = 3.32f }, // B (-3.98,3.32)
- new() { X = -4.56966f, Y = -3.5142f }, // C (-4.56966,-3.5142)
- new() { X = -3.56008f, Y = -9.12483f }, // D (-3.56008,-9.12483)
- new() { X = 3.75525f, Y = -9.88615f }, // E (3.75525,-9.88615)
- new() { X = -2.36844f, Y = -2.83563f }, // F (-2.36844,-2.83563)
- new() { X = -0.5f, Y = 2.06f } // G (-0.5,2.06)
- ];
+
+ var points = new[]
+ {
+ new Vector2 { X = 9.12f, Y = 4.2f }, // A (9.12,4.2)
+ new Vector2 { X = -3.98f, Y = 3.32f }, // B (-3.98,3.32)
+ new Vector2 { X = -4.56966f, Y = -3.5142f }, // C (-4.56966,-3.5142)
+ new Vector2 { X = -3.56008f, Y = -9.12483f }, // D (-3.56008,-9.12483)
+ new Vector2 { X = 3.75525f, Y = -9.88615f }, // E (3.75525,-9.88615)
+ new Vector2 { X = -2.36844f, Y = -2.83563f }, // F (-2.36844,-2.83563)
+ new Vector2 { X = -0.5f, Y = 2.06f } // G (-0.5,2.06)
+ };
var polygon = new Polygon(points);
@@ -54,7 +41,7 @@ public void Polygon_A_IsInside_ShouldPassTest()
point.Should().BeInside(polygon);
}
- var distance = polygon.DistanceFrom(new() { X = -1f, Y = 3.6f });
+ var distance = polygon.DistanceFrom(new Vector2 { X = -1f, Y = 3.6f });
distance.Should().BeGreaterThan(0);
}
diff --git a/src/PolyZone/Extensions/Vector2Extensions.cs b/src/PolyZone/Extensions/Vector2Extensions.cs
index b7e8981..e095130 100644
--- a/src/PolyZone/Extensions/Vector2Extensions.cs
+++ b/src/PolyZone/Extensions/Vector2Extensions.cs
@@ -1,12 +1,10 @@
using CitizenFX.Core;
-using PolyZone.Shapes;
+using PolyZone.Shapes.Interfaces;
namespace PolyZone.Extensions;
public static class Vector2Extensions
{
- /*public static float DistanceFrom(this Vector2 vector2, in Polygon polygon)
- {
- return vector2;
- }*/
+ public static bool IsInside(this Vector2 vector2, in ISpatial2dShape shape) => shape.Contains(vector2);
+ public static float DistanceTo(this Vector2 vector2, in ISpatial2dShape shape) => shape.DistanceFrom(vector2);
}
diff --git a/src/PolyZone/Properties/AssemblyInfo.cs b/src/PolyZone/Properties/AssemblyInfo.cs
deleted file mode 100644
index 9a1c36f..0000000
--- a/src/PolyZone/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-using System.Runtime.CompilerServices;
-
-[assembly: InternalsVisibleTo("PolyZone.Tests")]
diff --git a/src/PolyZone/Shapes/Interfaces/IPolygon.cs b/src/PolyZone/Shapes/Interfaces/IPolygon.cs
index c068f80..9eb6f25 100644
--- a/src/PolyZone/Shapes/Interfaces/IPolygon.cs
+++ b/src/PolyZone/Shapes/Interfaces/IPolygon.cs
@@ -1,9 +1,3 @@
-using CitizenFX.Core;
+namespace PolyZone.Shapes.Interfaces;
-namespace PolyZone.Shapes.Interfaces;
-
-public interface IPolygon
-{
- bool Contains(Vector2 point);
- float DistanceFrom(in Vector2 point);
-}
+public interface IPolygon : ISpatial2dShape;
diff --git a/src/PolyZone/Shapes/Interfaces/ISpatial2dShape.cs b/src/PolyZone/Shapes/Interfaces/ISpatial2dShape.cs
new file mode 100644
index 0000000..e8cdc86
--- /dev/null
+++ b/src/PolyZone/Shapes/Interfaces/ISpatial2dShape.cs
@@ -0,0 +1,9 @@
+using CitizenFX.Core;
+
+namespace PolyZone.Shapes.Interfaces;
+
+public interface ISpatial2dShape
+{
+ bool Contains(Vector2 point);
+ float DistanceFrom(in Vector2 point);
+}