use of buildcraft.robotics.ai.AIRobotGotoStationAndLoad in project BuildCraft by BuildCraft.
the class BoardRobotDelivery method delegateAIEnded.
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotSearchStackRequest) {
if (!ai.success()) {
deliveryBlacklist.clear();
startDelegateAI(new AIRobotGotoSleep(robot));
} else {
currentRequest = ((AIRobotSearchStackRequest) ai).request;
if (!currentRequest.getStation(robot.worldObj).take(robot)) {
releaseCurrentRequest();
}
}
} else if (ai instanceof AIRobotGotoStationAndLoad) {
if (!ai.success()) {
deliveryBlacklist.add(currentRequest.getStack());
releaseCurrentRequest();
} else {
startDelegateAI(new AIRobotDeliverRequested(robot, currentRequest));
}
} else if (ai instanceof AIRobotDeliverRequested) {
releaseCurrentRequest();
}
}
use of buildcraft.robotics.ai.AIRobotGotoStationAndLoad in project BuildCraft by BuildCraft.
the class BoardRobotCarrier method update.
@Override
public void update() {
if (!robot.containsItems()) {
IStackFilter filter = ActionRobotFilter.getGateFilter(robot.getLinkedStation());
startDelegateAI(new AIRobotGotoStationAndLoad(robot, filter, AIRobotLoad.ANY_QUANTITY));
} else {
startDelegateAI(new AIRobotGotoStationAndUnload(robot));
}
}
use of buildcraft.robotics.ai.AIRobotGotoStationAndLoad 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