diff options
author | syeyoung <cyoung06@naver.com> | 2021-09-18 12:29:50 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2021-09-18 12:29:50 +0900 |
commit | 3d42886e90d2d41603d5741a3d5d07907f7758fe (patch) | |
tree | 725c2c886d42fd9cb858a49bb9be326dbc6030d7 /src/main/java/kr/syeyoung/dungeonsguide/roomprocessor | |
parent | b5f5a1a613ab534e247c8eb04110344e2161d8d3 (diff) | |
download | Skyblock-Dungeons-Guide-3d42886e90d2d41603d5741a3d5d07907f7758fe.tar.gz Skyblock-Dungeons-Guide-3d42886e90d2d41603d5741a3d5d07907f7758fe.tar.bz2 Skyblock-Dungeons-Guide-3d42886e90d2d41603d5741a3d5d07907f7758fe.zip |
- Waypoints? and new JPS Pathfinding Algorithm
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomprocessor')
-rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java | 74 |
1 files changed, 53 insertions, 21 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index 20de9e9d..68b460cb 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -70,26 +70,37 @@ public class GeneralRoomProcessor implements RoomProcessor { public void tick() { if (!ticked && FeatureRegistry.SECRET_AUTO_START.isEnabled()) searchForNextTarget(); - - ticked = true; - if (path != null) { - path.onTick(); - if (FeatureRegistry.SECRET_AUTO_BROWSE_NEXT.isEnabled() && path.getCurrentAction() instanceof ActionComplete) { - if (!path.getState().equals("found")) return; - if (!(dungeonRoom.getMechanics().get(path.getMechanic()) instanceof DungeonSecret)) return; - searchForNextTarget(); + if (!ticked && FeatureRegistry.SECRET_PATHFIND_ALL.isEnabled()) { + for (Map.Entry<String, DungeonMechanic> value : getDungeonRoom().getDungeonRoomInfo().getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonSecret && ((DungeonSecret) value.getValue()).getSecretStatus(dungeonRoom) != DungeonSecret.SecretStatus.FOUND) { + pathfind(value.getKey(), "found"); + } } } + ticked = true; + + Set<String> toRemove = new HashSet<>(); + path.entrySet().forEach(a -> { + a.getValue().onTick(); + if (a.getValue().getCurrentAction() instanceof ActionComplete) + toRemove.add(a.getKey()); + }); + toRemove.forEach(path::remove); + for (DungeonMechanic value : dungeonRoom.getMechanics().values()) { if (value instanceof DungeonSecret) ((DungeonSecret) value).tick(dungeonRoom); } + + if (toRemove.contains("AUTO-BROWSE") && FeatureRegistry.SECRET_AUTO_BROWSE_NEXT.isEnabled()) { + searchForNextTarget(); + } } private final Set<String> visited = new HashSet<String>(); public void searchForNextTarget() { if (getDungeonRoom().getCurrentState() == DungeonRoom.RoomState.FINISHED) { - cancel(); + cancelAll(); return; } @@ -120,7 +131,7 @@ public class GeneralRoomProcessor implements RoomProcessor { } if (lowestWeightMechanic != null) { visited.add(lowestWeightMechanic.getKey()); - pathfind(lowestWeightMechanic.getKey(), "found"); + pathfind("AUTO-BROWSE", lowestWeightMechanic.getKey(), "found"); } else { visited.clear(); } @@ -128,7 +139,9 @@ public class GeneralRoomProcessor implements RoomProcessor { @Override public void drawScreen(float partialTicks) { - if (path != null) path.onRenderScreen(partialTicks); + path.values().forEach(a -> { + a.onRenderScreen(partialTicks); + }); if (FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && FeatureRegistry.DEBUG.isEnabled()) { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; @@ -154,8 +167,9 @@ public class GeneralRoomProcessor implements RoomProcessor { value.getValue().highlight(new Color(0,255,255,50), value.getKey(), dungeonRoom, partialTicks); } } - if (path != null) path.onRenderWorld(partialTicks); - + path.values().forEach(a -> { + a.onRenderWorld(partialTicks); + }); } @Override @@ -217,13 +231,25 @@ public class GeneralRoomProcessor implements RoomProcessor { } @Getter - private ActionRoute path; + private Map<String, ActionRoute> path = new HashMap<>(); - public void pathfind(String mechanic, String state) { - path = new ActionRoute(getDungeonRoom(), mechanic, state); + public ActionRoute getPath(String id){ + return path.get(id); + } + + public String pathfind(String mechanic, String state) { + String str; + pathfind(str = UUID.randomUUID().toString(), mechanic, state); + return str; + } + public void pathfind(String id, String mechanic, String state) { + path.put(id, new ActionRoute(getDungeonRoom(), mechanic, state)); + } + public void cancelAll() { + path.clear(); } - public void cancel() { - path = null; + public void cancel(String id) { + path.remove(id); } @Override @@ -251,13 +277,17 @@ public class GeneralRoomProcessor implements RoomProcessor { @Override public void onInteract(PlayerInteractEntityEvent event) { - if (path != null) path.onLivingInteract(event); + path.values().forEach(a -> { + a.onLivingInteract(event); + }); } private boolean last = false; @Override public void onInteractBlock(PlayerInteractEvent event) { - if (path != null) path.onPlayerInteract(event); + path.values().forEach(a -> { + a.onPlayerInteract(event); + }); if (event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() == Items.stick && @@ -280,7 +310,9 @@ public class GeneralRoomProcessor implements RoomProcessor { @Override public void onEntityDeath(LivingDeathEvent deathEvent) { - if (path != null) path.onLivingDeath(deathEvent); + path.values().forEach(a -> { + a.onLivingDeath(deathEvent); + }); if (EditingContext.getEditingContext() != null && EditingContext.getEditingContext().getRoom() == getDungeonRoom()) { if (deathEvent.entity instanceof EntityBat) { for (GuiScreen screen : EditingContext.getEditingContext().getGuiStack()) { |