diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-09-03 09:48:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-03 09:48:02 +0200 |
| commit | f5099a2b6d29099433e66781a8b26ab11e1902c8 (patch) | |
| tree | a5829c8680d4315ff254cad51f987ab0ef5b2d12 /src/main/java/at/hannibal2/skyhanni/test | |
| parent | e4f56d693a4c6cebb43006bfa507444d614072ca (diff) | |
| download | skyhanni-f5099a2b6d29099433e66781a8b26ab11e1902c8.tar.gz skyhanni-f5099a2b6d29099433e66781a8b26ab11e1902c8.tar.bz2 skyhanni-f5099a2b6d29099433e66781a8b26ab11e1902c8.zip | |
Backend: Graph Node Editor improvements (#2451)
Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/GraphEditor.kt | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/GraphEditor.kt b/src/main/java/at/hannibal2/skyhanni/test/GraphEditor.kt index 00fa25459..ababb9b65 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/GraphEditor.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/GraphEditor.kt @@ -367,17 +367,19 @@ object GraphEditor { } private fun editModeClicks() { - KeyboardManager.WasdInputMatrix.w.handleEditClicks(x = 1) - KeyboardManager.WasdInputMatrix.s.handleEditClicks(x = -1) - KeyboardManager.WasdInputMatrix.a.handleEditClicks(z = 1) - KeyboardManager.WasdInputMatrix.d.handleEditClicks(z = -1) - KeyboardManager.WasdInputMatrix.up.handleEditClicks(y = 1) - KeyboardManager.WasdInputMatrix.down.handleEditClicks(y = -1) + var vector = LocationUtils.calculatePlayerFacingDirection() + KeyboardManager.WasdInputMatrix.w.handleEditClicks(vector) + KeyboardManager.WasdInputMatrix.a.handleEditClicks(vector.rotateXZ(Math.toRadians(90.0))) + KeyboardManager.WasdInputMatrix.s.handleEditClicks(vector.rotateXZ(Math.toRadians(180.0))) + KeyboardManager.WasdInputMatrix.d.handleEditClicks(vector.rotateXZ(Math.toRadians(270.0))) + + KeyboardManager.WasdInputMatrix.up.handleEditClicks(LorenzVec(0, 1, 0)) + KeyboardManager.WasdInputMatrix.down.handleEditClicks(LorenzVec(0, -1, 0)) } - private fun KeyBinding.handleEditClicks(x: Int = 0, y: Int = 0, z: Int = 0) { + private fun KeyBinding.handleEditClicks(vector: LorenzVec) { if (this.keyCode.isKeyClicked()) { - activeNode?.position = activeNode?.position?.add(x, y, z) ?: return + activeNode?.position = activeNode?.position?.plus(vector) ?: return } } @@ -391,14 +393,20 @@ object GraphEditor { private fun addNode() { val closedNode = closedNode if (closedNode != null && closedNode.position.distanceSqToPlayer() < 9.0) { - feedBackInTutorial("Removed node, since you where closer than 3 blocks from a node.") - nodes.remove(closedNode) - edges.removeIf { it.isInEdge(closedNode) } - if (closedNode == activeNode) activeNode = null - this.closedNode = null - return + if (closedNode == activeNode) { + feedBackInTutorial("Removed node, since you where closer than 3 blocks from a the active node.") + nodes.remove(closedNode) + edges.removeIf { it.isInEdge(closedNode) } + if (closedNode == activeNode) activeNode = null + this.closedNode = null + return + } } val position = LocationUtils.playerEyeLocation().roundLocationToBlock() + if (nodes.any { it.position == position }) { + feedBackInTutorial("Can't create node, here is already another one.") + return + } val node = GraphingNode(id++, position) nodes.add(node) feedBackInTutorial("Added graph node.") |
