From 3d42886e90d2d41603d5741a3d5d07907f7758fe Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sat, 18 Sep 2021 12:29:50 +0900 Subject: - Waypoints? and new JPS Pathfinding Algorithm --- .../dungeonsguide/dungeon/roomfinder/DungeonRoom.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java index 5c6a7023..85970fa3 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -91,11 +91,9 @@ public class DungeonRoom { this.currentState = currentState; } - @Getter - private final PathFinder pathFinder; - public ScheduledFuture> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist) { - return asyncPathFinder.schedule(() -> { + ScheduledFuture> sf = asyncPathFinder.schedule(() -> { + PathFinder pathFinder = new PathFinder(nodeProcessorDungeonRoom); PathEntity latest = pathFinder.createEntityPathTo(blockaccess, entityIn, targetPos, dist); if (latest != null) { List poses = new ArrayList<>(); @@ -107,9 +105,11 @@ public class DungeonRoom { } return new ArrayList<>(); }, 0, TimeUnit.MILLISECONDS); + asyncPathFinder.schedule(() -> sf.cancel(true), 10, TimeUnit.SECONDS); + return sf; } - private static final ScheduledExecutorService asyncPathFinder = Executors.newScheduledThreadPool(2); + private static final ScheduledExecutorService asyncPathFinder = Executors.newScheduledThreadPool(4); @Getter private final NodeProcessorDungeonRoom nodeProcessorDungeonRoom; @@ -144,7 +144,6 @@ public class DungeonRoom { buildDoors(); buildRoom(); nodeProcessorDungeonRoom = new NodeProcessorDungeonRoom(this); - pathFinder = new PathFinder(nodeProcessorDungeonRoom); updateRoomProcessor(); } -- cgit