aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon
diff options
context:
space:
mode:
authorsyeyoung <cyougn06@naver.com>2022-01-31 23:16:26 +0900
committersyeyoung <cyougn06@naver.com>2022-01-31 23:16:26 +0900
commit33bc7744dceed33aa3220f351a43d2617f68183b (patch)
treeed58162a9467f28568c8baaf4e90ec571228e6fe /src/main/java/kr/syeyoung/dungeonsguide/dungeon
parentb518d47800ced4dd0f0e0250090826b5f0bace44 (diff)
downloadSkyblock-Dungeons-Guide-33bc7744dceed33aa3220f351a43d2617f68183b.tar.gz
Skyblock-Dungeons-Guide-33bc7744dceed33aa3220f351a43d2617f68183b.tar.bz2
Skyblock-Dungeons-Guide-33bc7744dceed33aa3220f351a43d2617f68183b.zip
- Add 3 new pathfinding algorithms
- Theta* - A* with finegrid used by jps - A* with finegrid used by jps + diagonal routes - Make MStringSelectionButton inc and dec button work as intended - Add new "feature" for choosing pathfind strategy
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java38
1 files changed, 33 insertions, 5 deletions
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 4052d2a0..2419f50a 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
@@ -19,7 +19,6 @@
package kr.syeyoung.dungeonsguide.dungeon.roomfinder;
import com.google.common.collect.Sets;
-import kr.syeyoung.dungeonsguide.DungeonsGuide;
import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
import kr.syeyoung.dungeonsguide.dungeon.MapProcessor;
import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo;
@@ -29,9 +28,8 @@ import kr.syeyoung.dungeonsguide.dungeon.events.DungeonStateChangeEvent;
import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic;
import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonRoomDoor;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
-import kr.syeyoung.dungeonsguide.pathfinding.CachedWorld;
-import kr.syeyoung.dungeonsguide.pathfinding.JPSPathfinder;
-import kr.syeyoung.dungeonsguide.pathfinding.NodeProcessorDungeonRoom;
+import kr.syeyoung.dungeonsguide.features.impl.secret.FeaturePathfindStrategy;
+import kr.syeyoung.dungeonsguide.pathfinding.*;
import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory;
import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor;
@@ -102,8 +100,13 @@ public class DungeonRoom {
this.currentState = currentState;
}
+ private Map<BlockPos, AStarFineGrid> activeBetterAStar = new HashMap<>();
+ private Map<BlockPos, AStarCornerCut> activeBetterAStarCornerCut = new HashMap<>();
+ private Map<BlockPos, ThetaStar> activeThetaStar = new HashMap<>();
+
public ScheduledFuture<List<Vec3>> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist, int timeout) {
- if (FeatureRegistry.SECRET_PATHFIND_STRATEGY.isEnabled()) {
+ FeaturePathfindStrategy.PathfindStrategy pathfindStrategy = FeatureRegistry.SECRET_PATHFIND_STRATEGY.getPathfindStrat();
+ if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.JPS_LEGACY) {
ScheduledFuture<List<Vec3>> sf = asyncPathFinder.schedule(() -> {
BlockPos min = new BlockPos(getMin().getX(), 0, getMin().getZ());
BlockPos max= new BlockPos(getMax().getX(), 255, getMax().getZ());
@@ -112,6 +115,30 @@ public class DungeonRoom {
return pathFinder.getRoute();
}, 0, TimeUnit.MILLISECONDS);
return sf;
+ } else if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.A_STAR_FINE_GRID) {
+ ScheduledFuture<List<Vec3>> sf = asyncPathFinder.schedule(() -> {
+ AStarFineGrid pathFinder =
+ activeBetterAStar.computeIfAbsent(targetPos, (pos) -> new AStarFineGrid(this, new Vec3(pos.getX(), pos.getY(), pos.getZ()).addVector(0.5, 0.5, 0.5)));
+ pathFinder.pathfind(entityIn.getPositionVector(),timeout);
+ return pathFinder.getRoute();
+ }, 0, TimeUnit.MILLISECONDS);
+ return sf;
+ }else if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.A_STAR_DIAGONAL) {
+ ScheduledFuture<List<Vec3>> sf = asyncPathFinder.schedule(() -> {
+ AStarCornerCut pathFinder =
+ activeBetterAStarCornerCut.computeIfAbsent(targetPos, (pos) -> new AStarCornerCut(this, new Vec3(pos.getX(), pos.getY(), pos.getZ()).addVector(0.5, 0.5, 0.5)));
+ pathFinder.pathfind(entityIn.getPositionVector(),timeout);
+ return pathFinder.getRoute();
+ }, 0, TimeUnit.MILLISECONDS);
+ return sf;
+ } else if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.THETA_STAR) {
+ ScheduledFuture<List<Vec3>> sf = asyncPathFinder.schedule(() -> {
+ ThetaStar pathFinder =
+ activeThetaStar.computeIfAbsent(targetPos, (pos) -> new ThetaStar(this, new Vec3(pos.getX(), pos.getY(), pos.getZ()).addVector(0.5, 0.5, 0.5)));
+ pathFinder.pathfind(entityIn.getPositionVector(),timeout);
+ return pathFinder.getRoute();
+ }, 0, TimeUnit.MILLISECONDS);
+ return sf;
} else {
ScheduledFuture<List<Vec3>> sf = asyncPathFinder.schedule(() -> {
PathFinder pathFinder = new PathFinder(nodeProcessorDungeonRoom);
@@ -276,6 +303,7 @@ public class DungeonRoom {
long arr[];
+ // These values are doubled
private final int minx, miny, minz, maxx, maxy, maxz;
private final int lenx, leny, lenz;
private static final float playerWidth = 0.3f;