yep
This commit is contained in:
@@ -3,10 +3,17 @@
|
||||
namespace Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
|
||||
[DebuggerDisplay("{Direction} - {Distance}")]
|
||||
public record Path(Vector2 Direction, Distance Distance = Distance.OneStep)
|
||||
public record Path
|
||||
{
|
||||
public Vector2 NormalizedDirection { get; }
|
||||
public Distance Distance { get; }
|
||||
|
||||
public Path Invert() => new(Vector2.Negate(Direction), Distance);
|
||||
public Path(Vector2 direction, Distance distance = Distance.OneStep)
|
||||
{
|
||||
NormalizedDirection = Vector2.Normalize(direction);
|
||||
this.Distance = distance;
|
||||
}
|
||||
public Path Invert() => new(Vector2.Negate(NormalizedDirection), Distance);
|
||||
}
|
||||
|
||||
public static class PathExtensions
|
||||
@@ -21,8 +28,8 @@ public static class PathExtensions
|
||||
var shortestPath = paths.First();
|
||||
foreach (var path in paths.Skip(1))
|
||||
{
|
||||
var distance = Vector2.Distance(start + path.Direction, end);
|
||||
var shortestDistance = Vector2.Distance(start + shortestPath.Direction, end);
|
||||
var distance = Vector2.Distance(start + path.NormalizedDirection, end); //Normalizing the direction probably broke this.
|
||||
var shortestDistance = Vector2.Distance(start + shortestPath.NormalizedDirection, end); // And this.
|
||||
if (distance < shortestDistance)
|
||||
{
|
||||
shortestPath = path;
|
||||
|
||||
Reference in New Issue
Block a user