OneNightDuel/ONDServer/Enemies/Pathfinder.cs

36 lines
1.2 KiB
C#
Raw Normal View History

using ONDServer.Map;
using ONDServer.Net;
namespace ONDServer.Enemies;
public abstract class Pathfinder {
public Enemy Enemy;
public Pathfinder(Enemy enemy) {
Enemy = enemy;
}
public abstract Decision DecideNext(MapTile goal);
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;
}
}