Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GoRogue.Debugger/GoRogue.Debugger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<ItemGroup>
<!-- ReSharper disable once VulnerablePackage -->
<PackageReference Include="dotnet-curses" Version="1.0.2" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0">
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions GoRogue.PerformanceTests/GoRogue.PerformanceTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.15.0" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions GoRogue.UnitTests/GoRogue.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0">
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.101">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="RoyT.AStar" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
10 changes: 5 additions & 5 deletions GoRogue/GoRogue.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Basic package info -->
<TargetFrameworks>net5.0;net6.0;net7.0;net8.0;;net9.0;netcoreapp3.1;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net5.0;net6.0;net7.0;net8.0;;net9.0;net10.0;netcoreapp3.1;netstandard2.1</TargetFrameworks>
<RootNamespace>GoRogue</RootNamespace>
<Authors>Chris3606</Authors>
<Copyright>Copyright © 2025 Christopher Ridley (Chris3606)</Copyright>
Expand All @@ -11,7 +11,7 @@
Configure versioning information, making sure to append "debug" to Debug version to allow publishing
to NuGet seperately from Release version.
-->
<Version>3.0.0-beta10</Version>
<Version>3.0.0-beta11</Version>
<Version Condition="'$(Configuration)'=='Debug'">$(Version)-debug</Version>

<!-- More nuget package settings-->
Expand Down Expand Up @@ -79,17 +79,17 @@

<!-- Dependencies -->
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0">
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.101">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="OptimizedPriorityQueue" Version="4.2.0" />
<PackageReference Include="ShaiRandom" Version="0.0.2" />
<PackageReference Include="TheSadRogue.Primitives" Version="1.6.0-rc3" />
<PackageReference Include="TheSadRogue.Primitives" Version="1.6.0" />
</ItemGroup>

<!-- When packing, copy the nuget files to the nuget output directory -->
Expand Down
15 changes: 11 additions & 4 deletions GoRogue/Pathing/AStar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public Func<Point, Point, double> Heuristic
if (start == end)
{
var retVal = new List<Point> { start };
return new Path(retVal);
return new Path(retVal, 0);
}

// Update min weight if it has changed
Expand Down Expand Up @@ -275,7 +275,7 @@ public Func<Point, Point, double> Heuristic
if (current.Position == end) // We found the end, cleanup and return the path
{
_openNodes.Clear();

double cost = current.G;
do
{
result.Add(current.Position);
Expand All @@ -285,7 +285,7 @@ public Func<Point, Point, double> Heuristic
} while (current.Position != start);

result.Add(start);
return new Path(result);
return new Path(result, cost);
}

for (int i = 0; i < adjacencyRule.DirectionsOfNeighborsCache.Length; i++)
Expand Down Expand Up @@ -376,6 +376,7 @@ private bool CheckWalkability(Point pos, Point start, Point end, bool assumeEndp
[PublicAPI]
public class Path
{
private double _cost;
private readonly IReadOnlyList<Point> _steps;
private bool _inOriginalOrder;

Expand All @@ -388,14 +389,16 @@ public class Path
public Path(Path pathToCopy, bool reverse = false)
{
_steps = pathToCopy._steps;
_cost = pathToCopy._cost;
_inOriginalOrder = reverse ? !pathToCopy._inOriginalOrder : pathToCopy._inOriginalOrder;
}

// Create based on internal list
internal Path(IReadOnlyList<Point> steps)
internal Path(IReadOnlyList<Point> steps, double cost)
{
_steps = steps;
_inOriginalOrder = true;
_cost = cost;
}

/// <summary>
Expand All @@ -418,6 +421,10 @@ internal Path(IReadOnlyList<Point> steps)
/// </summary>
public Point Start => _inOriginalOrder ? _steps[^1] : _steps[0];

/// <summary>
/// The weighted cost of the path.
/// </summary>
public double Cost => _cost;

/// <summary>
/// The coordinates that constitute the path (in order), NOT including the starting point.
Expand Down
Loading