Use areas to make script more robust

This commit is contained in:
2021-10-18 17:59:21 +02:00
parent bc6e82e409
commit 97d34e4415
2 changed files with 79 additions and 64 deletions

View File

@ -1,30 +1,24 @@
package io.reisub.dreambot.cagility;
import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.methods.interactive.Players;
import org.dreambot.api.methods.map.Area;
import org.dreambot.api.wrappers.interactive.GameObject;
public class Obstacle {
private final int id;
private final boolean retry;
private final Area[] areas;
private Obstacle next;
public Obstacle(int id, boolean canRetry) {
public Obstacle(int id, Area... areas) {
this.id = id;
this.retry = canRetry;
}
public Obstacle(int id) {
this(id, false);
this.areas = areas;
}
public int getID() {
return this.id;
}
public boolean canRetry() {
return this.retry;
}
public GameObject getGameObject() {
return GameObjects.closest(getID());
}
@ -36,4 +30,14 @@ public class Obstacle {
public void setNext(Obstacle next) {
this.next = next;
}
public boolean isPlayerInArea() {
for (Area area : areas) {
if (area.contains(Players.localPlayer())) {
return true;
}
}
return false;
}
}