@Override protected void serializeTask(DataOutputStream dos) throws IOException { super.serializeTask(dos); SimpleGuiTask.serializePosition(dos, position); dos.writeInt(materialType.ordinal()); dos.writeInt(productionType.ordinal()); dos.writeFloat(ratio); }
private static EMaterialType getMaterial(Attributes attributes) { String string = attributes.getValue(MATERIAL); if (string == null) { return null; } else { try { return EMaterialType.valueOf(string); } catch (IllegalArgumentException e) { return null; } } }
private EMaterialType requestMaterialType(ToolType tool) { EMaterialType[] materialTypes = EMaterialType.values(); Arrays.sort(materialTypes, Comparators.comparing(EMaterialType::name)); return (EMaterialType) JOptionPane.showInputDialog(null, "Select Material Type", "Material Type", JOptionPane.QUESTION_MESSAGE, null, materialTypes, tool); }
public MaterialButton(EMaterialType material) { super(material.getIcon()); this.material = material; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + amount; result = prime * result + ((material == null) ? 0 : material.hashCode()); result = prime * result + (relative ? 1231 : 1237); return result; }
private void dropCurrentMaterial() { EMaterialType material = movable.getMaterial(); if (material.isDroppable()) { super.getGrid().dropMaterial(movable.getPosition(), material, true, false); } super.setMaterial(EMaterialType.NO_MATERIAL); }
public PartitionManagerSettings() { materialTypeForPriorities = new EMaterialType[EMaterialType.NUMBER_OF_DROPPABLE_MATERIALS]; System.arraycopy(EMaterialType.DROPPABLE_MATERIALS, 0, materialTypeForPriorities, 0, EMaterialType.NUMBER_OF_DROPPABLE_MATERIALS); settingsOfMaterials = new MaterialDistributionSettings[EMaterialType.NUMBER_OF_MATERIALS]; for (int i = 0; i < EMaterialType.NUMBER_OF_MATERIALS; i++) { EMaterialType materialType = EMaterialType.VALUES[i]; if (materialType.isDistributionConfigurable()) { settingsOfMaterials[i] = new MaterialDistributionSettings(materialType); } else { settingsOfMaterials[i] = defaultSettings[i]; } } materialProductionSettings = new MaterialProductionSettings(); stockSettings = new StockSettings(INITIAL_STOCK_SETTINGS); }
/** * Draws the stack directly to the screen. * * @param x * The x coordinate of the building * @param y * The y coordinate of the building * @param material * The material the stack should have. * @param count * The number of elements on the stack */ private void drawStackAtScreen(int x, int y, EMaterialType material, int count, float color) { int stackIndex = material.getStackIndex(); Sequence<? extends Image> seq = this.imageProvider.getSettlerSequence(OBJECTS_FILE, stackIndex); draw(seq.getImageSafe(count - 1, () -> Labels.getName(material, count != 1) + "@" + count), x, y, 0, color); }
builder.append(stack.getDy()); builder.append("\" material=\""); builder.append(stack.getMaterialType().name()); builder.append("\" buildrequired=\""); builder.append(stack.requiredForBuild()); builder.append(stack.getDy()); builder.append("\" material=\""); builder.append(stack.getMaterialType().name()); builder.append("\" />\n"); builder.append(stack.getDy()); builder.append("\" material=\""); builder.append(stack.getMaterialType().name()); builder.append("\" />\n");
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (position != null ? position.hashCode() : 0); result = 31 * result + (materialType != null ? materialType.hashCode() : 0); result = 31 * result + (accepted ? 1 : 0); result = 31 * result + (local ? 1 : 0); return result; }
break; case DROP: if (takeDropMaterial != null && takeDropMaterial.isDroppable()) { boolean offerMaterial = strategy.droppingMaterial(); grid.dropMaterial(position, takeDropMaterial, offerMaterial, false);
/** * Creates a new {@link MaterialsManager} that uses the given {@link IJoblessSupplier} and {@link OffersList} for it's operations. * * @param joblessSupplier * {@link IJoblessSupplier} providing the jobless bearers. * @param offersList * {@link OffersList} providing the offered materials. * @param settings * {@link IPartitionSettings} providing the settings of the partition. */ public MaterialsManager(IJoblessSupplier joblessSupplier, OffersList offersList, PartitionManagerSettings settings) { this.joblessSupplier = joblessSupplier; this.offersList = offersList; this.settings = settings; requestQueues = new AbstractMaterialRequestPriorityQueue[EMaterialType.NUMBER_OF_MATERIALS]; for (int i = 0; i < EMaterialType.NUMBER_OF_MATERIALS; i++) { EMaterialType materialType = EMaterialType.VALUES[i]; if (materialType.isDistributionConfigurable()) { requestQueues[i] = new MaterialsForBuildingsRequestPriorityQueue(settings.getDistributionSettings(materialType)); } else { requestQueues[i] = new SimpleMaterialRequestPriorityQueue(); } } }
int count = ship.getCargoCount(j); if (material != null && count > 0) { Sequence<? extends Image> seq = this.imageProvider.getSettlerSequence(OBJECTS_FILE, material.getStackIndex()); Image image = seq.getImageSafe(count - 1, () -> Labels.getName(material, false)); image.drawAt(glDrawContext, viewX + xShift, viewY + yShift + CARGO_DECK_HEIGHT, 0, color, shade); int count = ship.getCargoCount(j); if (material != null && count > 0) { Sequence<? extends Image> seq = this.imageProvider.getSettlerSequence(OBJECTS_FILE, material.getStackIndex()); Image image = seq.getImageSafe(count - 1, () -> Labels.getName(material, false)); image.drawAt(glDrawContext, viewX + xShift, viewY + yShift + CARGO_DECK_HEIGHT, 0, color, shade);
private EMaterialType parseMaterial(final String materialString) { EMaterialType material; if ("*".equals(materialString)) { material = null; } else { material = EMaterialType.valueOf(materialString); } return material; }
private static int getRow(MapDataObject mapObject) { if (mapObject instanceof BuildingMapDataObject) { return BUILDING_START + ((BuildingMapDataObject) mapObject).getType().ordinal(); } else if (mapObject instanceof MovableObject) { return MOVABLE_START + ((MovableObject) mapObject).getType().ordinal(); } else if (mapObject instanceof StackMapDataObject) { return BUILDING_START + ((StackMapDataObject) mapObject).getType().ordinal(); } return -1; }
private static String getName(int row) { if (row >= BUILDING_START) { return Labels.getName(EBuildingType.values()[row - BUILDING_START]); } else if (row >= MOVABLE_START) { return Labels.getName(EMovableType.values()[row - MOVABLE_START]); } else if (row >= MATERIAL_START) { return Labels.getName(EMaterialType.values()[row - MATERIAL_START], true); } return ""; }
/** * Create a new {@link MaterialDisplay} * * @param type * The type of material. * @param amount * The number of materials to show. * @param required * <code>true</code> if those are required materials for build. */ public MaterialDisplay(EMaterialType type, int amount, int required) { String label; if (required < 0) { label = "building-material-count"; } else { label = "building-material-required"; } String text = Labels.getString(label, amount, required); // TODO: use Labels.getName(type) ? addChild(new Button(null, type.getIcon(), type.getIcon(), ""), 0, BUTTON_BOTTOM, 1, 1); addChild(new Label(text, EFontSize.NORMAL), 0, 0, 1, BUTTON_BOTTOM); } }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (managerPosition != null ? managerPosition.hashCode() : 0); result = 31 * result + (materialType != null ? materialType.hashCode() : 0); result = 31 * result + (buildingType != null ? buildingType.hashCode() : 0); result = 31 * result + (ratio != +0.0f ? Float.floatToIntBits(ratio) : 0); return result; } }
private EMaterialType[] getMaterialTypeArray(Attributes attributes) { String foodOrderString = attributes.getValue(FOOD_ORDER); if (foodOrderString == null) { return null; } try { String[] foodOrderStrings = foodOrderString.split(","); EMaterialType[] foodOrder = new EMaterialType[foodOrderStrings.length]; for (int i = 0; i < foodOrderStrings.length; i++) { foodOrder[i] = EMaterialType.valueOf(foodOrderStrings[i]); } return foodOrder; } catch (IllegalArgumentException e) { throw new IllegalAccessError("Food order may only contain EMaterialTypes: " + foodOrderString); } }