Revert "Rarity System"

This reverts commit a9ce316d282790c4a9b12526a291952486d27ea7.
This commit is contained in:
Daniel Mills 2020-07-22 15:04:28 -04:00
parent a9ce316d28
commit ae5d0b282c
4 changed files with 7 additions and 68 deletions

View File

@ -11,16 +11,15 @@ import ninja.bytecode.iris.util.BiomeResult;
import ninja.bytecode.iris.util.CellGenerator;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.RNG;
import ninja.bytecode.iris.util.RarityCellGenerator;
import ninja.bytecode.shuriken.collections.KList;
public class GenLayerBiome extends GenLayer
{
private CellGenerator region;
private CellGenerator bridge;
private RarityCellGenerator<IrisBiome> land;
private RarityCellGenerator<IrisBiome> shore;
private RarityCellGenerator<IrisBiome> sea;
private CellGenerator land;
private CellGenerator shore;
private CellGenerator sea;
private DimensionChunkGenerator iris;
public GenLayerBiome(DimensionChunkGenerator iris, RNG rng)
@ -29,9 +28,9 @@ public class GenLayerBiome extends GenLayer
this.iris = iris;
region = new CellGenerator(rng.nextParallelRNG(1188519));
bridge = new CellGenerator(rng.nextParallelRNG(1541462));
land = new RarityCellGenerator<>(rng.nextParallelRNG(9045162));
shore = new RarityCellGenerator<>(rng.nextParallelRNG(2342812));
sea = new RarityCellGenerator<>(rng.nextParallelRNG(6135621));
land = new CellGenerator(rng.nextParallelRNG(9045162));
shore = new CellGenerator(rng.nextParallelRNG(2342812));
sea = new CellGenerator(rng.nextParallelRNG(6135621));
}
public IrisRegion getRegion(double bx, double bz)

View File

@ -10,7 +10,6 @@ import lombok.EqualsAndHashCode;
import ninja.bytecode.iris.util.CNG;
import ninja.bytecode.iris.util.CellGenerator;
import ninja.bytecode.iris.util.Desc;
import ninja.bytecode.iris.util.IRare;
import ninja.bytecode.iris.util.RNG;
import ninja.bytecode.shuriken.collections.KList;
import ninja.bytecode.shuriken.logging.L;
@ -18,14 +17,11 @@ import ninja.bytecode.shuriken.logging.L;
@Desc("Represents a biome in iris.")
@Data
@EqualsAndHashCode(callSuper = false)
public class IrisBiome extends IrisRegistrant implements IRare
public class IrisBiome extends IrisRegistrant
{
@Desc("This is the human readable name for this biome. This can and should be different than the file name. This is not used for loading biomes in other objects.")
private String name = "A Biome";
@Desc("The weight of this biome. Higher than 1 is more common, less than 1 (above 0) is rarer")
private double weight = 1D;
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen")
private Dispersion biomeDispersion = Dispersion.SCATTER;

View File

@ -1,6 +0,0 @@
package ninja.bytecode.iris.util;
public interface IRare
{
public double getWeight();
}

View File

@ -1,50 +0,0 @@
package ninja.bytecode.iris.util;
import org.apache.commons.lang.math.DoubleRange;
import ninja.bytecode.shuriken.collections.KList;
import ninja.bytecode.shuriken.collections.KMap;
public class RarityCellGenerator<T extends IRare> extends CellGenerator
{
public RarityCellGenerator(RNG rng)
{
super(rng);
}
public T get(double x, double z, KList<T> t)
{
int totalWeight = 0;
KMap<DoubleRange, T> ranges = new KMap<>();
for(T i : t)
{
int weight = (int) Math.round(1000 * i.getWeight());
if(weight < 1)
{
continue;
}
ranges.put(new DoubleRange(totalWeight, totalWeight + weight), i);
totalWeight += weight;
}
int r = getIndex(x, z, totalWeight);
for(DoubleRange i : ranges.keySet())
{
if(i.containsDouble(r))
{
return ranges.get(i);
}
}
if(!t.isEmpty())
{
return t.get(0);
}
return null;
}
}