@Override
  public void actionActivate(IStatementContainer container, IStatementParameter[] parameters) {
    IRobotRegistry registry =
        RobotManager.registryProvider.getRegistry(container.getTile().getWorldObj());

    List<DockingStation> stations = RobotUtils.getStations(container.getTile());

    for (DockingStation station : stations) {
      if (station.robotTaking() != null) {
        EntityRobot robot = (EntityRobot) station.robotTaking();
        AIRobot ai = robot.getOverridingAI();

        if (ai != null) {
          continue;
        }

        DockingStation newStation = station;

        if (parameters[0] != null) {
          newStation = getStation((StatementParameterItemStack) parameters[0], registry);
        }

        if (newStation != null) {
          robot.overrideAI(new AIRobotGoAndLinkToDock(robot, newStation));
        }
      }
    }
  }
Esempio n. 2
0
  public static boolean canInteractWithFluid(
      DockingStation station, IFluidFilter filter, Class<?> actionClass) {
    boolean actionFound = false;

    for (StatementSlot s : station.getActiveActions()) {
      if (actionClass.isAssignableFrom(s.statement.getClass())) {
        StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters);

        if (!param.hasFilter()) {
          actionFound = true;
          break;
        } else {
          for (ItemStack stack : param.getStacks()) {
            if (stack != null) {
              FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);

              if (fluid != null && filter.matches(fluid.getFluid())) {
                actionFound = true;
                break;
              }
            }
          }
        }
      }
    }

    return actionFound;
  }
Esempio n. 3
0
  public static boolean canInteractWithItem(
      DockingStation station, IStackFilter filter, Class<?> actionClass) {
    boolean actionFound = false;

    for (StatementSlot s : station.getActiveActions()) {
      if (actionClass.isAssignableFrom(s.statement.getClass())) {
        StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters);

        if (!param.hasFilter() || param.matches(filter)) {
          actionFound = true;
          break;
        }
      }
    }

    return actionFound;
  }
Esempio n. 4
0
  public static Collection<ItemStack> getGateFilterStacks(DockingStation station) {
    ArrayList<ItemStack> result = new ArrayList<ItemStack>();

    for (StatementSlot slot : station.getActiveActions()) {
      if (slot.statement instanceof ActionRobotFilter) {
        for (IStatementParameter p : slot.parameters) {
          if (p != null && p instanceof StatementParameterItemStack) {
            StatementParameterItemStack param = (StatementParameterItemStack) p;
            ItemStack stack = param.getItemStack();

            if (stack != null) {
              result.add(stack);
            }
          }
        }
      }
    }

    return result;
  }