Merge pull request #2622 from hea3ven/robot-fixes

add a new Load/Unload area for robots
This commit is contained in:
Adrian Siekierka 2015-04-09 13:15:36 +02:00
commit cb031d826d
30 changed files with 103 additions and 113 deletions

View file

@ -57,6 +57,8 @@ public abstract class EntityRobotBase extends EntityLiving implements IInventory
public abstract IZone getZoneToWork(); public abstract IZone getZoneToWork();
public abstract IZone getZoneToLoadUnload();
public abstract boolean containsItems(); public abstract boolean containsItems();
public abstract boolean hasFreeSlot(); public abstract boolean hasFreeSlot();

View file

@ -139,6 +139,7 @@ gate.action.station.provide_machine_request=Provide Computed Items
gate.action.station.accept_fluids=Accept Fluids gate.action.station.accept_fluids=Accept Fluids
gate.action.station.povide_fluids=Provide Fluids gate.action.station.povide_fluids=Provide Fluids
gate.action.robot.work_in_area=Work in Area gate.action.robot.work_in_area=Work in Area
gate.action.robot.load_unload_area=Load/Unload in Area
gate.action.robot.wakeup=Wake Up gate.action.robot.wakeup=Wake Up
gate.action.station.forbid_robot=Robot Forbidden gate.action.station.forbid_robot=Robot Forbidden
gate.action.robot.filter=Filter gate.action.robot.filter=Filter

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

View file

@ -155,6 +155,7 @@ import buildcraft.robotics.statements.RobotsTriggerProvider;
import buildcraft.robotics.statements.TriggerRobotInStation; import buildcraft.robotics.statements.TriggerRobotInStation;
import buildcraft.robotics.statements.TriggerRobotLinked; import buildcraft.robotics.statements.TriggerRobotLinked;
import buildcraft.robotics.statements.TriggerRobotSleep; import buildcraft.robotics.statements.TriggerRobotSleep;
import buildcraft.robotics.statements.ActionRobotWorkInArea.AreaType;
import buildcraft.silicon.ItemRedstoneChipset; import buildcraft.silicon.ItemRedstoneChipset;
@Mod(name = "BuildCraft Robotics", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Robotics", dependencies = DefaultProps.DEPENDENCY_CORE) @Mod(name = "BuildCraft Robotics", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Robotics", dependencies = DefaultProps.DEPENDENCY_CORE)
@ -176,7 +177,8 @@ public class BuildCraftRobotics extends BuildCraftMod {
public static IActionInternal actionRobotGotoStation = new ActionRobotGotoStation(); public static IActionInternal actionRobotGotoStation = new ActionRobotGotoStation();
public static IActionInternal actionRobotWakeUp = new ActionRobotWakeUp(); public static IActionInternal actionRobotWakeUp = new ActionRobotWakeUp();
public static IActionInternal actionRobotWorkInArea = new ActionRobotWorkInArea(); public static IActionInternal actionRobotWorkInArea = new ActionRobotWorkInArea(AreaType.WORK);
public static IActionInternal actionRobotLoadUnloadArea = new ActionRobotWorkInArea(AreaType.LOAD_UNLOAD);
public static IActionInternal actionRobotFilter = new ActionRobotFilter(); public static IActionInternal actionRobotFilter = new ActionRobotFilter();
public static IActionInternal actionRobotFilterTool = new ActionRobotFilterTool(); public static IActionInternal actionRobotFilterTool = new ActionRobotFilterTool();
public static IActionInternal actionRobotAllowCraft = new ActionStationAllowCraft(); public static IActionInternal actionRobotAllowCraft = new ActionStationAllowCraft();

View file

@ -67,6 +67,7 @@ import buildcraft.robotics.ai.AIRobotMain;
import buildcraft.robotics.ai.AIRobotShutdown; import buildcraft.robotics.ai.AIRobotShutdown;
import buildcraft.robotics.ai.AIRobotSleep; import buildcraft.robotics.ai.AIRobotSleep;
import buildcraft.robotics.statements.ActionRobotWorkInArea; import buildcraft.robotics.statements.ActionRobotWorkInArea;
import buildcraft.robotics.statements.ActionRobotWorkInArea.AreaType;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.gates.ActionIterator; import buildcraft.transport.gates.ActionIterator;
@ -606,8 +607,6 @@ public class EntityRobot extends EntityRobotBase implements
currentDockingStationIndex = null; currentDockingStationIndex = null;
currentDockingStationSide = null; currentDockingStationSide = null;
mainAI.abortDelegateAI();
} }
} }
@ -923,14 +922,26 @@ public class EntityRobot extends EntityRobotBase implements
@Override @Override
public IZone getZoneToWork() { public IZone getZoneToWork() {
if (linkedDockingStation instanceof DockingStation) { return getZone(ActionRobotWorkInArea.AreaType.WORK);
for (StatementSlot s : new ActionIterator(((DockingStation) linkedDockingStation).getPipe().getPipe())) { }
if (s.statement instanceof ActionRobotWorkInArea) {
IZone zone = ActionRobotWorkInArea.getArea(s);
if (zone != null) { @Override
return zone; public IZone getZoneToLoadUnload() {
} IZone zone = getZone(ActionRobotWorkInArea.AreaType.LOAD_UNLOAD);
if (zone == null) {
zone = getZoneToWork();
}
return zone;
}
private IZone getZone(AreaType areaType) {
for (StatementSlot s : new ActionIterator(linkedDockingStation.getPipe().getPipe())) {
if (s.statement instanceof ActionRobotWorkInArea
&& ((ActionRobotWorkInArea) s.statement).getAreaType() == areaType) {
IZone zone = ActionRobotWorkInArea.getArea(s);
if (zone != null) {
return zone;
} }
} }
} }
@ -973,7 +984,7 @@ public class EntityRobot extends EntityRobotBase implements
@Override @Override
protected boolean interact(EntityPlayer player) { protected boolean interact(EntityPlayer player) {
ItemStack stack = player.getCurrentEquippedItem(); ItemStack stack = player.getCurrentEquippedItem();
if(player.isSneaking() && stack != null && stack.getItem() == BuildCraftCore.wrenchItem) { if (player.isSneaking() && stack != null && stack.getItem() == BuildCraftCore.wrenchItem) {
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
convertToItems(); convertToItems();
} else { } else {

View file

@ -67,7 +67,7 @@ public class AIRobotCraftAssemblyTable extends AIRobotCraftGeneric {
if (table != null) { if (table != null) {
if (!craftStarted) { if (!craftStarted) {
if (requirements.size() != 0) { if (requirements.size() != 0) {
startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ReqStackFilter(), robot.getZoneToWork(), 1)); startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ReqStackFilter(), 1));
return; return;
} }

View file

@ -64,14 +64,13 @@ public class AIRobotCraftFurnace extends AIRobotCraftGeneric {
if (furnace != null) { if (furnace != null) {
if (!craftStarted) { if (!craftStarted) {
if (furnace.getStackInSlot(FUEL_SLOT) == null && InvUtils.getItem(robot, new FuelFilter()) == null) { if (furnace.getStackInSlot(FUEL_SLOT) == null && InvUtils.getItem(robot, new FuelFilter()) == null) {
startDelegateAI(new AIRobotGotoStationAndLoad(robot, new FuelFilter(), robot.getZoneToWork(), 1)); startDelegateAI(new AIRobotGotoStationAndLoad(robot, new FuelFilter(), 1));
return; return;
} }
if (InvUtils.getItem(robot, new ArrayStackFilter(input)) == null) { if (InvUtils.getItem(robot, new ArrayStackFilter(input)) == null) {
startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ArrayStackFilter(input), startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ArrayStackFilter(input), 1));
robot.getZoneToWork(), 1));
return; return;
} }

View file

@ -90,7 +90,7 @@ public class AIRobotCraftWorkbench extends AIRobotCraftGeneric {
terminate(); terminate();
} }
} else if (requirements.size() > 0) { } else if (requirements.size() > 0) {
startDelegateAI(new AIRobotGotoStationToLoad(robot, new ReqStackFilter(), robot.getZoneToWork())); startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ReqStackFilter(), 1));
} else { } else {
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationWorkbenchFilter(), robot.getZoneToWork())); startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationWorkbenchFilter(), robot.getZoneToWork()));
} }
@ -98,14 +98,12 @@ public class AIRobotCraftWorkbench extends AIRobotCraftGeneric {
@Override @Override
public void delegateAIEnded(AIRobot ai) { public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStationToLoad) { if (ai instanceof AIRobotGotoStationAndLoad) {
if (ai.success()) { if (ai.success()) {
startDelegateAI(new AIRobotLoad(robot, new ReqStackFilter(), 1)); requirements = tryCraft(false);
} else { } else {
terminate(); terminate();
} }
} else if (ai instanceof AIRobotLoad) {
requirements = tryCraft(false);
} else if (ai instanceof AIRobotSearchAndGotoStation) { } else if (ai instanceof AIRobotSearchAndGotoStation) {
if (new StationWorkbenchFilter().matches((DockingStation) robot.getDockingStation())) { if (new StationWorkbenchFilter().matches((DockingStation) robot.getDockingStation())) {
craftingTimer = 40; craftingTimer = 40;

View file

@ -22,7 +22,7 @@ public class AIRobotDisposeItems extends AIRobot {
@Override @Override
public void start () { public void start () {
startDelegateAI(new AIRobotGotoStationAndUnload(robot, robot.getZoneToWork())); startDelegateAI(new AIRobotGotoStationAndUnload(robot));
} }
@Override @Override
@ -30,7 +30,7 @@ public class AIRobotDisposeItems extends AIRobot {
if (ai instanceof AIRobotGotoStationAndUnload) { if (ai instanceof AIRobotGotoStationAndUnload) {
if (ai.success()) { if (ai.success()) {
if (robot.containsItems()) { if (robot.containsItems()) {
startDelegateAI(new AIRobotGotoStationAndUnload(robot, robot.getZoneToWork())); startDelegateAI(new AIRobotGotoStationAndUnload(robot));
} else { } else {
terminate(); terminate();
} }

View file

@ -37,7 +37,7 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot {
@Override @Override
public void update() { public void update() {
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, robot.getZoneToWork())); startDelegateAI(new AIRobotGotoStationToLoad(robot, filter));
} }
@Override @Override

View file

@ -8,7 +8,6 @@
*/ */
package buildcraft.robotics.ai; package buildcraft.robotics.ai;
import buildcraft.api.core.IZone;
import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.filters.IStackFilter; import buildcraft.core.lib.inventory.filters.IStackFilter;
@ -16,24 +15,22 @@ import buildcraft.core.lib.inventory.filters.IStackFilter;
public class AIRobotGotoStationAndLoad extends AIRobot { public class AIRobotGotoStationAndLoad extends AIRobot {
private IStackFilter filter; private IStackFilter filter;
private IZone zone;
private int quantity; private int quantity;
public AIRobotGotoStationAndLoad(EntityRobotBase iRobot) { public AIRobotGotoStationAndLoad(EntityRobotBase iRobot) {
super(iRobot); super(iRobot);
} }
public AIRobotGotoStationAndLoad(EntityRobotBase iRobot, IStackFilter iFilter, IZone iZone, int iQuantity) { public AIRobotGotoStationAndLoad(EntityRobotBase iRobot, IStackFilter iFilter, int iQuantity) {
this(iRobot); this(iRobot);
filter = iFilter; filter = iFilter;
zone = iZone;
quantity = iQuantity; quantity = iQuantity;
} }
@Override @Override
public void start() { public void start() {
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, zone)); startDelegateAI(new AIRobotGotoStationToLoad(robot, filter));
} }
@Override @Override

View file

@ -8,30 +8,27 @@
*/ */
package buildcraft.robotics.ai; package buildcraft.robotics.ai;
import buildcraft.api.core.IZone;
import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.filters.IFluidFilter; import buildcraft.core.lib.inventory.filters.IFluidFilter;
public class AIRobotGotoStationAndLoadFluids extends AIRobot { public class AIRobotGotoStationAndLoadFluids extends AIRobot {
private IZone zone;
private IFluidFilter filter; private IFluidFilter filter;
public AIRobotGotoStationAndLoadFluids(EntityRobotBase iRobot) { public AIRobotGotoStationAndLoadFluids(EntityRobotBase iRobot) {
super(iRobot); super(iRobot);
} }
public AIRobotGotoStationAndLoadFluids(EntityRobotBase iRobot, IFluidFilter iFilter, IZone iZone) { public AIRobotGotoStationAndLoadFluids(EntityRobotBase iRobot, IFluidFilter iFilter) {
this(iRobot); this(iRobot);
zone = iZone;
filter = iFilter; filter = iFilter;
} }
@Override @Override
public void start() { public void start() {
startDelegateAI(new AIRobotGotoStationToLoadFluids(robot, filter, zone)); startDelegateAI(new AIRobotGotoStationToLoadFluids(robot, filter));
} }
@Override @Override

View file

@ -8,24 +8,18 @@
*/ */
package buildcraft.robotics.ai; package buildcraft.robotics.ai;
import buildcraft.api.core.IZone;
import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.EntityRobotBase;
public class AIRobotGotoStationAndUnload extends AIRobot { public class AIRobotGotoStationAndUnload extends AIRobot {
private IZone zone;
private DockingStation station; private DockingStation station;
public AIRobotGotoStationAndUnload(EntityRobotBase iRobot) { public AIRobotGotoStationAndUnload(EntityRobotBase iRobot) {
super(iRobot); super(iRobot);
}
public AIRobotGotoStationAndUnload(EntityRobotBase iRobot, IZone iZone) { station = null;
this(iRobot);
zone = iZone;
} }
public AIRobotGotoStationAndUnload(EntityRobotBase iRobot, DockingStation iStation) { public AIRobotGotoStationAndUnload(EntityRobotBase iRobot, DockingStation iStation) {
@ -37,7 +31,7 @@ public class AIRobotGotoStationAndUnload extends AIRobot {
@Override @Override
public void start() { public void start() {
if (station == null) { if (station == null) {
startDelegateAI(new AIRobotGotoStationToUnload(robot, zone)); startDelegateAI(new AIRobotGotoStationToUnload(robot));
} else { } else {
startDelegateAI(new AIRobotGotoStation(robot, station)); startDelegateAI(new AIRobotGotoStation(robot, station));
} }

View file

@ -8,27 +8,18 @@
*/ */
package buildcraft.robotics.ai; package buildcraft.robotics.ai;
import buildcraft.api.core.IZone;
import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.EntityRobotBase;
public class AIRobotGotoStationAndUnloadFluids extends AIRobot { public class AIRobotGotoStationAndUnloadFluids extends AIRobot {
private IZone zone;
public AIRobotGotoStationAndUnloadFluids(EntityRobotBase iRobot) { public AIRobotGotoStationAndUnloadFluids(EntityRobotBase iRobot) {
super(iRobot); super(iRobot);
} }
public AIRobotGotoStationAndUnloadFluids(EntityRobotBase iRobot, IZone iZone) {
this(iRobot);
zone = iZone;
}
@Override @Override
public void start() { public void start() {
startDelegateAI(new AIRobotGotoStationToUnloadFluids(robot, zone)); startDelegateAI(new AIRobotGotoStationToUnloadFluids(robot));
} }
@Override @Override

View file

@ -11,7 +11,6 @@ package buildcraft.robotics.ai;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IZone;
import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.EntityRobotBase;
@ -25,22 +24,20 @@ import buildcraft.robotics.statements.ActionStationProvideItems;
public class AIRobotGotoStationToLoad extends AIRobot { public class AIRobotGotoStationToLoad extends AIRobot {
private IStackFilter filter; private IStackFilter filter;
private IZone zone;
public AIRobotGotoStationToLoad(EntityRobotBase iRobot) { public AIRobotGotoStationToLoad(EntityRobotBase iRobot) {
super(iRobot); super(iRobot);
} }
public AIRobotGotoStationToLoad(EntityRobotBase iRobot, IStackFilter iFilter, IZone iZone) { public AIRobotGotoStationToLoad(EntityRobotBase iRobot, IStackFilter iFilter) {
this(iRobot); this(iRobot);
filter = iFilter; filter = iFilter;
zone = iZone;
} }
@Override @Override
public void update() { public void update() {
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(), zone)); startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(), robot.getZoneToLoadUnload()));
} }
@Override @Override

View file

@ -30,16 +30,15 @@ public class AIRobotGotoStationToLoadFluids extends AIRobot {
super(iRobot); super(iRobot);
} }
public AIRobotGotoStationToLoadFluids(EntityRobotBase iRobot, IFluidFilter iFiler, IZone iZone) { public AIRobotGotoStationToLoadFluids(EntityRobotBase iRobot, IFluidFilter iFiler) {
this(iRobot); this(iRobot);
zone = iZone;
filter = iFiler; filter = iFiler;
} }
@Override @Override
public void update() { public void update() {
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(), zone)); startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(), robot.getZoneToLoadUnload()));
} }
@Override @Override

View file

@ -10,7 +10,6 @@ package buildcraft.robotics.ai;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IInvSlot; import buildcraft.api.core.IInvSlot;
import buildcraft.api.core.IZone;
import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.EntityRobotBase;
@ -24,22 +23,13 @@ import buildcraft.transport.gates.ActionIterator;
public class AIRobotGotoStationToUnload extends AIRobot { public class AIRobotGotoStationToUnload extends AIRobot {
private IZone zone;
public AIRobotGotoStationToUnload(EntityRobotBase iRobot) { public AIRobotGotoStationToUnload(EntityRobotBase iRobot) {
super(iRobot); super(iRobot);
} }
public AIRobotGotoStationToUnload(EntityRobotBase iRobot, IZone iZone) {
this(iRobot);
zone = iZone;
}
@Override @Override
public void start() { public void start() {
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationInventory(), zone)); startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationInventory(), robot.getZoneToLoadUnload()));
} }
@Override @Override

View file

@ -10,7 +10,6 @@ package buildcraft.robotics.ai;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import buildcraft.api.core.IZone;
import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation; import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.EntityRobotBase;
@ -23,21 +22,13 @@ import buildcraft.transport.PipeTransportFluids;
public class AIRobotGotoStationToUnloadFluids extends AIRobot { public class AIRobotGotoStationToUnloadFluids extends AIRobot {
private IZone zone;
public AIRobotGotoStationToUnloadFluids(EntityRobotBase iRobot) { public AIRobotGotoStationToUnloadFluids(EntityRobotBase iRobot) {
super(iRobot); super(iRobot);
} }
public AIRobotGotoStationToUnloadFluids(EntityRobotBase iRobot, IZone iZone) {
this(iRobot);
zone = iZone;
}
@Override @Override
public void update() { public void update() {
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(), zone)); startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationFilter(), robot.getZoneToLoadUnload()));
} }
@Override @Override

View file

@ -23,6 +23,7 @@ public class AIRobotSearchBlock extends AIRobot {
private IterableAlgorithmRunner blockScannerJob; private IterableAlgorithmRunner blockScannerJob;
private IBlockFilter pathFound; private IBlockFilter pathFound;
private Iterator<BlockIndex> blockIter; private Iterator<BlockIndex> blockIter;
private IZone zone;
public AIRobotSearchBlock(EntityRobotBase iRobot, boolean random, IBlockFilter iPathFound) { public AIRobotSearchBlock(EntityRobotBase iRobot, boolean random, IBlockFilter iPathFound) {
super(iRobot); super(iRobot);
@ -31,7 +32,7 @@ public class AIRobotSearchBlock extends AIRobot {
if (!random) { if (!random) {
blockIter = new BlockScannerExpanding().iterator(); blockIter = new BlockScannerExpanding().iterator();
} else { } else {
IZone zone = iRobot.getZoneToWork(); zone = iRobot.getZoneToWork();
if (zone != null) { if (zone != null) {
BlockIndex pos = new BlockIndex(iRobot); BlockIndex pos = new BlockIndex(iRobot);
blockIter = new BlockScannerZoneRandom(pos.x, pos.y, pos.z, iRobot.worldObj.rand, zone) blockIter = new BlockScannerZoneRandom(pos.x, pos.y, pos.z, iRobot.worldObj.rand, zone)
@ -47,8 +48,7 @@ public class AIRobotSearchBlock extends AIRobot {
@Override @Override
public void start() { public void start() {
blockScanner = new PathFindingSearch(robot.worldObj, new BlockIndex( blockScanner = new PathFindingSearch(robot.worldObj, new BlockIndex(
robot), blockIter, pathFound, 96, robot robot), blockIter, pathFound, 96, zone);
.getZoneToWork());
blockScannerJob = new IterableAlgorithmRunner(blockScanner); blockScannerJob = new IterableAlgorithmRunner(blockScanner);
blockScannerJob.start(); blockScannerJob.start();
} }

View file

@ -54,7 +54,7 @@ public class BoardRobotBomber extends RedstoneBoardRobot {
} }
if (!containItems) { if (!containItems) {
startDelegateAI(new AIRobotGotoStationAndLoad(robot, TNT_FILTER, null, AIRobotLoad.ANY_QUANTITY)); startDelegateAI(new AIRobotGotoStationAndLoad(robot, TNT_FILTER, AIRobotLoad.ANY_QUANTITY));
} else { } else {
startDelegateAI(new AIRobotSearchRandomGroundBlock(robot, 100, new IBlockFilter() { startDelegateAI(new AIRobotSearchRandomGroundBlock(robot, 100, new IBlockFilter() {
@Override @Override

View file

@ -21,8 +21,7 @@ import buildcraft.core.builders.BuildingSlot;
import buildcraft.core.lib.inventory.filters.ArrayStackFilter; import buildcraft.core.lib.inventory.filters.ArrayStackFilter;
import buildcraft.robotics.ai.AIRobotGotoBlock; import buildcraft.robotics.ai.AIRobotGotoBlock;
import buildcraft.robotics.ai.AIRobotGotoSleep; import buildcraft.robotics.ai.AIRobotGotoSleep;
import buildcraft.robotics.ai.AIRobotGotoStationToLoad; import buildcraft.robotics.ai.AIRobotGotoStationAndLoad;
import buildcraft.robotics.ai.AIRobotLoad;
import buildcraft.robotics.ai.AIRobotRecharge; import buildcraft.robotics.ai.AIRobotRecharge;
public class BoardRobotBuilder extends RedstoneBoardRobot { public class BoardRobotBuilder extends RedstoneBoardRobot {
@ -93,9 +92,8 @@ public class BoardRobotBuilder extends RedstoneBoardRobot {
} }
if (requirementsToLookFor != null && requirementsToLookFor.size() > 0) { if (requirementsToLookFor != null && requirementsToLookFor.size() > 0) {
startDelegateAI(new AIRobotGotoStationToLoad(robot, startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ArrayStackFilter(
new ArrayStackFilter(requirementsToLookFor.getFirst()), requirementsToLookFor.getFirst()), requirementsToLookFor.getFirst().stackSize));
robot.getZoneToWork()));
} }
if (currentBuildingSlot != null && requirementsToLookFor != null && requirementsToLookFor.size() == 0) { if (currentBuildingSlot != null && requirementsToLookFor != null && requirementsToLookFor.size() == 0) {
@ -121,16 +119,12 @@ public class BoardRobotBuilder extends RedstoneBoardRobot {
@Override @Override
public void delegateAIEnded(AIRobot ai) { public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStationToLoad) { if (ai instanceof AIRobotGotoStationAndLoad) {
if (ai.success()) { if (ai.success()) {
startDelegateAI(new AIRobotLoad(robot, new ArrayStackFilter(requirementsToLookFor.getFirst()), requirementsToLookFor.removeFirst();
requirementsToLookFor.getFirst().stackSize));
} else { } else {
startDelegateAI(new AIRobotGotoSleep(robot)); startDelegateAI(new AIRobotGotoSleep(robot));
} }
} else if (ai instanceof AIRobotLoad) {
// TODO: check that we get the proper items in
requirementsToLookFor.removeFirst();
} else if (ai instanceof AIRobotGotoBlock) { } else if (ai instanceof AIRobotGotoBlock) {
if (markerToBuild == null || markerToBuild.bluePrintBuilder == null) { if (markerToBuild == null || markerToBuild.bluePrintBuilder == null) {
// defensive code, in case of a wrong load from NBT // defensive code, in case of a wrong load from NBT

View file

@ -34,10 +34,9 @@ public class BoardRobotCarrier extends RedstoneBoardRobot {
public void update() { public void update() {
if (!robot.containsItems()) { if (!robot.containsItems()) {
IStackFilter filter = ActionRobotFilter.getGateFilter(robot.getLinkedStation()); IStackFilter filter = ActionRobotFilter.getGateFilter(robot.getLinkedStation());
startDelegateAI(new AIRobotGotoStationAndLoad(robot, filter, robot.getZoneToWork(), startDelegateAI(new AIRobotGotoStationAndLoad(robot, filter, AIRobotLoad.ANY_QUANTITY));
AIRobotLoad.ANY_QUANTITY));
} else { } else {
startDelegateAI(new AIRobotGotoStationAndUnload(robot, robot.getZoneToWork())); startDelegateAI(new AIRobotGotoStationAndUnload(robot));
} }
} }

View file

@ -53,7 +53,7 @@ public class BoardRobotDelivery extends RedstoneBoardRobot {
startDelegateAI(new AIRobotSearchStackRequest(robot, ActionRobotFilter.getGateFilter(robot startDelegateAI(new AIRobotSearchStackRequest(robot, ActionRobotFilter.getGateFilter(robot
.getLinkedStation()), deliveryBlacklist)); .getLinkedStation()), deliveryBlacklist));
} else { } else {
startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ReqFilter(), robot.getZoneToWork(), 1)); startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ReqFilter(), 1));
} }
} }

View file

@ -35,10 +35,9 @@ public class BoardRobotFluidCarrier extends RedstoneBoardRobot {
public void update() { public void update() {
if (!robotHasFluid()) { if (!robotHasFluid()) {
IFluidFilter filter = ActionRobotFilter.getGateFluidFilter(robot.getLinkedStation()); IFluidFilter filter = ActionRobotFilter.getGateFluidFilter(robot.getLinkedStation());
startDelegateAI(new AIRobotGotoStationAndLoadFluids(robot, filter, startDelegateAI(new AIRobotGotoStationAndLoadFluids(robot, filter));
robot.getZoneToWork()));
} else { } else {
startDelegateAI(new AIRobotGotoStationAndUnloadFluids(robot, robot.getZoneToWork())); startDelegateAI(new AIRobotGotoStationAndUnloadFluids(robot));
} }
} }

View file

@ -44,7 +44,7 @@ public class BoardRobotPicker extends RedstoneBoardRobot {
startDelegateAI(new AIRobotFetchItem(robot, 250, ActionRobotFilter.getGateFilter(robot startDelegateAI(new AIRobotFetchItem(robot, 250, ActionRobotFilter.getGateFilter(robot
.getLinkedStation()), robot.getZoneToWork())); .getLinkedStation()), robot.getZoneToWork()));
} else if (robot.containsItems()) { } else if (robot.containsItems()) {
startDelegateAI(new AIRobotGotoStationAndUnload(robot, robot.getZoneToWork())); startDelegateAI(new AIRobotGotoStationAndUnload(robot));
} else { } else {
startDelegateAI(new AIRobotGotoSleep(robot)); startDelegateAI(new AIRobotGotoSleep(robot));
} }

View file

@ -57,7 +57,7 @@ public class BoardRobotPump extends RedstoneBoardRobot {
FluidStack tank = robot.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid; FluidStack tank = robot.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
if (tank != null && tank.amount > 0) { if (tank != null && tank.amount > 0) {
startDelegateAI(new AIRobotGotoStationAndUnloadFluids(robot, robot.getZoneToWork())); startDelegateAI(new AIRobotGotoStationAndUnloadFluids(robot));
} else { } else {
updateFilter(); updateFilter();

View file

@ -67,7 +67,7 @@ public class BoardRobotStripes extends RedstoneBoardRobot {
startDelegateAI(new AIRobotGotoSleep(robot)); startDelegateAI(new AIRobotGotoSleep(robot));
} }
} else if (ai instanceof AIRobotFetchAndEquipItemStack) { } else if (ai instanceof AIRobotFetchAndEquipItemStack) {
if (robot.getHeldItem() == null) { if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot)); startDelegateAI(new AIRobotGotoSleep(robot));
} }
} else if (ai instanceof AIRobotStripesHandler) { } else if (ai instanceof AIRobotStripesHandler) {

View file

@ -22,18 +22,45 @@ import buildcraft.core.statements.BCStatement;
public class ActionRobotWorkInArea extends BCStatement implements IActionInternal { public class ActionRobotWorkInArea extends BCStatement implements IActionInternal {
public ActionRobotWorkInArea() { public enum AreaType {
super("buildcraft:robot.work_in_area"); WORK("work_in_area"),
LOAD_UNLOAD("load_unload_area");
private String name;
private AreaType(String iName) {
name = iName;
}
public String getTag() {
return "buildcraft:robot." + name;
}
public String getUnlocalizedName() {
return "gate.action.robot." + name;
}
public String getIcon() {
return "buildcraftrobotics:triggers/action_robot_" + name;
}
}
private AreaType areaType;
public ActionRobotWorkInArea(AreaType iAreaType) {
super(iAreaType.getTag());
areaType = iAreaType;
} }
@Override @Override
public String getDescription() { public String getDescription() {
return StringUtils.localize("gate.action.robot.work_in_area"); return StringUtils.localize(areaType.getUnlocalizedName());
} }
@Override @Override
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraftrobotics:triggers/action_robot_in_area"); icon = iconRegister.registerIcon(areaType.getIcon());
} }
public static IZone getArea(StatementSlot slot) { public static IZone getArea(StatementSlot slot) {
@ -67,8 +94,10 @@ public class ActionRobotWorkInArea extends BCStatement implements IActionInterna
} }
@Override @Override
public void actionActivate(IStatementContainer source, public void actionActivate(IStatementContainer source, IStatementParameter[] parameters) {
IStatementParameter[] parameters) { }
public AreaType getAreaType() {
return areaType;
} }
} }

View file

@ -8,7 +8,6 @@
*/ */
package buildcraft.robotics.statements; package buildcraft.robotics.statements;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -52,6 +51,7 @@ public class RobotsActionProvider implements IActionProvider {
result.add(BuildCraftRobotics.actionRobotGotoStation); result.add(BuildCraftRobotics.actionRobotGotoStation);
result.add(BuildCraftRobotics.actionRobotWorkInArea); result.add(BuildCraftRobotics.actionRobotWorkInArea);
result.add(BuildCraftRobotics.actionRobotLoadUnloadArea);
result.add(BuildCraftRobotics.actionRobotWakeUp); result.add(BuildCraftRobotics.actionRobotWakeUp);
result.add(BuildCraftRobotics.actionRobotFilter); result.add(BuildCraftRobotics.actionRobotFilter);
result.add(BuildCraftRobotics.actionRobotFilterTool); result.add(BuildCraftRobotics.actionRobotFilterTool);