package productions.celestial.api.defaultoperations;
import com.runemate.game.api.hybrid.entities.GroundItem;
import com.runemate.game.api.hybrid.local.Camera;
import com.runemate.game.api.hybrid.location.navigation.Path;
import com.runemate.game.api.hybrid.location.navigation.basic.BresenhamPath;
import com.runemate.game.api.hybrid.region.GroundItems;
import com.runemate.game.api.hybrid.region.Players;
import com.runemate.game.api.script.Execution;
import com.runemate.game.api.script.framework.task.Task;
public class TakeAnagogicOrt extends Task {
private GroundItem ort = null;
@Override
public void execute() {
if (ort.isVisible()) {
if (ort.interact("Take", "Anagogic ort")) {
if (Execution.delayUntil(() -> Players.getLocal().isMoving(), 750)) {
Execution.delayUntil(() -> !Players.getLocal().isMoving(), 2000);
}
} else {
Camera.passivelyTurnTo(ort);
}
} else {
final Path p = BresenhamPath.buildTo(ort);
if (p != null && p.step(true)) {
Camera.passivelyTurnTo(ort);
Execution.delayUntil(() -> ort != null && ort.isVisible(), 2000);
}
}
}
@Override
public boolean validate() {
if (!Players.getLocal().isMoving()) {
ort = GroundItems.newQuery().names("Anagogic ort").actions("Take").reachable().results().first();
}
return ort != null;
}
}