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); } }
@Override protected final void executeImpl() { if (execResults == null) { // this is to slow down undead robot after cleanup, from fast exception-loop try { Thread.sleep(1000); } catch (InterruptedException ignore) { } } // Entering tick robotThreadManager.checkRunThread(); if (testingCondition) { throw new RobotException( "You cannot take action inside Condition.test(). You should handle onCustomEvent instead."); } setSetCallCount(0); setGetCallCount(0); // This stops autoscan from scanning... if (waitCondition != null && waitCondition.test()) { waitCondition = null; commands.setScan(true); } commands.setOutputText(out.readAndReset()); commands.setGraphicsCalls(graphicsProxy.readoutQueuedCalls()); // Call server execResults = peer.executeImpl(commands); updateStatus(execResults.getCommands(), execResults.getStatus()); graphicsProxy.setPaintingEnabled(execResults.isPaintEnabled()); firedEnergy = 0; firedHeat = 0; // add new events eventManager.add(new StatusEvent(execResults.getStatus())); if (statics.isPaintRobot() && execResults.isPaintEnabled()) { // Add paint event, if robot is a paint robot and its painting is enabled eventManager.add(new PaintEvent()); } // add other events if (execResults.getEvents() != null) { for (Event event : execResults.getEvents()) { eventManager.add(event); } } if (execResults.getBulletUpdates() != null) { for (BulletStatus bulletStatus : execResults.getBulletUpdates()) { final Bullet bullet = bullets.get(bulletStatus.bulletId); if (bullet != null) { HiddenAccess.update( bullet, bulletStatus.x, bulletStatus.y, bulletStatus.victimName, bulletStatus.isActive); if (!bulletStatus.isActive) { bullets.remove(bulletStatus.bulletId); } } } } // add new team messages loadTeamMessages(execResults.getTeamMessages()); eventManager.processEvents(); }