Skip to content
2 changes: 1 addition & 1 deletion locale/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -4410,7 +4410,7 @@ msgid "NOTICE_READY_TO_EDIT"
msgstr "Editor is now ready to be entered"

msgid "NOT_ADAPTED_TO_CURRENT_PATCH"
msgstr "Not adapted to current patch conditions. Change the preferred conditions or tolerance ranges to remove the debuffs."
msgstr "Not adapted to the current patch conditions. Change the patch, adjust the tolerance ranges, or add/remove organelles that affect tolerance to remove the debuffs."

msgid "NOT_STARTED_DOT"
msgstr "Not started."
Expand Down
5 changes: 5 additions & 0 deletions simulation_parameters/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,11 @@ public static class Constants
public const float TOLERANCE_INITIAL_PRESSURE_RANGE = 2400000;
public const float TOLERANCE_PRESSURE_RANGE_MAX = 2000000;

// These values must be the same as in the editor
public const float TOLERANCE_OXYGEN_RANGE_MAX = 0.1f;
public const float TOLERANCE_OXYGEN_STEP = 0.01f;
public const float TOLERANCE_UV_STEP = 0.05f;

/// <summary>
/// UV effects only appear once this amount of UV is in a patch
/// </summary>
Expand Down
14 changes: 7 additions & 7 deletions simulation_parameters/microbe_stage/organelles.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
},
"ToleranceEffects": {
"UV": 0.03,
"Oxygen": 0.01
"Oxygen": 0.015
},
"Density": 1600,
"Graphics": {
Expand Down Expand Up @@ -387,7 +387,7 @@
}
},
"ToleranceEffects": {
"Oxygen": 0.03
"Oxygen": 0.035
},
"Density": 1000,
"Graphics": {
Expand Down Expand Up @@ -432,7 +432,7 @@
}
},
"ToleranceEffects": {
"Oxygen": -0.03
"Oxygen": -0.04
},
"Density": 1000,
"Graphics": {
Expand Down Expand Up @@ -473,7 +473,7 @@
}
},
"ToleranceEffects": {
"Oxygen": -0.06
"Oxygen": -0.07
},
"Density": 1000,
"Graphics": {
Expand Down Expand Up @@ -741,7 +741,7 @@
}
},
"ToleranceEffects": {
"Oxygen": 0.06
"Oxygen": 0.08
},
"Density": 1000,
"Graphics": {
Expand Down Expand Up @@ -795,7 +795,7 @@
}
},
"ToleranceEffects": {
"Oxygen": 0.01
"Oxygen": 0.02
},
"Density": 1100,
"Graphics": {
Expand Down Expand Up @@ -945,7 +945,7 @@
},
"ToleranceEffects": {
"UV": 0.08,
"Oxygen": 0.02
"Oxygen": 0.035
},
"Density": 1800,
"Graphics": {
Expand Down
26 changes: 25 additions & 1 deletion src/microbe_stage/Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,36 @@ public EnvironmentalTolerances GenerateOptimalTolerances(
};

// Apply the reverse of the negative effects to balance things out (and slightly exaggerate to not run into
// rounding issues)
// rounding issues). If the effects are positive reduce the tolerance values
if (externalModifiers.OxygenResistance < 0)
{
result.OxygenResistance -= externalModifiers.OxygenResistance * 1.01f;
}
else
{
// auto-evo is run and oxygen levels might decrease a bit so make sure the tolerance is high enough
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment still says the opposite (decrease instead of increase), but other than that the code changes now look good.

result.OxygenResistance *= 1.2f;
result.OxygenResistance -= externalModifiers.OxygenResistance;

// due to rounding make sure the tolerance is always in appropriate range
result.OxygenResistance = Math.Max(result.OxygenResistance, 0);
result.OxygenResistance = (float)(Math.Ceiling(result.OxygenResistance / Constants.TOLERANCE_OXYGEN_STEP) *
Constants.TOLERANCE_OXYGEN_STEP);
}

if (externalModifiers.UVResistance < 0)
{
result.UVResistance -= externalModifiers.UVResistance * 1.01f;
}
else
{
result.UVResistance -= externalModifiers.UVResistance;

// due to rounding make sure the tolerance is always in appropriate range
result.UVResistance = Math.Max(0, result.UVResistance);
result.UVResistance = (float)(Math.Ceiling(result.UVResistance / Constants.TOLERANCE_UV_STEP) *
Constants.TOLERANCE_UV_STEP);
}

if (externalModifiers.PressureTolerance < 0)
result.PressureTolerance -= externalModifiers.PressureTolerance * 1.01f;
Expand Down
14 changes: 14 additions & 0 deletions src/microbe_stage/editor/TolerancesEditorSubComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ public override void OnEditorSpeciesSetup(Species species)
{
// The latest data should have already been loaded into CurrentTolerances

// Allow for bigger max oxygen tolerance range when loading older save or species that were
// created to fit into world with higher oxygen level
var oxygenMaxValue =
(float)(Math.Ceiling(CurrentTolerances.OxygenResistance / Constants.TOLERANCE_OXYGEN_STEP) *
Constants.TOLERANCE_OXYGEN_STEP);
oxygenResistanceSlider.MaxValue =
Math.Max(Constants.TOLERANCE_OXYGEN_RANGE_MAX, oxygenMaxValue);
ApplyCurrentValuesToGUI();
}
else
Expand All @@ -248,6 +255,13 @@ public override void OnEditorSpeciesSetup(Species species)
var speciesTolerance = Editor.EditedBaseSpecies.Tolerances;
CurrentTolerances.CopyFrom(speciesTolerance);

// Allow for bigger max oxygen tolerance range when loading older save or species that were
// created to fit into world with higher oxygen level
var oxygenMaxValue =
(float)(Math.Ceiling(CurrentTolerances.OxygenResistance / Constants.TOLERANCE_OXYGEN_STEP) *
Constants.TOLERANCE_OXYGEN_STEP);
oxygenResistanceSlider.MaxValue =
Math.Max(Constants.TOLERANCE_OXYGEN_RANGE_MAX, oxygenMaxValue);
ResetToCurrentSpeciesTolerances();
}

Expand Down
4 changes: 2 additions & 2 deletions src/microbe_stage/editor/TolerancesEditorSubComponent.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ focus_next = NodePath("../../../../UV/RangeDisplayContainer/VBoxContainer/UVResi
focus_previous = NodePath("../../../../Pressure/HBoxContainer4/PressureRange")
theme_override_constants/center_grabber = 1
theme_override_styles/slider = SubResource("StyleBoxEmpty_evsrs")
max_value = 1.0
step = 0.05
max_value = 0.1
step = 0.01

[node name="Spacer2" type="Control" parent="Oxygen/RangeDisplayContainer" unique_id=1372406449]
custom_minimum_size = Vector2(8, 0)
Expand Down