Search in sources :

Example 1 with MinMaxLayerThickness

use of org.terasology.world.zones.MinMaxLayerThickness in project Terasology by MovingBlocks.

the class LayeredZoneRegionFunctionTest method setup.

@Before
public void setup() {
    parent.addZone(new Zone("Medium sky", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), MEDIUM_SKY))).addZone(new Zone("Low sky", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), LOW_SKY))).addZone(new Zone("Above ground", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), ABOVE_GROUND))).addZone(new Zone("Ground", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), GROUND))).addZone(new Zone("Shallow underground", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), SHALLOW_UNDERGROUND))).addZone(new Zone("Medium underground", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), MEDIUM_UNDERGROUND)));
    parent.setSeed(12345);
    parent.initialize();
    ListMultimap<Class<? extends WorldFacet>, FacetProvider> facetProviderChains = ArrayListMultimap.create();
    facetProviderChains.put(SurfaceHeightFacet.class, (generatingRegion) -> {
        SurfaceHeightFacet facet = new SurfaceHeightFacet(generatingRegion.getRegion(), generatingRegion.getBorderForFacet(SurfaceHeightFacet.class));
        for (BaseVector2i pos : facet.getRelativeRegion().contents()) {
            facet.set(pos, 100);
        }
        generatingRegion.setRegionFacet(SurfaceHeightFacet.class, facet);
    });
    Map<Class<? extends WorldFacet>, Border3D> borders = new HashMap<>();
    borders.put(SurfaceHeightFacet.class, new Border3D(0, 0, 0));
    region = new RegionImpl(Region3i.createFromCenterExtents(new Vector3i(0, 0, 0), 4), facetProviderChains, borders);
}
Also used : HashMap(java.util.HashMap) Zone(org.terasology.world.zones.Zone) FacetProvider(org.terasology.world.generation.FacetProvider) Border3D(org.terasology.world.generation.Border3D) MinMaxLayerThickness(org.terasology.world.zones.MinMaxLayerThickness) LayeredZoneRegionFunction(org.terasology.world.zones.LayeredZoneRegionFunction) WorldFacet(org.terasology.world.generation.WorldFacet) SurfaceHeightFacet(org.terasology.world.generation.facets.SurfaceHeightFacet) BaseVector2i(org.terasology.math.geom.BaseVector2i) Vector3i(org.terasology.math.geom.Vector3i) RegionImpl(org.terasology.world.generation.RegionImpl) Before(org.junit.Before)

Example 2 with MinMaxLayerThickness

use of org.terasology.world.zones.MinMaxLayerThickness in project Terasology by MovingBlocks.

the class LayeredZoneRegionFunctionTest method testCreation.

@Test
public void testCreation() {
    int minWidth = 100;
    int maxWidth = 200;
    int ordering = 1000;
    LayeredZoneRegionFunction function = new LayeredZoneRegionFunction(new MinMaxLayerThickness(minWidth, maxWidth), ordering);
    assertEquals(ordering, function.getOrdering());
}
Also used : MinMaxLayerThickness(org.terasology.world.zones.MinMaxLayerThickness) LayeredZoneRegionFunction(org.terasology.world.zones.LayeredZoneRegionFunction) Test(org.junit.Test)

Aggregations

LayeredZoneRegionFunction (org.terasology.world.zones.LayeredZoneRegionFunction)2 MinMaxLayerThickness (org.terasology.world.zones.MinMaxLayerThickness)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 Test (org.junit.Test)1 BaseVector2i (org.terasology.math.geom.BaseVector2i)1 Vector3i (org.terasology.math.geom.Vector3i)1 Border3D (org.terasology.world.generation.Border3D)1 FacetProvider (org.terasology.world.generation.FacetProvider)1 RegionImpl (org.terasology.world.generation.RegionImpl)1 WorldFacet (org.terasology.world.generation.WorldFacet)1 SurfaceHeightFacet (org.terasology.world.generation.facets.SurfaceHeightFacet)1 Zone (org.terasology.world.zones.Zone)1