Search in sources :

Example 1 with IBaritoneProcess

use of baritone.api.process.IBaritoneProcess in project baritone by cabaletta.

the class PathingControlManager method executeProcesses.

public PathingCommand executeProcesses() {
    for (IBaritoneProcess process : processes) {
        if (process.isActive()) {
            if (!active.contains(process)) {
                // put a newly active process at the very front of the queue
                active.add(0, process);
            }
        } else {
            active.remove(process);
        }
    }
    // ties are broken by which was added to the beginning of the list first
    active.sort(Comparator.comparingDouble(IBaritoneProcess::priority).reversed());
    Iterator<IBaritoneProcess> iterator = active.iterator();
    while (iterator.hasNext()) {
        IBaritoneProcess proc = iterator.next();
        PathingCommand exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel());
        if (exec == null) {
            if (proc.isActive()) {
                throw new IllegalStateException(proc.displayName() + " actively returned null PathingCommand");
            }
        // no need to call onLostControl; they are reporting inactive.
        } else if (exec.commandType != PathingCommandType.DEFER) {
            inControlThisTick = proc;
            if (!proc.isTemporary()) {
                iterator.forEachRemaining(IBaritoneProcess::onLostControl);
            }
            return exec;
        }
    }
    return null;
}
Also used : PathingCommand(baritone.api.process.PathingCommand) IBaritoneProcess(baritone.api.process.IBaritoneProcess)

Example 2 with IBaritoneProcess

use of baritone.api.process.IBaritoneProcess in project baritone by cabaletta.

the class ProcCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    args.requireMax(0);
    IPathingControlManager pathingControlManager = baritone.getPathingControlManager();
    IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null);
    if (process == null) {
        throw new CommandInvalidStateException("No process in control");
    }
    logDirect(String.format("Class: %s\n" + "Priority: %f\n" + "Temporary: %b\n" + "Display name: %s\n" + "Last command: %s", process.getClass().getTypeName(), process.priority(), process.isTemporary(), process.displayName(), pathingControlManager.mostRecentCommand().map(PathingCommand::toString).orElse("None")));
}
Also used : IPathingControlManager(baritone.api.pathing.calc.IPathingControlManager) IBaritoneProcess(baritone.api.process.IBaritoneProcess) CommandInvalidStateException(baritone.api.command.exception.CommandInvalidStateException)

Example 3 with IBaritoneProcess

use of baritone.api.process.IBaritoneProcess in project Spark-Client by Spark-Client-Development.

the class ETACommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    args.requireMax(0);
    IPathingControlManager pathingControlManager = baritone.getPathingControlManager();
    IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null);
    if (process == null) {
        throw new CommandInvalidStateException("No process in control");
    }
    IPathingBehavior pathingBehavior = baritone.getPathingBehavior();
    logDirect(String.format("Next segment: %.2f\n" + "Goal: %.2f", pathingBehavior.ticksRemainingInSegment().orElse(-1.0), pathingBehavior.estimatedTicksToGoal().orElse(-1.0)));
}
Also used : IPathingControlManager(baritone.api.pathing.calc.IPathingControlManager) IBaritoneProcess(baritone.api.process.IBaritoneProcess) CommandInvalidStateException(baritone.api.command.exception.CommandInvalidStateException) IPathingBehavior(baritone.api.behavior.IPathingBehavior)

Example 4 with IBaritoneProcess

use of baritone.api.process.IBaritoneProcess in project Spark-Client by Spark-Client-Development.

the class PathingControlManager method cancelEverything.

public void cancelEverything() {
    // called by PathingBehavior on TickEvent Type OUT
    inControlLastTick = null;
    inControlThisTick = null;
    command = null;
    active.clear();
    for (IBaritoneProcess proc : processes) {
        proc.onLostControl();
        if (proc.isActive() && !proc.isTemporary()) {
            // it's okay only for a temporary thing (like combat pause) to maintain control even if you say to cancel
            throw new IllegalStateException(proc.displayName());
        }
    }
}
Also used : IBaritoneProcess(baritone.api.process.IBaritoneProcess)

Example 5 with IBaritoneProcess

use of baritone.api.process.IBaritoneProcess in project Spark-Client by Spark-Client-Development.

the class PathingControlManager method executeProcesses.

public PathingCommand executeProcesses() {
    for (IBaritoneProcess process : processes) {
        if (process.isActive()) {
            if (!active.contains(process)) {
                // put a newly active process at the very front of the queue
                active.add(0, process);
            }
        } else {
            active.remove(process);
        }
    }
    // ties are broken by which was added to the beginning of the list first
    active.sort(Comparator.comparingDouble(IBaritoneProcess::priority).reversed());
    Iterator<IBaritoneProcess> iterator = active.iterator();
    while (iterator.hasNext()) {
        IBaritoneProcess proc = iterator.next();
        PathingCommand exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel());
        if (exec == null) {
            if (proc.isActive()) {
                throw new IllegalStateException(proc.displayName() + " actively returned null PathingCommand");
            }
        // no need to call onLostControl; they are reporting inactive.
        } else if (exec.commandType != PathingCommandType.DEFER) {
            inControlThisTick = proc;
            if (!proc.isTemporary()) {
                iterator.forEachRemaining(IBaritoneProcess::onLostControl);
            }
            return exec;
        }
    }
    return null;
}
Also used : PathingCommand(baritone.api.process.PathingCommand) IBaritoneProcess(baritone.api.process.IBaritoneProcess)

Aggregations

IBaritoneProcess (baritone.api.process.IBaritoneProcess)8 CommandInvalidStateException (baritone.api.command.exception.CommandInvalidStateException)4 IPathingControlManager (baritone.api.pathing.calc.IPathingControlManager)4 IPathingBehavior (baritone.api.behavior.IPathingBehavior)2 PathingCommand (baritone.api.process.PathingCommand)2