Examples of CoreRoutedPipe


Examples of logisticspipes.pipes.basic.CoreRoutedPipe

    ticksUntillNextInventoryCheck=REFRESH_TIME;
    if(iterated++%this.simpleID==0)
      ticksUntillNextInventoryCheck++; // randomly wait 1 extra tick - just so that every router doesn't tick at the same time
    if(iterated >= ServerRouter.getBiggestSimpleID())
      iterated = 0;
    CoreRoutedPipe pipe = getPipe();
    if(pipe==null)
      return;
    if(pipe.hasGenericInterests())
      this.declareGenericInterest();
    else
      this.removeGenericInterest();
    Set<ItemIdentifier> newInterests = pipe.getSpecificInterests();
    if(newInterests == null) {
      newInterests = new TreeSet<ItemIdentifier>();
    }
    if(!newInterests.equals(_hasInterestIn)) {
      for(ItemIdentifier i : _hasInterestIn) {
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

  final List<ExitRoute> routes = getRouter().getIRoutersByCost();
    if(!_service.getUpgradeManager().isAdvancedSatelliteCrafter()) {
      if(satelliteId == 0) return true;
      for (final PipeItemsSatelliteLogistics satellite : PipeItemsSatelliteLogistics.AllSatellites) {
        if (satellite.satelliteId == satelliteId) {
          CoreRoutedPipe satPipe = satellite;
          if(satPipe == null || satPipe.stillNeedReplace() || satPipe.getRouter() == null)
            continue;
          IRouter satRouter = satPipe.getRouter();
          for (ExitRoute route:routes) {
            if (route.destination == satRouter) {
              return true;
            }
          }
        }
      }
    } else {
      boolean foundAll = true;
      for(int i=0;i<9;i++) {
        boolean foundOne = false;
        if(advancedSatelliteIdArray[i] == 0) {
          continue;
        }
        for (final PipeItemsSatelliteLogistics satellite : PipeItemsSatelliteLogistics.AllSatellites) {
          if (satellite.satelliteId == advancedSatelliteIdArray[i]) {
            CoreRoutedPipe satPipe = satellite;
            if(satPipe == null || satPipe.stillNeedReplace() || satPipe.getRouter() == null)
              continue;
            IRouter satRouter = satPipe.getRouter();
            for (ExitRoute route:routes) {
              if (route.destination == satRouter) {
                foundOne = true;
                break;
              }
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

  }

  protected int getNextConnectSatelliteId(boolean prev, int x) {
    int closestIdFound = prev ? 0 : Integer.MAX_VALUE;
    for (final PipeItemsSatelliteLogistics satellite : PipeItemsSatelliteLogistics.AllSatellites) {
      CoreRoutedPipe satPipe = satellite;
      if(satPipe == null || satPipe.stillNeedReplace() || satPipe.getRouter() == null || satPipe.isFluidPipe()) continue;
      IRouter satRouter = satPipe.getRouter();
      List<ExitRoute> routes = getRouter().getDistanceTo(satRouter);
      if(routes != null && !routes.isEmpty()) {
        boolean filterFree = false;
        for(ExitRoute route: routes) {
          if(route.filters.isEmpty()) {
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

  }
 
  protected int getNextConnectFluidSatelliteId(boolean prev, int x) {
    int closestIdFound = prev ? 0 : Integer.MAX_VALUE;
    for (final PipeFluidSatellite satellite : PipeFluidSatellite.AllSatellites) {
      CoreRoutedPipe satPipe = satellite;
      if(satPipe == null || satPipe.stillNeedReplace() || satPipe.getRouter() == null || !satPipe.isFluidPipe()) continue;
      IRouter satRouter = satPipe.getRouter();
      List<ExitRoute> routes = getRouter().getDistanceTo(satRouter);
      if(routes != null && !routes.isEmpty()) {
        boolean filterFree = false;
        for(ExitRoute route: routes) {
          if(route.filters.isEmpty()) {
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

  public IRouter getSatelliteRouter(int x) {
    if(x == -1) {
      for (final PipeItemsSatelliteLogistics satellite : PipeItemsSatelliteLogistics.AllSatellites) {
        if (satellite.satelliteId == satelliteId) {
          CoreRoutedPipe satPipe = satellite;
          if(satPipe == null || satPipe.stillNeedReplace() || satPipe.getRouter() == null)
            continue;
          return satPipe.getRouter();
        }
      }
    } else {
      for (final PipeItemsSatelliteLogistics satellite : PipeItemsSatelliteLogistics.AllSatellites) {
        if (satellite.satelliteId == advancedSatelliteIdArray[x]) {
          CoreRoutedPipe satPipe = satellite;
          if(satPipe == null || satPipe.stillNeedReplace() || satPipe.getRouter() == null)
            continue;
          return satPipe.getRouter();
        }
      }
    }
    return null;
  }
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

   
    @Override
    public void run() {
      if(!run) return;
      try {
        CoreRoutedPipe p = target.getCachedPipe();
        if(p==null){
          run = false;
          return;
        }
        //spinlock during the first tick, we can't touch the routing table, untill Update() has been called on every pipe.
        for(int i=0;i<10 && p.stillNeedReplace();i++){Thread.sleep(10);}
        if(p.stillNeedReplace())
          return; // drop the pipe update if it still needs replace after 5 ticks.
        CreateRouteTable(newVersion);
      } catch(Exception e) {
        e.printStackTrace();
      }
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

  public IRouter getFluidSatelliteRouter(int x) {
    if(x == -1) {
      for (final PipeFluidSatellite satellite : PipeFluidSatellite.AllSatellites) {
        if (satellite.satelliteId == liquidSatelliteId) {
          CoreRoutedPipe satPipe = satellite;
          if(satPipe == null || satPipe.stillNeedReplace() || satPipe.getRouter() == null)
            continue;
          return satPipe.getRouter();
        }
      }
    } else {
      for (final PipeFluidSatellite satellite : PipeFluidSatellite.AllSatellites) {
        if (satellite.satelliteId == liquidSatelliteIdArray[x]) {
          CoreRoutedPipe satPipe = satellite;
          if(satPipe == null || satPipe.stillNeedReplace() || satPipe.getRouter() == null)
            continue;
          return satPipe.getRouter();
        }
      }
    }
    return null;
  }
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

    return  UUID.randomUUID();
  }

  @Override
  public LogisticsModule getLogisticsModule() {
    CoreRoutedPipe pipe = this.getPipe();
    if (pipe == null) return null;
    return pipe.getLogisticsModule();
  }
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

      return foundPipes;
    }
   
    //Break recursion if we end up on a routing pipe, unless its the first one. Will break if matches the first call
    if (startPipe.isRoutingPipe() && setVisited.size() != 0) {
      CoreRoutedPipe rp = startPipe.getRoutingPipe();
      if(rp.stillNeedReplace()) {
        return foundPipes;
      }
      int size = 0;
      for(Integer dis:distances.values()) {
        size += dis;
      }
     
      if(!rp.getUpgradeManager().hasPowerPassUpgrade()) {
        connectionFlags.remove(PipeRoutingConnectionType.canPowerSubSystemFrom);
      }
     
      foundPipes.put(rp, new ExitRoute(null,rp.getRouter(), ForgeDirection.UNKNOWN, side.getOpposite(), Math.max(1, size), connectionFlags, distances.size()));
     
      return foundPipes;
    }
   
    //Visited is checked after, so we can reach the same target twice to allow to keep the shortest path
    setVisited.add(new LPPosition(startPipe));
    distances.put(new LPPosition(startPipe), startPipe.getDistance());
   
    // first check specialPipeConnections (tesseracts, teleports, other connectors)
    List<IPipeInformationProvider> pipez = SimpleServiceLocator.specialpipeconnection.getConnectedPipes(startPipe);
    for (IPipeInformationProvider specialpipe : pipez){
      if (setVisited.contains(new LPPosition(specialpipe))) {
        //Don't go where we have been before
        continue;
      }
      HashMap<CoreRoutedPipe, ExitRoute> result = getConnectedRoutingPipes(specialpipe, connectionFlags, side);
      for (Entry<CoreRoutedPipe, ExitRoute> pipe : result.entrySet()) {
        pipe.getValue().exitOrientation = ForgeDirection.UNKNOWN;
        ExitRoute foundPipe=foundPipes.get(pipe.getKey());
        if (foundPipe == null || (pipe.getValue().distanceToDestination < foundPipe.distanceToDestination)) {
          // New path OR   If new path is better, replace old path
          foundPipes.put(pipe.getKey(), pipe.getValue());
        }
      }
    }
   
    ArrayDeque<Pair<TileEntity,ForgeDirection>> connections = new ArrayDeque<Pair<TileEntity,ForgeDirection>>();
   
    //Recurse in all directions
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
      if(root && !ForgeDirection.UNKNOWN.equals(side) && !direction.equals(side)) continue;

      // tile may be up to 1 second old, but any neighbour pipe change will cause an immidiate update here, so we know that if it has changed, it isn't a pipe that has done so.
      TileEntity tile = startPipe.getTile(direction);
     
      if (tile == null) continue;
      if(OrientationsUtil.isSide(direction)) {
        if (root && tile instanceof ILogisticsPowerProvider) {
          if(this.powerNodes==null) {
            powerNodes = new ArrayList<Pair<ILogisticsPowerProvider,List<IFilter>>>();
          }
          //If we are a FireWall pipe add our filter to the pipes
          if(startPipe.isFirewallPipe()) {
            powerNodes.add(new Pair<ILogisticsPowerProvider,List<IFilter>>((ILogisticsPowerProvider) tile, new OneList<IFilter>(startPipe.getFirewallFilter())));
          } else {
            powerNodes.add(new Pair<ILogisticsPowerProvider,List<IFilter>>((ILogisticsPowerProvider) tile, Collections.unmodifiableList(new ArrayList<IFilter>(0))));
          }
        }
        if(root && tile instanceof ISubSystemPowerProvider) {
          if(this.subPowerProvider==null) {
            subPowerProvider = new ArrayList<Pair<ISubSystemPowerProvider,List<IFilter>>>();
          }
          //If we are a FireWall pipe add our filter to the pipes
          if(startPipe.isFirewallPipe()) {
            subPowerProvider.add(new Pair<ISubSystemPowerProvider,List<IFilter>>((ISubSystemPowerProvider) tile, new OneList<IFilter>(startPipe.getFirewallFilter())));
          } else {
            subPowerProvider.add(new Pair<ISubSystemPowerProvider,List<IFilter>>((ISubSystemPowerProvider) tile, Collections.unmodifiableList(new ArrayList<IFilter>(0))));
          }
        }
      }
      connections.add(new Pair<TileEntity, ForgeDirection>(tile, direction));
    }
   
    while(!connections.isEmpty()) {
      Pair<TileEntity,ForgeDirection> pair = connections.pollFirst();
      TileEntity tile = pair.getValue1();
      ForgeDirection direction = pair.getValue2();
      EnumSet<PipeRoutingConnectionType> nextConnectionFlags = EnumSet.copyOf(connectionFlags);
      boolean isDirectConnection = false;
      int resistance = 0;
     
      if(root) {
        List<TileEntity> list = SimpleServiceLocator.specialtileconnection.getConnectedPipes(tile);
        if(!list.isEmpty()) {
          for(TileEntity pipe:list) {
            connections.add(new Pair<TileEntity, ForgeDirection>(pipe, direction));
          }
          continue;
        }
        if(!startPipe.getRoutingPipe().getUpgradeManager().hasPowerPassUpgrade()) {
          nextConnectionFlags.remove(PipeRoutingConnectionType.canPowerSubSystemFrom);
        }
      }
     
      if(tile instanceof IInventory && startPipe.isRoutingPipe() && startPipe.getRoutingPipe() instanceof IDirectRoutingConnection) {
        if(SimpleServiceLocator.connectionManager.hasDirectConnection(startPipe.getRoutingPipe().getRouter())) {
          CoreRoutedPipe CRP = SimpleServiceLocator.connectionManager.getConnectedPipe(startPipe.getRoutingPipe().getRouter());
          if(CRP != null) {
            tile = CRP.container;
            isDirectConnection = true;
            resistance = ((IDirectRoutingConnection)startPipe.getRoutingPipe()).getConnectionResistance();
          }
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

 
  @Override
  public DummyContainer getContainer(EntityPlayer player) {
    LogisticsTileGenericPipe tile = this.getPipe(player.getEntityWorld());
    if(tile == null || !(tile.pipe instanceof CoreRoutedPipe)) return null;
    final CoreRoutedPipe pipe = (CoreRoutedPipe) tile.pipe;
    DummyContainer dummy = new DummyContainer(player, null, pipe.getUpgradeManager().getGuiController(), new IGuiOpenControler() {
      //Network Statistics
      @Override
      public void guiOpenedByPlayer(EntityPlayer player) {
        pipe.playerStartWatching(player, 0);
      }
     
      @Override
      public void guiClosedByPlayer(EntityPlayer player) {
        pipe.playerStopWatching(player, 0);
      }
    });
    dummy.addNormalSlotsForPlayerInventory(0, 0);
    // TAB_1 SLOTS
    for(int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
        dummy.addRestrictedSlot(pipeSlot, pipe.getUpgradeManager().getInv(), 8 + pipeSlot * 18, 18, new ISlotCheck() {
        @Override
        public boolean isStackAllowed(ItemStack itemStack) {
          if(itemStack == null) return false;
          if(itemStack.getItem() == LogisticsPipes.UpgradeItem) {
            if(!LogisticsPipes.UpgradeItem.getUpgradeForItem(itemStack, null).isAllowed(pipe)) return false;
          } else {
            return false;
          }
          return true;
        }
        });
      }
    for(int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
        dummy.addRestrictedSlot(pipeSlot, pipe.getUpgradeManager().getSneakyInv(), 8 + pipeSlot * 18, 48, new ISlotCheck() {
        @Override
        public boolean isStackAllowed(ItemStack itemStack) {
          if(itemStack == null) return false;
          if(itemStack.getItem() == LogisticsPipes.UpgradeItem) {
            IPipeUpgrade upgrade = LogisticsPipes.UpgradeItem.getUpgradeForItem(itemStack, null);
            if(!(upgrade instanceof SneakyUpgrade)) return false;
            if(!upgrade.isAllowed(pipe)) return false;
          } else {
            return false;
          }
          return true;
        }
        });
      }
    // TAB_2 SLOTS
      dummy.addStaticRestrictedSlot(0, pipe.getUpgradeManager().getSecInv(), 8 + 8 * 18, 18, new ISlotCheck() {
      @Override
      public boolean isStackAllowed(ItemStack itemStack) {
        if(itemStack == null) return false;
        if(itemStack.getItem() != LogisticsPipes.LogisticsItemCard) return false;
        if(itemStack.getItemDamage() != LogisticsItemCard.SEC_CARD) return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.