From 97113b1ae2203e5f980bda5c7103732bd00bca9b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 2 Sep 2023 20:21:51 +0200 Subject: [PATCH] Implement planToAnywhere Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/ai/LixfelPathplanner.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelPathplanner.java b/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelPathplanner.java index df56c82..b2e593e 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelPathplanner.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ai/LixfelPathplanner.java @@ -88,7 +88,15 @@ public class LixfelPathplanner { } public List planToAnywhere(Vector start, Vector destination) { - return plan(start, destination); //TODO (destination neighbor search) + Vector intermediate = walkable.stream().filter(vector -> neighbouring(vector, destination)).findAny().orElse(null); + + if(intermediate == null) + return Collections.emptyList(); + + List plan = plan(start, intermediate); + plan.add(destination); + + return plan; } public List plan(Vector start, Vector destination) {