Ejemplo n.º 1
0
 @Override
 public void inject(DimletKey key, DimensionInformation dimensionInformation) {
   SkyDescriptor.Builder builder = new SkyDescriptor.Builder();
   builder.combine(dimensionInformation.getSkyDescriptor());
   SkyDescriptor newDescriptor = DimletObjectMapping.idToSkyDescriptor.get(key);
   if (newDescriptor.specifiesFogColor()) {
     builder.resetFogColor();
   }
   if (newDescriptor.specifiesSkyColor()) {
     builder.resetSkyColor();
   }
   builder.combine(newDescriptor);
   dimensionInformation.setSkyDescriptor(builder.build());
 }
Ejemplo n.º 2
0
  @Override
  public void constructDimension(
      List<Pair<DimletKey, List<DimletKey>>> dimlets,
      Random random,
      DimensionInformation dimensionInformation) {
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_SKY, dimlets);
    if (dimlets.isEmpty()) {
      if (random.nextFloat() < DimletConfiguration.randomSpecialSkyChance) {
        // If nothing was specified then there is random chance we get random sky stuff.
        List<DimletKey> skyIds =
            new ArrayList<DimletKey>(DimletObjectMapping.idToSkyDescriptor.keySet());
        for (int i = 0; i < 1 + random.nextInt(3); i++) {
          DimletKey key = skyIds.get(random.nextInt(skyIds.size()));
          List<DimletKey> modifiers = Collections.emptyList();
          dimlets.add(Pair.of(key, modifiers));
        }
      }

      if (random.nextFloat() < DimletConfiguration.randomSpecialSkyChance) {
        List<DimletKey> bodyKeys = new ArrayList<DimletKey>();
        for (DimletKey key : DimletObjectMapping.idToSkyDescriptor.keySet()) {
          if (DimletObjectMapping.celestialBodies.contains(key)) {
            bodyKeys.add(key);
          }
        }

        for (int i = 0; i < random.nextInt(3); i++) {
          DimletKey key = bodyKeys.get(random.nextInt(bodyKeys.size()));
          List<DimletKey> modifiers = Collections.emptyList();
          dimlets.add(Pair.of(key, modifiers));
        }
      }
    }

    SkyDescriptor.Builder builder = new SkyDescriptor.Builder();
    for (Pair<DimletKey, List<DimletKey>> dimletWithModifiers : dimlets) {
      DimletKey key = dimletWithModifiers.getKey();
      builder.combine(DimletObjectMapping.idToSkyDescriptor.get(key));
    }
    dimensionInformation.setSkyDescriptor(builder.build());
  }