/** * Instantiate the MapController with the given server map used. * * @param serverMap the server map containing the context and map */ public ServerMapController(BW4TServerMap serverMap) { super(serverMap.getMap()); this.serverMap = serverMap; getRenderSettings().setRenderEntityName(true); Dimensions size = serverMap.getContinuousSpace().getDimensions(); getRenderSettings().setWorldDimensions((int) size.getWidth(), (int) size.getHeight()); }
@Override public Set<ViewBlock> getVisibleBlocks() { Set<ViewBlock> blocks = new HashSet<>(); for (Object block : serverMap.getContext().getObjects(Block.class)) { blocks.add(((Block) block).getView()); } return blocks; }
@Override public int getSequenceIndex() { Set<DropZone> dropZone = serverMap.getObjectsFromContext(DropZone.class); if (dropZone.size() <= 0) { return 0; } return dropZone.iterator().next().getSequenceIndex(); }
@Override public List<BlockColor> getSequence() { Set<DropZone> dropZone = serverMap.getObjectsFromContext(DropZone.class); if (dropZone.size() <= 0) { return new ArrayList<>(); } return dropZone.iterator().next().getSequence(); }
@Override public Set<ViewEPartner> getVisibleEPartners() { Set<ViewEPartner> epartners = new HashSet<>(); for (Object epartner : serverMap.getContext().getObjects(EPartner.class)) { EPartner epartnerTemp = (EPartner) epartner; epartners.add(epartnerTemp.getView()); } return epartners; }
@Override public Set<Path> getPaths() { Set<Path> paths = new HashSet<Path>(); for (Object pathTemp : serverMap.getContext().getObjects(Path.class)) { Path path = (Path) pathTemp; paths.add(path); } return paths; }
@Override public boolean isOccupied(Zone room) { for (Object roomObj : serverMap.getContext().getObjects(Room.class)) { Room sroom = (Room) roomObj; if (sroom.getName().equals(room.getName())) { return sroom.getOccupier() != null; } } return false; }
@Override public Set<ViewEntity> getVisibleEntities() { Set<ViewEntity> entities = new HashSet<>(); for (Object robot : serverMap.getContext().getObjects(IRobot.class)) { IRobot robotTemp = (IRobot) robot; if (robotTemp.isConnected()) { entities.add(robotTemp.getView()); } } return entities; }