Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package at.hannibal2.skyhanni.config.features.event.diana

import at.hannibal2.skyhanni.config.FeatureToggle
import at.hannibal2.skyhanni.config.core.config.Position
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper
import com.google.gson.annotations.Expose
import io.github.notenoughupdates.moulconfig.ChromaColour
import io.github.notenoughupdates.moulconfig.annotations.Accordion
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink
Expand Down Expand Up @@ -150,10 +148,12 @@ class DianaConfig {
@ConfigLink(owner = DianaConfig::class, field = "burrowNearestWarp")
val warpGuiPosition: Position = Position(327, 125, scale = 2.6f)

@Expose
@ConfigOption(name = "Ignored Warps", desc = "Warps listed here will not be suggested.")
@ConfigEditorDraggableList
val ignoredWarpsList: MutableList<BurrowWarpHelper.WarpPoint> = mutableListOf(BurrowWarpHelper.WarpPoint.TAYLOR)

// TODO add a way to ignore warps, maybe with ; list via name
// @Expose
// @ConfigOption(name = "Ignored Warps", desc = "Warps listed here will not be suggested.")
// @ConfigEditorDraggableList
// val ignoredWarps: MutableList<String> = mutableListOf()

@Expose
@ConfigOption(
Expand Down
47 changes: 46 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.GraphUtils
import at.hannibal2.skyhanni.utils.GraphUtils.distanceSqToPlayer
import at.hannibal2.skyhanni.utils.GraphUtils.distanceToNode
import at.hannibal2.skyhanni.utils.GraphUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.GraphUtils.playerPosition
import at.hannibal2.skyhanni.utils.LorenzColor
Expand Down Expand Up @@ -139,10 +140,14 @@ object IslandGraphs {
private var cachedNearbyNodes = listOf<GraphNode>()
private var lastCacheUpdate = SimpleTimeMark.farPast()

// TODO create class for those things
private var currentTarget: LorenzVec? = null
private var currentTargetNode: GraphNode? = null
private var navigationLabel = ""
private var lastDisplayedDistance = 0.0
private var warpIsBetter = false
private var bestWarpPoint: GraphNode? = null
private var distanceToBestWarp = 0.0
private var totalDistance = 0.0
private var pathColor = Color.WHITE
private var allowRerouting = false
Expand Down Expand Up @@ -467,6 +472,9 @@ object IslandGraphs {
goal = null
pathRenderer = null
currentTargetNode = null
warpIsBetter = false
bestWarpPoint = null
distanceToBestWarp = 0.0
navigationLabel = ""
totalDistance = 0.0
lastDisplayedDistance = 0.0
Expand Down Expand Up @@ -518,6 +526,7 @@ object IslandGraphs {
require(label.isNotEmpty()) { "Label cannot be empty." }
resetNavigation()
allowRerouting = false
currentTargetNode = getGraph().getNearestNode(location)
initNavigation(location, label, color, onFound, onManualCancel, condition)
}

Expand Down Expand Up @@ -552,6 +561,7 @@ object IslandGraphs {

private fun updateNavigationProgress() {
if (navigationLabel == "") return
checkForWarps()
val distance = (pathRenderer?.remainingDistance ?: return).roundTo(1)

if (distance == lastDisplayedDistance) return
Expand All @@ -568,6 +578,39 @@ object IslandGraphs {
NavigationFeedback.sendPathFindMessage(component)
}

private fun checkForWarps() {
val graph = getGraph()
val targetNode = currentTargetNode ?: error("currentTargetNode is null")

val warp = bestWarpPoint ?: run {
val possibleWarps = graph.filterByActive { it.hasTag(GraphNodeTag.WARP) }
val warp = possibleWarps.minByOrNull { targetNode.distanceToNode(it) } ?: run {
warpIsBetter = false
bestWarpPoint = null
return
}
println("found nearest node: ${warp.name}")
bestWarpPoint = warp
distanceToBestWarp = warp.distanceToNode(targetNode)
warp
}
val command = warp.name ?: error("warp node without name")
val genericMargin = 20
val newWarpIsBetter = distanceToBestWarp + genericMargin < lastDisplayedDistance
if (newWarpIsBetter != warpIsBetter) {
warpIsBetter = newWarpIsBetter
if (newWarpIsBetter) {
println("warp is better!")
ChatUtils.clickableChat(
"click to run $command",
onClick = {
ChatUtils.sendMessageToServer(command)
},
)
}
}
}

fun cancelClick() {
stopNavigation()
onManualCancel()
Expand All @@ -576,7 +619,9 @@ object IslandGraphs {
@HandleEvent
fun onRenderWorld(event: SkyHanniRenderWorldEvent) {
if (currentIslandGraph == null) return
pathRenderer?.render(event)
if (!warpIsBetter) {
pathRenderer?.render(event)
}
}

fun isActive(testTarget: LorenzVec, testLabel: String): Boolean = testTarget == currentTarget && testLabel == navigationLabel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@
POI("poi", LorenzColor.WHITE, "Point of Interest", "A relevant spot or a landmark on the map.", onlySkyblock = null),

// LAUNCH_PAD("launch", LorenzColor.WHITE, "Launch Pad", "Slime blocks sending you to another server."),
TELEPORT("teleport", LorenzColor.BLUE, "Teleport", "A spot from/to teleport.", onlySkyblock = null),

// TODO delete once no graph data contains this anymore
// deprecated, dont use anymore
TELEPORT("teleport", LorenzColor.BLUE, "Teleport", "A spot from/to teleport. Deprecated, split up to warp, jump pad, and teleport pad", onlySkyblock = null),

Check warning on line 27 in src/main/java/at/hannibal2/skyhanni/data/model/graph/GraphNodeTag.kt

View workflow job for this annotation

GitHub Actions / Run detekt

detekt.style.MaxLineLength

Line detected, which is longer than the defined maximum line length in the code style.
// teleports from any island to this location on this island
WARP("warp", LorenzColor.BLUE, "Warp", "A warp command target.", onlySkyblock = null),
// stand there, jumps to another island, name is the other island
JUMP_PAD("jump_pad", LorenzColor.BLUE, "Jump Pad", "jump pad or portal to another island.", onlySkyblock = null),
// teleports around on the same island.
TELEPORT_PAD("teleport_pad", LorenzColor.BLUE, "Teleport Pad", "Teleport pad inside the same island.", onlySkyblock = null),

// on multiple islands
ROMEO("romeo", LorenzColor.WHITE, "Romeo & Juliette Quest", "Spots related to the Romeo and Juliette/Ring of Love quest line."),
Expand Down
Loading
Loading