use of buildcraft.robotics.ai.AIRobotRecharge in project BuildCraft by BuildCraft.
the class BoardRobotBuilder method update.
@Override
public void update() {
if (launchingDelay > 0) {
launchingDelay--;
return;
}
if (markerToBuild == null) {
markerToBuild = findClosestMarker();
if (markerToBuild == null) {
if (robot.containsItems()) {
startDelegateAI(new AIRobotDisposeItems(robot));
} else {
startDelegateAI(new AIRobotGotoSleep(robot));
}
return;
}
}
if (!markerToBuild.needsToBuild()) {
markerToBuild = null;
currentBuildingSlot = null;
return;
}
if (currentBuildingSlot == null) {
currentBuildingSlot = markerToBuild.bluePrintBuilder.reserveNextSlot(robot.worldObj);
if (currentBuildingSlot == null) {
// No slots available yet
launchingDelay = 40;
return;
}
}
if (requirementsToLookFor == null) {
if (robot.containsItems()) {
startDelegateAI(new AIRobotDisposeItems(robot));
}
if (robot.worldObj.getWorldInfo().getGameType() != WorldSettings.GameType.CREATIVE) {
requirementsToLookFor = currentBuildingSlot.getRequirements(markerToBuild.getContext());
} else {
requirementsToLookFor = new LinkedList<>();
}
if (requirementsToLookFor == null) {
launchingDelay = 40;
return;
}
if (requirementsToLookFor.size() > 4) {
currentBuildingSlot.built = true;
currentBuildingSlot = null;
requirementsToLookFor = null;
return;
}
}
if (requirementsToLookFor.size() > 0) {
startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ArrayStackFilter(requirementsToLookFor.get(0)), requirementsToLookFor.get(0).stackSize));
return;
}
if (requirementsToLookFor.size() == 0) {
if (currentBuildingSlot.stackConsumed == null) {
// Once all the element are in, if not already, use them to
// prepare the slot.
markerToBuild.bluePrintBuilder.useRequirements(robot, currentBuildingSlot);
}
if (!hasEnoughEnergy()) {
startDelegateAI(new AIRobotRecharge(robot));
} else {
startDelegateAI(new AIRobotGotoBlock(robot, Utils.convertFloor(currentBuildingSlot.getDestination()), 8));
}
// TODO: take into account cases where the robot can't reach the
// destination - go to work on another block
}
}
Aggregations