Skip to content

Commit

Permalink
Made temperature local variance smaller in other patches (#5913)
Browse files Browse the repository at this point in the history
so that thermosynthesis isn't accidentally very good in the colder patches
  • Loading branch information
hhyyrylainen authored Feb 20, 2025
1 parent acf0b8e commit aab9102
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
1 change: 0 additions & 1 deletion simulation_parameters/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,6 @@ public static class Constants
public const float OPTIMAL_THERMOPLAST_TEMPERATURE = 100.0f;
public const float THERMOPLAST_GUI_MAX_TEMPERATURE = 140.0f;

public const float NOISE_EFFECT_ON_LOCAL_TEMPERATURE = 70.0f;
public const float TEMPERATURE_CHANGE_TO_TEMPERATURE_MULTIPLIER = 40.0f;
public const float THERMOPLAST_HEAT_UP_SPEED = 0.25f;

Expand Down
4 changes: 4 additions & 0 deletions simulation_parameters/microbe_stage/biomes.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"PatchVents"
],
"GasVolume": 1,
"TemperatureVarianceScale": 70,
"Conditions": {
"Chunks": {
"floatingToxin": {
Expand Down Expand Up @@ -508,6 +509,7 @@
],
"CompoundCloudBrightness": 2,
"GasVolume": 1,
"TemperatureVarianceScale": 20,
"Conditions": {
"Chunks": {
"floatingToxin": {
Expand Down Expand Up @@ -1511,6 +1513,7 @@
},
"CompoundCloudBrightness": 2.5,
"GasVolume": 1,
"TemperatureVarianceScale": 15,
"Conditions": {
"Chunks": {
"floatingToxin": {
Expand Down Expand Up @@ -2347,6 +2350,7 @@
},
"CompoundCloudBrightness": 2.5,
"GasVolume": 1,
"TemperatureVarianceScale": 18,
"Conditions": {
"Chunks": {
"floatingToxin": {
Expand Down
11 changes: 11 additions & 0 deletions src/microbe_stage/Biome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public class Biome : IRegistryType
/// </summary>
public LightDetails Sunlight = new();

/// <summary>
/// How much the temperature in this biome varies on a microscopic scale when moving around
/// </summary>
public float TemperatureVarianceScale = 5;

public float CompoundCloudBrightness = 1.0f;

/// <summary>
Expand Down Expand Up @@ -91,6 +96,12 @@ public void Check(string name)
"cloud brightness needs to be over 0");
}

if (TemperatureVarianceScale < 0)
{
throw new InvalidRegistryDataException(name, GetType().Name,
"temperature variance scale needs to be over 0");
}

TranslationHelper.CopyTranslateTemplatesToTranslateSource(this);
}

Expand Down
6 changes: 5 additions & 1 deletion src/microbe_stage/MicrobeHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,11 @@ private void UpdateHeatHelperWidget(in Entity player)
Constants.THERMOPLAST_MAX_ATP_TEMPERATURE, Constants.THERMOPLAST_GUI_MAX_TEMPERATURE);

if (!float.IsNaN(previousTemperature))
heatAccumulationBar.UpdateIndicator(cellProperties.Temperature > previousTemperature + 0.00001f);
{
// Only show good indicator when temperature is going up and it is within the ATP generation range
heatAccumulationBar.UpdateIndicator(cellProperties.Temperature > previousTemperature + 0.00001f &&
cellProperties.Temperature >= Constants.THERMOPLAST_MIN_ATP_TEMPERATURE);
}

previousTemperature = cellProperties.Temperature;
}
Expand Down
5 changes: 4 additions & 1 deletion src/microbe_stage/systems/MicrobeHeatAccumulationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class MicrobeHeatAccumulationSystem : AEntitySetSystem<float>
private GameWorld? gameWorld;

private float patchTemperatureMiddle;
private float temperatureVarianceScale = 1;

public MicrobeHeatAccumulationSystem(World world, IParallelRunner runner) : base(world, runner,
Constants.SYSTEM_EXTREME_ENTITIES_PER_THREAD)
Expand Down Expand Up @@ -77,7 +78,7 @@ public float SampleTemperatureAt(Vector3 position)

var differenceFromMiddle = rawNoise - Constants.MICROBE_HEAT_NOISE_MIDDLE_POINT;

return patchTemperatureMiddle + differenceFromMiddle * Constants.NOISE_EFFECT_ON_LOCAL_TEMPERATURE;
return patchTemperatureMiddle + differenceFromMiddle * temperatureVarianceScale;
}

protected override void PreUpdate(float delta)
Expand All @@ -103,6 +104,8 @@ protected override void PreUpdate(float delta)
return;
}

temperatureVarianceScale = gameWorld.Map.CurrentPatch.BiomeTemplate.TemperatureVarianceScale;

if (!gameWorld.Map.CurrentPatch.Biome.TryGetCompound(Compound.Temperature, CompoundAmountType.Current,
out var patchTemperature))
{
Expand Down

0 comments on commit aab9102

Please sign in to comment.