Use areas to make script more robust
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user