separate normal terminaison from abort
This commit is contained in:
parent
e4ab3b0fa0
commit
2e209805b8
4 changed files with 26 additions and 8 deletions
api/buildcraft/api/robots
common/buildcraft/core
|
@ -40,6 +40,10 @@ public class AIRobot {
|
|||
|
||||
}
|
||||
|
||||
public void delegateAIAborted(AIRobot ai) {
|
||||
|
||||
}
|
||||
|
||||
public final void terminate() {
|
||||
abortDelegateAI();
|
||||
end();
|
||||
|
@ -50,6 +54,16 @@ public class AIRobot {
|
|||
}
|
||||
}
|
||||
|
||||
public final void abort() {
|
||||
abortDelegateAI();
|
||||
end();
|
||||
|
||||
if (parentAI != null) {
|
||||
parentAI.delegateAI = null;
|
||||
parentAI.delegateAIAborted(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final void cycle() {
|
||||
preempt(delegateAI);
|
||||
|
||||
|
@ -72,7 +86,7 @@ public class AIRobot {
|
|||
|
||||
public final void abortDelegateAI() {
|
||||
if (delegateAI != null) {
|
||||
delegateAI.terminate();
|
||||
delegateAI.abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
|
|||
if (ai instanceof AIRobotSearchBlock) {
|
||||
BlockIndex index = ((AIRobotSearchBlock) ai).blockFound;
|
||||
|
||||
if (reserveBlock(index)) {
|
||||
if (index != null && reserveBlock(index)) {
|
||||
startDelegateAI(new AIRobotBreakWithTool(robot, ((AIRobotSearchBlock) ai).blockFound));
|
||||
}
|
||||
} else if (ai instanceof AIRobotBreakWithTool) {
|
||||
|
|
|
@ -76,11 +76,11 @@ public class PathFinding {
|
|||
}
|
||||
|
||||
public void iterate(int itNumber) {
|
||||
if (nextIteration == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < itNumber; ++i) {
|
||||
if (nextIteration == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (endReached) {
|
||||
result = new LinkedList<BlockIndex>();
|
||||
|
||||
|
|
|
@ -21,8 +21,12 @@ public class PathFindingJob extends Thread {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!isTerminated() && !pathFinding.isDone()) {
|
||||
pathFinding.iterate();
|
||||
try {
|
||||
while (!isTerminated() && !pathFinding.isDone()) {
|
||||
pathFinding.iterate();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue