Skip to content

Commit

Permalink
Make pollution cost optional, with setting (#117)
Browse files Browse the repository at this point in the history
The corresponding setting defaults to off and is stored in project file.

Closes #111
  • Loading branch information
shpaass authored May 10, 2024
2 parents 3e55845 + 971851a commit 950402e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Yafc.Model/Analysis/CostAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public override void Compute(Project project, ErrorCollector warnings) {
}

if (minEmissions >= 0f) {
logisticsCost += minEmissions * CostPerPollution * recipe.time;
logisticsCost += minEmissions * CostPerPollution * recipe.time * project.settings.PollutionCostModifier;
}

constraint.SetUb(logisticsCost);
Expand Down
1 change: 1 addition & 0 deletions Yafc.Model/Model/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public class ProjectSettings : ModelObject<Project> {
public float miningProductivity { get; set; }
public int reactorSizeX { get; set; } = 2;
public int reactorSizeY { get; set; } = 2;
public float PollutionCostModifier { get; set; } = 0;
public event Action<bool> changed;
protected internal override void ThisChanged(bool visualOnly) {
changed?.Invoke(visualOnly);
Expand Down
8 changes: 8 additions & 0 deletions Yafc/Windows/PreferencesScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public override void Build(ImGui gui) {
gui.BuildText("Fluid production/consumption:", Font.subheader);
BuildUnitPerTime(gui, true, prefs);

using (gui.EnterRow()) {
gui.BuildText("Pollution cost modifier (0 for off, 100% for old default)", Font.text, topOffset: 0.5f); ;
if (gui.BuildFloatInput(settings.PollutionCostModifier, out var pollutionCostModifier, UnitOfMeasure.Percent, new Padding(0.5f))) {
settings.RecordUndo().PollutionCostModifier = pollutionCostModifier;
gui.Rebuild();
}
}

ChoiceObject(gui, "Default belt:", Database.allBelts, prefs.defaultBelt, s => {
prefs.RecordUndo().defaultBelt = s;
gui.Rebuild();
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Version: 0.6.5
Date: soon
Changes:
- Add a help message and proper handling for command line arguments
- Removed default pollution cost from calculation. Added a setting to customize pollution cost.
- Add fuel consumption recipe for products
----------------------------------------------------------------------------------------------------------------------
Version: 0.6.4
Expand Down

0 comments on commit 950402e

Please sign in to comment.