Search in sources :

Example 1 with AIRobotGotoStationAndLoad

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();
    }
}
Also used : AIRobotGotoStationAndLoad(buildcraft.robotics.ai.AIRobotGotoStationAndLoad) AIRobotSearchStackRequest(buildcraft.robotics.ai.AIRobotSearchStackRequest) AIRobotGotoSleep(buildcraft.robotics.ai.AIRobotGotoSleep) AIRobotDeliverRequested(buildcraft.robotics.ai.AIRobotDeliverRequested)

Example 2 with AIRobotGotoStationAndLoad

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));
    }
}
Also used : AIRobotGotoStationAndLoad(buildcraft.robotics.ai.AIRobotGotoStationAndLoad) AIRobotGotoStationAndUnload(buildcraft.robotics.ai.AIRobotGotoStationAndUnload) IStackFilter(buildcraft.api.core.IStackFilter)

Example 3 with AIRobotGotoStationAndLoad

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
    }
}
Also used : ArrayStackFilter(buildcraft.lib.inventory.filter.ArrayStackFilter) AIRobotGotoStationAndLoad(buildcraft.robotics.ai.AIRobotGotoStationAndLoad) AIRobotGotoSleep(buildcraft.robotics.ai.AIRobotGotoSleep) AIRobotDisposeItems(buildcraft.robotics.ai.AIRobotDisposeItems) AIRobotGotoBlock(buildcraft.robotics.ai.AIRobotGotoBlock) AIRobotRecharge(buildcraft.robotics.ai.AIRobotRecharge)

Aggregations

AIRobotGotoStationAndLoad (buildcraft.robotics.ai.AIRobotGotoStationAndLoad)3 AIRobotGotoSleep (buildcraft.robotics.ai.AIRobotGotoSleep)2 IStackFilter (buildcraft.api.core.IStackFilter)1 ArrayStackFilter (buildcraft.lib.inventory.filter.ArrayStackFilter)1 AIRobotDeliverRequested (buildcraft.robotics.ai.AIRobotDeliverRequested)1 AIRobotDisposeItems (buildcraft.robotics.ai.AIRobotDisposeItems)1 AIRobotGotoBlock (buildcraft.robotics.ai.AIRobotGotoBlock)1 AIRobotGotoStationAndUnload (buildcraft.robotics.ai.AIRobotGotoStationAndUnload)1 AIRobotRecharge (buildcraft.robotics.ai.AIRobotRecharge)1 AIRobotSearchStackRequest (buildcraft.robotics.ai.AIRobotSearchStackRequest)1