diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-09-20 22:37:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-20 22:37:38 +0200 |
commit | 08da9f51266d8f514a047cd3f9ffb5adfd7b29e8 (patch) | |
tree | de3810321a59bcd0872b6cafe1ad8ea9c74aacb9 /src/main/java/at/hannibal2/skyhanni/features/misc | |
parent | a99f0bdd1c2c5df1495996844dcf62791c19498d (diff) | |
download | skyhanni-08da9f51266d8f514a047cd3f9ffb5adfd7b29e8.tar.gz skyhanni-08da9f51266d8f514a047cd3f9ffb5adfd7b29e8.tar.bz2 skyhanni-08da9f51266d8f514a047cd3f9ffb5adfd7b29e8.zip |
Improvement: Area Navigation updates (#2537)
Co-authored-by: nea <nea@nea.moe>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt | 17 |
1 files changed, 4 insertions, 13 deletions
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 d85b34cc6..311af056e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.data.model.Graph import at.hannibal2.skyhanni.data.model.GraphNode import at.hannibal2.skyhanni.data.model.GraphNodeTag import at.hannibal2.skyhanni.data.model.TextInput -import at.hannibal2.skyhanni.data.model.findShortestPathAsGraphWithDistance import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.EntityMoveEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -19,6 +18,7 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils +import at.hannibal2.skyhanni.utils.GraphUtils import at.hannibal2.skyhanni.utils.LocationUtils.canBeSeen import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor @@ -65,19 +65,10 @@ object IslandAreas { val graph = IslandGraphs.currentIslandGraph ?: return val closedNote = IslandGraphs.closedNote ?: return - val paths = mutableMapOf<GraphNode, Graph>() - - val map = mutableMapOf<GraphNode, Double>() - for (graphNode in graph.nodes) { - if (graphNode.getAreaTag() == null) continue - val (path, distance) = graph.findShortestPathAsGraphWithDistance(closedNote, graphNode) - paths[graphNode] = path - map[graphNode] = distance - } + val (paths, map) = GraphUtils.findFastestPaths(graph, closedNote) { it.getAreaTag() != null } this.paths = paths val finalNodes = mutableMapOf<GraphNode, Double>() - val alreadyFoundAreas = mutableListOf<String>() for ((node, distance) in map.sorted()) { val areaName = node.name ?: continue @@ -271,8 +262,8 @@ object IslandAreas { private val allAreas = listOf(GraphNodeTag.AREA, GraphNodeTag.SMALL_AREA) private val onlyLargeAreas = listOf(GraphNodeTag.AREA) - private fun GraphNode.getAreaTag(): GraphNodeTag? = tags.firstOrNull { - it in (if (config.includeSmallAreas) allAreas else onlyLargeAreas) + fun GraphNode.getAreaTag(ignoreConfig: Boolean = false): GraphNodeTag? = tags.firstOrNull { + it in (if (config.includeSmallAreas || ignoreConfig) allAreas else onlyLargeAreas) } private fun setTarget(node: GraphNode) { |