Skip to content

Commit

Permalink
small tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
CarnifexOptimus committed Jan 26, 2025
1 parent ad6c88c commit 1ee82c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions BossMod/Pathfinding/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,20 @@ public int AddGoal(Func<WPos, float> shape, float threshold, int minPriority, in
return result;
}

public List<(int x, int y, WPos center)> EnumeratePixels()
public (int x, int y, WPos center)[] EnumeratePixels()
{
var result = new List<(int x, int y, WPos center)>(Width * Height);
var result = new (int x, int y, WPos center)[(Width * Height)];
var rsq = Resolution * Resolution; // since we then multiply by _localZDivRes, end result is same as * res * rotation.ToDir()
var dx = LocalZDivRes.OrthoL() * rsq;
var dy = LocalZDivRes * rsq;
var cy = Center + (-Width * HalfPixel + HalfPixel) * dx + (-Height * HalfPixel + HalfPixel) * dy;

var index = 0;
for (var y = 0; y < Height; ++y)
{
var cx = cy;
for (var x = 0; x < Width; ++x)
{
result.Add((x, y, cx));
result[index++] = (x, y, cx);
cx += dx;
}
cy += dy;
Expand Down
7 changes: 5 additions & 2 deletions BossMod/Pathfinding/NavigationDecision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static NavigationDecision Build(Context ctx, WorldState ws, AIHints hints

for (var i = 0; i < len; ++i)
{
var inside = localForbiddenZones[i].shapeDistance(player.Position) <= forbiddenZoneCushion - 0.1f;
var inside = localForbiddenZones[i].shapeDistance(player.Position) <= 0.1f;
inZone[i] = inside;
if (inside)
{
Expand Down Expand Up @@ -328,8 +328,11 @@ public static NavigationDecision FindPathFromOutsideBounds(Context ctx, WPos sta
{
WPos? closest = null;
var closestDistance = float.MaxValue;
foreach (var p in ctx.Map.EnumeratePixels())
var map = ctx.Map.EnumeratePixels();
var len = map.Length;
for (var i = 0; i < len; ++i)
{
var p = map[i];
if (ctx.Map[p.x, p.y].MaxG > 0) // assume any pixel not marked as blocked is better than being outside of bounds
{
var distance = (p.center - startPos).LengthSq();
Expand Down

0 comments on commit 1ee82c8

Please sign in to comment.