Skip to content

Commit c00a584

Browse files
committed
feat: create walkpath console command
1 parent 4f126dc commit c00a584

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

src/main/java/org/runejs/client/frame/DebugTools.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
import org.runejs.client.scene.Point2d;
66

77
public class DebugTools {
8+
public static boolean walkpathEnabled = false;
89
public static int[] walkpathX = null;
910
public static int[] walkpathY = null;
1011

1112
public static void drawWalkPath() {
12-
if (walkpathX == null) {
13+
if (!walkpathEnabled || walkpathX == null) {
1314
return;
1415
}
1516

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.runejs.client.frame.console.Commands;
2+
3+
import org.runejs.client.frame.DebugTools;
4+
import org.runejs.client.frame.console.Command;
5+
import org.runejs.client.frame.console.Console;
6+
7+
public class DebugWalkCommand extends Command {
8+
public DebugWalkCommand() {
9+
super(new String[]{"debugwalk"}, "Toggles debug walkpath");
10+
}
11+
12+
@Override
13+
public void execute(Console console, String[] cmdInput) {
14+
DebugTools.walkpathEnabled = !DebugTools.walkpathEnabled;
15+
if(DebugTools.walkpathEnabled) {
16+
console.log("<col=00FF00>Walkpath is now drawn</col>");
17+
} else {
18+
console.log("<col=FF0000>Walkpath is now hidden</col>");
19+
}
20+
}
21+
}

src/main/java/org/runejs/client/frame/console/Console.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ private void initialiseCommands() {
6262
commands.add(new ClearCommand());
6363
commands.add(new DebugCommand());
6464
commands.add(new DebugViewCommand());
65+
commands.add(new DebugWalkCommand());
6566
commands.add(new DebugWidgetsCommand());
6667
commands.add(new EchoCommand());
6768
commands.add(new PlayerRightsCommand());

src/main/java/org/runejs/client/media/renderable/actor/Pathfinding.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,15 @@ else if((waypoint & 0b1000) != 0)
250250
int x = walkingQueueX[currentIndex];
251251
int y = walkingQueueY[currentIndex];
252252

253-
DebugTools.walkpathX = new int[maxPathSize + 1];
254-
DebugTools.walkpathY = new int[maxPathSize + 1];
255-
256-
DebugTools.walkpathX[0] = startX;
257-
DebugTools.walkpathY[0] = startY;
258-
DebugTools.walkpathX[1] = x;
259-
DebugTools.walkpathY[1] = y;
253+
if (DebugTools.walkpathEnabled) {
254+
DebugTools.walkpathX = new int[maxPathSize + 1];
255+
DebugTools.walkpathY = new int[maxPathSize + 1];
256+
257+
DebugTools.walkpathX[0] = startX;
258+
DebugTools.walkpathY[0] = startY;
259+
DebugTools.walkpathX[1] = x;
260+
DebugTools.walkpathY[1] = y;
261+
}
260262

261263
WalkOutboundMessage.WalkType walkType = WalkOutboundMessage.WalkType.TILE;
262264

@@ -275,8 +277,11 @@ else if(clickType == 2) {
275277
currentIndex--;
276278
int stepX = walkingQueueX[currentIndex] - x;
277279
int stepY = walkingQueueY[currentIndex] - y;
278-
DebugTools.walkpathX[counter + 1] = walkingQueueX[currentIndex];
279-
DebugTools.walkpathY[counter + 1] = walkingQueueY[currentIndex];
280+
281+
if (DebugTools.walkpathEnabled) {
282+
DebugTools.walkpathX[counter + 1] = walkingQueueX[currentIndex];
283+
DebugTools.walkpathY[counter + 1] = walkingQueueY[currentIndex];
284+
}
280285

281286
steps.add(new WalkOutboundMessage.WalkStep(stepX, stepY));
282287
}

0 commit comments

Comments
 (0)