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 @@ -2000,6 +2000,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 @@ -347,7 +347,7 @@
},
"ToleranceEffects": {
"UV": 0.03,
"Oxygen": 0.01
"Oxygen": 0.015
},
"Density": 1600,
"Graphics": {
Expand Down Expand Up @@ -393,7 +393,7 @@
}
},
"ToleranceEffects": {
"Oxygen": 0.03
"Oxygen": 0.035
},
"Density": 1000,
"Graphics": {
Expand Down Expand Up @@ -439,7 +439,7 @@
}
},
"ToleranceEffects": {
"Oxygen": -0.03
"Oxygen": -0.04
},
"Density": 1000,
"Graphics": {
Expand Down Expand Up @@ -481,7 +481,7 @@
}
},
"ToleranceEffects": {
"Oxygen": -0.06
"Oxygen": -0.07
},
"Density": 1000,
"Graphics": {
Expand Down Expand Up @@ -750,7 +750,7 @@
}
},
"ToleranceEffects": {
"Oxygen": 0.06
"Oxygen": 0.08
},
"Density": 1000,
"Graphics": {
Expand Down Expand Up @@ -804,7 +804,7 @@
}
},
"ToleranceEffects": {
"Oxygen": 0.01
"Oxygen": 0.02
},
"Density": 1100,
"Graphics": {
Expand Down Expand Up @@ -954,7 +954,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 increase a bit so make sure the tolerance is high enough
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
20 changes: 19 additions & 1 deletion src/microbe_stage/editor/TolerancesEditorSubComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public partial class TolerancesEditorSubComponent : EditorComponentBase<ICellEdi
[Export]
private Slider oxygenResistanceSlider = null!;

[Export]
private Control oxygenResistanceSpacer = null!;

[Export]
private Slider uvResistanceSlider = null!;

Expand Down Expand Up @@ -239,7 +242,7 @@ public override void OnEditorSpeciesSetup(Species species)
if (!wasFreshInit)
{
// The latest data should have already been loaded into CurrentTolerances

SetOxygenSliderWidth();
ApplyCurrentValuesToGUI();
}
else
Expand All @@ -248,6 +251,7 @@ public override void OnEditorSpeciesSetup(Species species)
var speciesTolerance = Editor.EditedBaseSpecies.Tolerances;
CurrentTolerances.CopyFrom(speciesTolerance);

SetOxygenSliderWidth();
ResetToCurrentSpeciesTolerances();
}

Expand Down Expand Up @@ -456,6 +460,20 @@ protected override void RegisterTooltips()
}
}

private void SetOxygenSliderWidth()
{
// 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);
var sliderMaxValue = Math.Max(Constants.TOLERANCE_OXYGEN_RANGE_MAX, oxygenMaxValue);

oxygenResistanceSlider.MaxValue = sliderMaxValue;
oxygenResistanceSlider.SetStretchRatio(sliderMaxValue);
oxygenResistanceSpacer.SetStretchRatio(1 - sliderMaxValue);
}

private void CalculateStatsAndShow(EnvironmentalTolerances calculationTolerances,
EnvironmentalToleranceToolTip toolTip)
{
Expand Down
52 changes: 35 additions & 17 deletions src/microbe_stage/editor/TolerancesEditorSubComponent.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ region_rect = Rect2(0, 0, 258, 1)

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_n6u17"]

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_evsrs"]
[sub_resource type="StyleBoxLine" id="StyleBoxLine_xmghy"]
color = Color(0.439216, 0.623529, 0.623529, 1)
thickness = 5

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_jstjb"]

[node name="TolerancesEditorSubComponent" type="VBoxContainer" unique_id=1336617322 node_paths=PackedStringArray("temperatureToolTipContainer", "pressureToolTipContainer", "oxygenResistanceToolTipContainer", "uvResistanceToolTipContainer", "temperatureSlider", "temperatureToleranceRangeSlider", "pressureSlider", "pressureToleranceRangeSlider", "oxygenResistanceSlider", "uvResistanceSlider", "temperatureMinLabel", "temperatureMaxLabel", "temperatureToleranceLabel", "temperatureModifierLabel", "temperatureRangeDisplay", "temperatureLabelContainer", "pressureMinLabel", "pressureMaxLabel", "pressureToleranceLabel", "pressureModifierLabel", "pressureRangeDisplay", "pressureLabelContainer", "oxygenResistanceModifierLabel", "oxygenResistanceTotalLabel", "oxygenResistanceRangeDisplay", "oxygenResistanceLabelContainer", "uvResistanceModifierLabel", "uvResistanceTotalLabel", "uvResistanceRangeDisplay", "uvResistanceLabelContainer")]
[node name="TolerancesEditorSubComponent" type="VBoxContainer" unique_id=1336617322 node_paths=PackedStringArray("temperatureToolTipContainer", "pressureToolTipContainer", "oxygenResistanceToolTipContainer", "uvResistanceToolTipContainer", "temperatureSlider", "temperatureToleranceRangeSlider", "pressureSlider", "pressureToleranceRangeSlider", "oxygenResistanceSlider", "oxygenResistanceSpacer", "uvResistanceSlider", "temperatureMinLabel", "temperatureMaxLabel", "temperatureToleranceLabel", "temperatureModifierLabel", "temperatureRangeDisplay", "temperatureLabelContainer", "pressureMinLabel", "pressureMaxLabel", "pressureToleranceLabel", "pressureModifierLabel", "pressureRangeDisplay", "pressureLabelContainer", "oxygenResistanceModifierLabel", "oxygenResistanceTotalLabel", "oxygenResistanceRangeDisplay", "oxygenResistanceLabelContainer", "uvResistanceModifierLabel", "uvResistanceTotalLabel", "uvResistanceRangeDisplay", "uvResistanceLabelContainer")]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
Expand All @@ -44,7 +46,8 @@ temperatureSlider = NodePath("Temperature/RangeDisplayContainer/VBoxContainer/Te
temperatureToleranceRangeSlider = NodePath("Temperature/HBoxContainer3/TemperatureRange")
pressureSlider = NodePath("Pressure/RangeDisplayContainer/VBoxContainer/PressureSlider")
pressureToleranceRangeSlider = NodePath("Pressure/HBoxContainer4/PressureRange")
oxygenResistanceSlider = NodePath("Oxygen/RangeDisplayContainer/VBoxContainer/OxygenResistanceSlider")
oxygenResistanceSlider = NodePath("Oxygen/RangeDisplayContainer/VBoxContainer/HBoxContainer/OxygenResistanceSlider")
oxygenResistanceSpacer = NodePath("Oxygen/RangeDisplayContainer/VBoxContainer/HBoxContainer/OxygenResistanceSpacer")
uvResistanceSlider = NodePath("UV/RangeDisplayContainer/VBoxContainer/UVResistanceSlider")
temperatureMinLabel = NodePath("Temperature/HBoxContainer2/Total/TemperatureMinimum")
temperatureMaxLabel = NodePath("Temperature/HBoxContainer2/Total/TemperatureMaximum")
Expand Down Expand Up @@ -349,8 +352,8 @@ layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
focus_neighbor_top = NodePath("../../RangeDisplayContainer/VBoxContainer/PressureSlider")
focus_neighbor_bottom = NodePath("../../../Oxygen/RangeDisplayContainer/VBoxContainer/OxygenResistanceSlider")
focus_next = NodePath("../../../Oxygen/RangeDisplayContainer/VBoxContainer/OxygenResistanceSlider")
focus_neighbor_bottom = NodePath("../../../Oxygen/RangeDisplayContainer/VBoxContainer/HBoxContainer/OxygenResistanceSlider")
focus_next = NodePath("../../../Oxygen/RangeDisplayContainer/VBoxContainer/HBoxContainer/OxygenResistanceSlider")
focus_previous = NodePath("../../RangeDisplayContainer/VBoxContainer/PressureSlider")
mouse_filter = 1
min_value = 200000.0
Expand Down Expand Up @@ -465,19 +468,34 @@ max_value = 1.0
step = 0.01
value = 0.0
beginConnectorFromMarker = 2
relatedSlider = NodePath("../OxygenResistanceSlider")
relatedSlider = NodePath("../HBoxContainer/OxygenResistanceSlider")

[node name="OxygenResistanceSlider" type="HSlider" parent="Oxygen/RangeDisplayContainer/VBoxContainer" unique_id=967114038]
[node name="HBoxContainer" type="HBoxContainer" parent="Oxygen/RangeDisplayContainer/VBoxContainer" unique_id=1215608808]
layout_mode = 2
theme_override_constants/separation = -1

[node name="OxygenResistanceSlider" type="HSlider" parent="Oxygen/RangeDisplayContainer/VBoxContainer/HBoxContainer" unique_id=967114038]
layout_mode = 2
size_flags_horizontal = 3
focus_neighbor_top = NodePath("../../../../Pressure/HBoxContainer4/PressureRange")
focus_neighbor_bottom = NodePath("../../../../UV/RangeDisplayContainer/VBoxContainer/UVResistanceSlider")
focus_next = NodePath("../../../../UV/RangeDisplayContainer/VBoxContainer/UVResistanceSlider")
focus_previous = NodePath("../../../../Pressure/HBoxContainer4/PressureRange")
size_flags_vertical = 1
size_flags_stretch_ratio = 10.0
focus_neighbor_top = NodePath("../../../../../Pressure/HBoxContainer4/PressureRange")
focus_neighbor_bottom = NodePath("../../../../../UV/RangeDisplayContainer/VBoxContainer/UVResistanceSlider")
focus_next = NodePath("../../../../../UV/RangeDisplayContainer/VBoxContainer/UVResistanceSlider")
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
theme_override_styles/slider = SubResource("StyleBoxLine_xmghy")
max_value = 0.1
step = 0.01

[node name="OxygenResistanceSpacer" type="Control" parent="Oxygen/RangeDisplayContainer/VBoxContainer/HBoxContainer" unique_id=574488409]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 90.0
focus_neighbor_top = NodePath("../../../../../Pressure/HBoxContainer4/PressureRange")
focus_neighbor_bottom = NodePath("../../../../../UV/RangeDisplayContainer/VBoxContainer/UVResistanceSlider")
focus_next = NodePath("../../../../../UV/RangeDisplayContainer/VBoxContainer/UVResistanceSlider")
focus_previous = NodePath("../../../../../Pressure/HBoxContainer4/PressureRange")

[node name="Spacer2" type="Control" parent="Oxygen/RangeDisplayContainer" unique_id=1372406449]
custom_minimum_size = Vector2(8, 0)
Expand Down Expand Up @@ -575,8 +593,8 @@ relatedSlider = NodePath("../UVResistanceSlider")
[node name="UVResistanceSlider" type="HSlider" parent="UV/RangeDisplayContainer/VBoxContainer" unique_id=142203687]
layout_mode = 2
size_flags_horizontal = 3
focus_neighbor_top = NodePath("../../../../Oxygen/RangeDisplayContainer/VBoxContainer/OxygenResistanceSlider")
focus_previous = NodePath("../../../../Oxygen/RangeDisplayContainer/VBoxContainer/OxygenResistanceSlider")
focus_neighbor_top = NodePath("../../../../Oxygen/RangeDisplayContainer/VBoxContainer/HBoxContainer/OxygenResistanceSlider")
focus_previous = NodePath("../../../../Oxygen/RangeDisplayContainer/VBoxContainer/HBoxContainer/OxygenResistanceSlider")
theme_override_constants/center_grabber = 1
theme_override_styles/slider = SubResource("StyleBoxEmpty_jstjb")
max_value = 1.0
Expand All @@ -590,6 +608,6 @@ layout_mode = 2
[connection signal="value_changed" from="Temperature/HBoxContainer3/TemperatureRange" to="." method="OnTemperatureToleranceRangeSliderChanged"]
[connection signal="value_changed" from="Pressure/RangeDisplayContainer/VBoxContainer/PressureSlider" to="." method="OnPressureSliderChanged"]
[connection signal="value_changed" from="Pressure/HBoxContainer4/PressureRange" to="." method="OnPressureToleranceRangeSliderChanged"]
[connection signal="value_changed" from="Oxygen/RangeDisplayContainer/VBoxContainer/OxygenResistanceSlider" to="." method="OnOxygenResistanceSliderChanged"]
[connection signal="value_changed" from="Oxygen/RangeDisplayContainer/VBoxContainer/HBoxContainer/OxygenResistanceSlider" to="." method="OnOxygenResistanceSliderChanged"]
[connection signal="resized" from="UV/RangeDisplayContainer/VBoxContainer/UVResistanceSlider" to="." method="OnResized"]
[connection signal="value_changed" from="UV/RangeDisplayContainer/VBoxContainer/UVResistanceSlider" to="." method="OnUVResistanceSliderChanged"]