2026-03-22 18:31:05 +01:00
|
|
|
using ONDServer.Map;
|
2026-03-08 16:55:49 +01:00
|
|
|
|
2026-03-22 18:31:05 +01:00
|
|
|
namespace ONDServer.Enemies;
|
2026-03-08 16:55:49 +01:00
|
|
|
|
|
|
|
|
public abstract class Pathfinder {
|
|
|
|
|
public Enemy Enemy;
|
|
|
|
|
public Pathfinder(Enemy enemy) {
|
|
|
|
|
Enemy = enemy;
|
|
|
|
|
}
|
|
|
|
|
public abstract Decision DecideNext(MapTile goal);
|
|
|
|
|
// protected abstract Dictionary<MapTile, int> Crawl(MapTile tile); // fill Distances with all reachable tiles
|
|
|
|
|
|
|
|
|
|
protected virtual List<MapTile> GetNeighbours(MapTile tile, Predicate<TileConnector> connectorFilter, Predicate<MapTile> tileFilter) {
|
|
|
|
|
return tile.GetAllConnectors().Where(c => connectorFilter(c)).Select(c => c.OtherTile(tile)).Where(t => tileFilter(t)).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Decision {
|
|
|
|
|
public int type;
|
|
|
|
|
|
|
|
|
|
public MapTile? nextTile;
|
|
|
|
|
public ServerPlayer? attackTarget;
|
|
|
|
|
|
|
|
|
|
private Decision() { }
|
|
|
|
|
|
|
|
|
|
public static Decision Move(MapTile tile) => new() { type = MoveType, nextTile = tile };
|
|
|
|
|
public static Decision Attack(ServerPlayer player) => new(){ type = AttackType, attackTarget = player };
|
|
|
|
|
public static Decision Reset() => new(){ type = ResetType };
|
|
|
|
|
public static Decision Wait() => new(){ type = WaitType };
|
|
|
|
|
|
|
|
|
|
public const int MoveType = 0;
|
|
|
|
|
public const int AttackType = 1;
|
|
|
|
|
public const int ResetType = 2;
|
|
|
|
|
public const int WaitType = 3;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|