fix: propagate parkour profiles through astar

This commit is contained in:
BruceChen 2026-04-18 16:14:04 +00:00
parent b4b0c6e8ed
commit 724880f928
2 changed files with 16 additions and 0 deletions

View file

@ -132,6 +132,20 @@ public sealed class LivePathingRegressionTests
Assert.Equal(scenario.Goal.Z + 0.5, segments[^1].End.Z);
}
[Fact]
public void AStar_LinearFlatGapFourChain_TagsParkourSegmentsAsDefaultProfile()
{
PathingExecutionScenario scenario = LinearParkourScenarioBuilder.Create("linear-flat-gap4", gap: 4, deltaY: 0);
PathResult result = PathingScenarioRunner.PlanOnly(scenario);
List<PathSegment> segments = PathSegmentBuilder.FromPath(result.Path);
Assert.Equal(PathStatus.Success, result.Status);
Assert.Equal(3, segments.Count(segment => segment.MoveType == MoveType.Parkour));
Assert.All(
segments.Where(segment => segment.MoveType == MoveType.Parkour),
segment => Assert.Equal(ParkourProfile.Default, segment.ParkourProfile));
}
[Theory]
[InlineData("linear-ascend-gap2-dy+1", 2, 1)]
[InlineData("linear-descend-gap4-dy-1", 4, -1)]

View file

@ -226,6 +226,7 @@ namespace MinecraftClient.Pathing.Core
neighbor.GCost = tentativeG;
neighbor.Parent = current;
neighbor.MoveUsed = move.Type;
neighbor.ParkourProfile = moveResult.ParkourProfile;
if (neighbor.IsOpen)
openSet.Update(neighbor);
}
@ -237,6 +238,7 @@ namespace MinecraftClient.Pathing.Core
HCost = goal.Heuristic(nx, ny, nz),
Parent = current,
MoveUsed = move.Type,
ParkourProfile = moveResult.ParkourProfile,
IsOpen = true
};
nodeMap[packed] = neighbor;