From 7abaccfbeb477e36f3ddeaca0062cc1de7e2b110 Mon Sep 17 00:00:00 2001 From: agent-q1 <suhassuhas2001@gmail.com> Date: Mon, 20 Apr 2020 14:04:00 +0530 Subject: [PATCH 1/2] Added function that provides a temperature facet instead of a constant value of 0.6f --- .../metalrenegades/world/dynamic/TemperatureProvider.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/terasology/metalrenegades/world/dynamic/TemperatureProvider.java b/src/main/java/org/terasology/metalrenegades/world/dynamic/TemperatureProvider.java index db31a452..0396132c 100644 --- a/src/main/java/org/terasology/metalrenegades/world/dynamic/TemperatureProvider.java +++ b/src/main/java/org/terasology/metalrenegades/world/dynamic/TemperatureProvider.java @@ -67,9 +67,9 @@ private float generateWeight() { private double getRandomTemp(BaseVector2i pos) { // float sumOfWeights = 10; // TODO -// Random random = new Random(); + Random random = new Random(); //// float f = random.nextFloat() * sumOfWeights; -// return Math.sqrt(random.nextFloat()); - return 0.6f; + return Math.pow(random.nextFloat(),0.1); +// return 0.6f; } } From a1dac613735013da52826bc52ef53c5c84afcaae Mon Sep 17 00:00:00 2001 From: agent-q1 <suhassuhas2001@gmail.com> Date: Mon, 20 Apr 2020 15:06:03 +0530 Subject: [PATCH 2/2] changes to HumidityProvider --- .../metalrenegades/world/dynamic/HumidityProvider.java | 10 +++++++--- .../world/dynamic/TemperatureProvider.java | 9 +++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/terasology/metalrenegades/world/dynamic/HumidityProvider.java b/src/main/java/org/terasology/metalrenegades/world/dynamic/HumidityProvider.java index d1601ad7..1636809a 100644 --- a/src/main/java/org/terasology/metalrenegades/world/dynamic/HumidityProvider.java +++ b/src/main/java/org/terasology/metalrenegades/world/dynamic/HumidityProvider.java @@ -29,6 +29,8 @@ import org.terasology.world.generation.Produces; import org.terasology.world.generation.facets.SurfaceHumidityFacet; +import java.util.Random; + @Produces(SurfaceHumidityFacet.class) public class HumidityProvider implements ConfigurableFacetProvider { private static final int SAMPLE_RATE = 4; @@ -65,7 +67,7 @@ public void process(GeneratingRegion region) { // TODO: Setup humidity Rect2i processRegion = facet.getWorldRegion(); for (BaseVector2i position: processRegion.contents()) { - double hum = getRandomHumidity(position); + double hum = getRandomHumidity(); facet.setWorld(position, (float) hum); } @@ -98,8 +100,10 @@ private void reload() { noise = new SubSampledNoise(brown, scale, SAMPLE_RATE); } - private float getRandomHumidity(BaseVector2i pos) { - return 0.1f; + private double getRandomHumidity() { + Random random = new Random(); + return 1-Math.pow(random.nextFloat(),0.04); + } public static class Configuration implements Component { diff --git a/src/main/java/org/terasology/metalrenegades/world/dynamic/TemperatureProvider.java b/src/main/java/org/terasology/metalrenegades/world/dynamic/TemperatureProvider.java index 0396132c..ca732de0 100644 --- a/src/main/java/org/terasology/metalrenegades/world/dynamic/TemperatureProvider.java +++ b/src/main/java/org/terasology/metalrenegades/world/dynamic/TemperatureProvider.java @@ -54,7 +54,7 @@ public void process(GeneratingRegion region) { // TODO: Set temperature Rect2i processRegion = facet.getWorldRegion(); for (BaseVector2i position: processRegion.contents()) { - double temp = getRandomTemp(position); + double temp = getRandomTemp(); facet.setWorld(position, (float) temp); } @@ -65,11 +65,8 @@ private float generateWeight() { return 0; } - private double getRandomTemp(BaseVector2i pos) { -// float sumOfWeights = 10; // TODO + private double getRandomTemp() { Random random = new Random(); -//// float f = random.nextFloat() * sumOfWeights; - return Math.pow(random.nextFloat(),0.1); -// return 0.6f; + return Math.pow(random.nextFloat(),0.08); } }