Exemplo n.º 1
0
  private void calculateCelestialBodyDescriptors() {
    List<CelestialBodyType> celestialBodies = skyDescriptor.getCelestialBodies();
    // Find the most suitable sun and moon. This is typically the largest sun in the list of
    // celestial bodies.
    int sunidx = -1;
    int bestsun = 0;
    int moonidx = -1;
    int bestmoon = 0;
    for (int i = 0; i < celestialBodies.size(); i++) {
      CelestialBodyType type = celestialBodies.get(i);
      if (type.getGoodSunFactor() > bestsun) {
        bestsun = type.getGoodSunFactor();
        sunidx = i;
      }
      if (type.getGoodMoonFactor() > bestmoon) {
        bestmoon = type.getGoodMoonFactor();
        moonidx = i;
      }
    }

    // Always the same random series.
    Random random = new Random(123);
    random.nextFloat();
    celestialBodyDescriptors = new ArrayList<CelestialBodyDescriptor>();
    for (int i = 0; i < celestialBodies.size(); i++) {
      CelestialBodyType type = celestialBodies.get(i);
      celestialBodyDescriptors.add(new CelestialBodyDescriptor(type, i == sunidx || i == moonidx));
    }
  }
Exemplo n.º 2
0
  public Block getFeatureLiquid(
      Random random,
      Map<FeatureType, List<DimletKey>> modifiersForFeature,
      FeatureType featureType) {
    Block block;
    if (featureTypes.contains(featureType)) {
      List<BlockMeta> blocks = new ArrayList<BlockMeta>();
      List<Block> fluids = new ArrayList<Block>();
      getMaterialAndFluidModifiers(modifiersForFeature.get(featureType), blocks, fluids);

      if (!fluids.isEmpty()) {
        block = fluids.get(random.nextInt(fluids.size()));
        if (block == null) {
          block = Blocks.water; // This is the default in case None was specified.
        }
      } else {
        // Nothing was specified. With a relatively big chance we use stone. But there is also a
        // chance that the material will be something else.
        if (random.nextFloat() < DimletConfiguration.randomOrbFluidChance) {
          DimletKey key = DimletRandomizer.getRandomFluidBlock(random, true);
          actualRfCost += calculateCostFactor(key);
          block = DimletObjectMapping.idToFluid.get(key);
        } else {
          block = Blocks.water;
        }
      }
    } else {
      block = Blocks.water;
    }
    return block;
  }