public MaterialButton(EMaterialType material) { super(material.getIcon()); this.material = material; }
EPriority(int priorityIndex) { this.ordinal = (byte) ordinal(); this.priorityIndex = priorityIndex; }
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; } } }
@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 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); }
@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; }
public ESearchType getSearchType(Attributes attributes) { String string = attributes.getValue(SEARCH); if (string == null) { return null; } else { try { return ESearchType.valueOf(string); } catch (IllegalArgumentException e) { return null; } } }
/** * Create a new messageLabel if a geologist found minerals. * * @param type * The type of minerals. * @param pos * The position * @return The messageLabel object */ public static IMessage foundMinerals(EMaterialType type, ShortPoint2D pos) { return new SimpleMessage(EMessageType.MINERALS, "minerals_" + type.toString(), (byte) -1, pos); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (newPriority != null ? newPriority.hashCode() : 0); return result; }
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); }
private void dropCurrentMaterial() { EMaterialType material = movable.getMaterial(); if (material.isDroppable()) { super.getGrid().dropMaterial(movable.getPosition(), material, true, false); } super.setMaterial(EMaterialType.NO_MATERIAL); }
/** * 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); }
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 ""; }
@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; }
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); } }
@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 void readAndAddRelativeStack(Attributes attributes, ArrayList<RelativeStack> stacks) { try { int dx = Integer.parseInt(attributes.getValue(ATTR_DX)); int dy = Integer.parseInt(attributes.getValue(ATTR_DY)); EMaterialType type = EMaterialType.valueOf(attributes.getValue(ATTR_MATERIAl)); stacks.add(new RelativeStack(dx, dy, type)); } catch (NumberFormatException e) { System.err.println("Warning: illegal number " + "for stack attribute, in definiton for " + buildingName); } catch (IllegalArgumentException e) { System.err.println("Illegal material name in " + buildingName); } }