1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-06-16 18:54:31 +02:00
MLEM/MLEM/Pathfinding/AStar2.cs

25 lines
910 B
C#
Raw Normal View History

using System;
using System.Linq;
using Microsoft.Xna.Framework;
2019-09-04 13:05:44 +02:00
using MLEM.Misc;
namespace MLEM.Pathfinding {
public class AStar2 : AStar<Point> {
2019-09-04 13:05:44 +02:00
private static readonly Point[] AdjacentDirs = Direction2Helper.Adjacent.Offsets().ToArray();
private static readonly Point[] AllDirs = Direction2Helper.All.Offsets().ToArray();
public AStar2(GetCost defaultCostFunction, bool defaultAllowDiagonals, float defaultCost = 1, int defaultMaxTries = 10000) :
base(AllDirs, AdjacentDirs, defaultCostFunction, defaultAllowDiagonals, defaultCost, defaultMaxTries) {
}
protected override Point AddPositions(Point first, Point second) {
return first + second;
}
protected override float GetManhattanDistance(Point first, Point second) {
return Math.Abs(second.X - first.X) + Math.Abs(second.Y - first.Y);
}
}
}