diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-09-28 21:38:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-28 21:38:11 +0200 |
commit | f4419b8c77926fd160a04e5b888864e91ee17b0d (patch) | |
tree | 0d3d3020c83e4dda82a9b2350e622b7691cd47ec /src/main/java/at/hannibal2/skyhanni/features | |
parent | a610f68b510837789e6e375749e3a1afa324efcb (diff) | |
download | skyhanni-f4419b8c77926fd160a04e5b888864e91ee17b0d.tar.gz skyhanni-f4419b8c77926fd160a04e5b888864e91ee17b0d.tar.bz2 skyhanni-f4419b8c77926fd160a04e5b888864e91ee17b0d.zip |
abstracted navigation rerouting (#2597)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
6 files changed, 28 insertions, 21 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt index 468fecbcb..dbe06fbf9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt @@ -280,7 +280,7 @@ object HoppityEggLocator { val color = config.waypointColor.toChromaColor() - IslandGraphs.pathFind(location, color, condition = { config.showPathFinder }) + IslandGraphs.pathFind(location, "Hoppity Egg", color, condition = { config.showPathFinder }) } fun isValidEggLocation(location: LorenzVec): Boolean = HoppityEggLocations.islandLocations.any { it.distance(location) < 5.0 } @@ -333,7 +333,7 @@ object HoppityEggLocator { HoppityEggLocations.apiEggLocations[LorenzUtils.skyBlockIsland]?.let { for ((i, location) in it.values.withIndex()) { if (i == target) { - IslandGraphs.pathFind(location) + IslandGraphs.pathFind(location, "Hoppity Test") return } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt index 70e148aa9..c120c3d64 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt @@ -58,7 +58,10 @@ object HoppityNpc { "New rabbits are available at §aHoppity's Shop§e!", config::hoppityShopReminder, actionName = "warp to hub", - action = { HypixelCommands.warp("hub") }, + action = { + HypixelCommands.warp("hub") + //afterNextIslandwarpTtp hub: IslandGraphs.pathFind(hoppity) + }, ) lastReminderSent = SimpleTimeMark.now() diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt index 5214ff162..eb89da696 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt @@ -5,8 +5,6 @@ import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.model.Graph import at.hannibal2.skyhanni.data.model.GraphNode -import at.hannibal2.skyhanni.data.model.findShortestDistance -import at.hannibal2.skyhanni.data.model.findShortestPathAsGraphWithDistance import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -28,6 +26,7 @@ import at.hannibal2.skyhanni.utils.ColorUtils.getFirstColorCode import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.DelayedRun +import at.hannibal2.skyhanni.utils.GraphUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -81,6 +80,7 @@ object TunnelsMaps { private var active: String = "" private lateinit var fairySouls: Map<String, GraphNode> + // TODO what is this? why is there a difference? can this be replaced with GraphNodeTag.GRIND_ORES? private lateinit var newGemstones: Map<String, List<GraphNode>> private lateinit var oldGemstones: Map<String, List<GraphNode>> @@ -98,7 +98,7 @@ object TunnelsMaps { val list = possibleLocations[name] ?: return null val offCooldown = list.filter { cooldowns[it]?.isInPast() != false } - val best = offCooldown.minByOrNull { graph.findShortestDistance(closed, it) } ?: list.minBy { + val best = offCooldown.minByOrNull { GraphUtils.findShortestDistance(closed, it) } ?: list.minBy { cooldowns[it] ?: SimpleTimeMark.farPast() } if (cooldowns[best]?.isInPast() != false) { @@ -249,7 +249,8 @@ object TunnelsMaps { this.oldGemstones = oldGemstone normalLocations = other translateTable.clear() - DelayedRun.runNextTick { // Needs to be delayed since the config may not be loaded + DelayedRun.runNextTick { + // Needs to be delayed since the config may not be loaded locationDisplay = generateLocationsDisplay() } } @@ -398,7 +399,7 @@ object TunnelsMaps { val closest = closedNote ?: return val goal = goal ?: return if (closest == prevClosed && goal == prevGoal) return - val (path, distance) = graph.findShortestPathAsGraphWithDistance(closest, goal) + val (path, distance) = GraphUtils.findShortestPathAsGraphWithDistance(closest, goal) val first = path.firstOrNull() val second = path.getOrNull(1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt index 5ece5897c..cddbd201d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandGraphs +import at.hannibal2.skyhanni.data.IslandGraphs.pathFind import at.hannibal2.skyhanni.data.model.Graph import at.hannibal2.skyhanni.data.model.GraphNode import at.hannibal2.skyhanni.data.model.GraphNodeTag @@ -13,7 +14,6 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor @@ -81,7 +81,7 @@ object IslandAreas { nodes = finalNodes } - var hasMoved = false + private var hasMoved = false @SubscribeEvent fun onTick(event: LorenzTickEvent) { @@ -144,11 +144,6 @@ object IslandAreas { val isTarget = node.name == targetNode?.name val color = if (isTarget) LorenzColor.GOLD else tag.color - // trying to find a faster path to the existing target - if (isTarget && node != targetNode) { - ChatUtils.debug("Found a faster node, rerouting...") - setTarget(node) - } val coloredName = "${color.getChatColor()}${name}" var suffix = "" @@ -159,6 +154,7 @@ object IslandAreas { passedAreas.remove("null") passedAreas.remove(currentAreaName) // so show areas needed to pass thorough + // TODO show this pass through in the /shnavigate command if (passedAreas.isNotEmpty()) { // suffix = " §7${passedAreas.joinToString(", ")}" } @@ -268,9 +264,13 @@ object IslandAreas { private fun setTarget(node: GraphNode) { targetNode = node + val tag = node.getAreaTag() ?: return + val displayName = tag.color.getChatColor() + node.name val color = config.pathfinder.color.get().toChromaColor() - IslandGraphs.pathFind( - node.position, color, + node.pathFind( + displayName, + color, + allowRerouting = true, onFound = { targetNode = null updatePosition() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/pathfind/NavigationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/pathfind/NavigationHelper.kt index e753948bc..48719e63e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/pathfind/NavigationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/pathfind/NavigationHelper.kt @@ -2,11 +2,12 @@ package at.hannibal2.skyhanni.features.misc.pathfind import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandGraphs +import at.hannibal2.skyhanni.data.IslandGraphs.pathFind import at.hannibal2.skyhanni.data.model.GraphNode import at.hannibal2.skyhanni.data.model.GraphNodeTag -import at.hannibal2.skyhanni.data.model.findShortestDistance import at.hannibal2.skyhanni.features.misc.IslandAreas import at.hannibal2.skyhanni.utils.CollectionUtils.sorted +import at.hannibal2.skyhanni.utils.GraphUtils import at.hannibal2.skyhanni.utils.NumberUtil.roundTo import at.hannibal2.skyhanni.utils.chat.Text import at.hannibal2.skyhanni.utils.chat.Text.asComponent @@ -57,7 +58,8 @@ object NavigationHelper { val distance = distances[node]!!.roundTo(1) val component = "$name §e$distance".asComponent() component.onClick { - IslandGraphs.pathFind(node.position) +// node.pathFind(label = node.name!!, allowRerouting = true) + node.pathFind(label = name, allowRerouting = true) sendNavigateMessage(name, goBack) } val tag = node.tags.first { it in allowedTags } @@ -102,7 +104,7 @@ object NavigationHelper { val remainingTags = node.tags.filter { it in allowedTags } if (remainingTags.isEmpty()) continue if (name.lowercase().contains(searchTerm)) { - distances[node] = graph.findShortestDistance(closedNote, node) + distances[node] = GraphUtils.findShortestDistance(closedNote, node) } if (remainingTags.size != 1) { println("found node with invalid amount of tags: ${node.name} (${remainingTags.map { it.cleanName }}") diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt index 2a4613f7a..41ad12763 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt @@ -111,7 +111,8 @@ object EnigmaSoulWaypoints { ChatUtils.chat("§5Tracking the $name Enigma Soul!", prefixColor = "§5") if (config.showPathFinder) { soulLocations[name]?.let { - IslandGraphs.pathFind(it, config.color.toChromaColor(), condition = { config.showPathFinder }) + + IslandGraphs.pathFind(it, "$name Enigma Soul", config.color.toChromaColor(), condition = { config.showPathFinder }) } } trackedSouls.add(name) |