Hi Kent,
A scan() contains an
execute() method implicitly, which means that it executes its turn
now by sending all its pending actions to the game, and "waiting" for the event handlers to be called.
Hence, the current onScannedRobot() handler is "interrupted" now due to scan() being called (executed), and the remaining code in the handler will not be called, at least not in the current turn.
And called scan() in the handler prevents commands following scan() from being called.
public void rescan() {
boolean reset = false;
boolean origInterruptableValue = false;
if (eventManager.getCurrentTopEventPriority() == eventManager.getScannedRobotEventPriority()) {
reset = true;
origInterruptableValue = eventManager.isInterruptible(eventManager.getScannedRobotEventPriority());
eventManager.setInterruptible(eventManager.getScannedRobotEventPriority(), true);
}
commands.setScan(true);
executeImpl();
if (reset) {
eventManager.setInterruptible(eventManager.getScannedRobotEventPriority(), origInterruptableValue);
}
}