示例#1
0
  /**
   * Set the default material for a component type.
   *
   * @param componentClass
   * @param material
   */
  public void setDefaultComponentMaterial(
      Class<? extends RocketComponent> componentClass, Material material) {

    putString(
        "componentMaterials",
        componentClass.getSimpleName(),
        material == null ? null : material.toStorableString());
  }
示例#2
0
  /**
   * Get the default material type for the given component.
   *
   * @param componentClass
   * @param type the Material.Type to return.
   * @return
   */
  public Material getDefaultComponentMaterial(
      Class<? extends RocketComponent> componentClass, Material.Type type) {

    String material = get("componentMaterials", componentClass, null);
    if (material != null) {
      try {
        Material m = Material.fromStorableString(material, false);
        if (m.getType() == type) return m;
      } catch (IllegalArgumentException ignore) {
      }
    }

    switch (type) {
      case LINE:
        return StaticFieldHolder.DEFAULT_LINE_MATERIAL;
      case SURFACE:
        return StaticFieldHolder.DEFAULT_SURFACE_MATERIAL;
      case BULK:
        return StaticFieldHolder.DEFAULT_BULK_MATERIAL;
    }
    throw new IllegalArgumentException("Unknown material type: " + type);
  }