diff --git a/isometric-park-fna/Engines/SimulationBridgeEngine.cs b/isometric-park-fna/Engines/SimulationBridgeEngine.cs --- a/isometric-park-fna/Engines/SimulationBridgeEngine.cs +++ b/isometric-park-fna/Engines/SimulationBridgeEngine.cs @@ -113,7 +113,7 @@ { #region calculate_preserve_cells - var preserve_cell_coordinates = new List<(int, int)>(); + var preserve_cell_coordinates = new List<(int, int)>(); Stopwatch iterPreserves = new Stopwatch(); iterPreserves.Start(); @@ -190,9 +190,11 @@ SendMessage(new SpawnDialogMessage {Path = "PoorTreeHealth"}); } - Logging.Spy(new {count = preserve_cell_coordinates.Count()} ); + Logging.Spy(new {count = preserve_cell_coordinates.Count(), half = (simulation.map.tree_capacity * 0.5)} ); - if (preserve_cell_coordinates.Count() > (simulation.map.tree_capacity * 0.5)) { + if ((simulation.latestBudget.preserve_cells > (simulation.map.tree_capacity * 0.5)) + && (simulation.previousBudget.preserve_cells <= (simulation.map.tree_capacity * 0.5))) + { SendMessage(new SpawnDialogMessage {Path = "PreserveHalf"}); var fundraiserEntity = CreateEntity(); @@ -200,7 +202,8 @@ category = "Misc", amount = 20_000M }); } - else if (preserve_cell_coordinates.Count() > (simulation.map.tree_capacity * 0.25)) + else if ((simulation.latestBudget.preserve_cells > (simulation.map.tree_capacity * 0.25)) + && (simulation.previousBudget.preserve_cells <= (simulation.map.tree_capacity * 0.25))) { SendMessage(new SpawnDialogMessage {Path = "PreserveProgress"}); } @@ -254,6 +257,7 @@ Logging.Info(String.Format("Planted {0} trees, expected {1}, P(destroy)= {2}", added, (expected / 12.0), probability)); } } + simulation.preserve_cells = preserve_cell_coordinates.Count(); } this.ticksToSend = 0; diff --git a/isometric-park-fna/Simulation.cs b/isometric-park-fna/Simulation.cs --- a/isometric-park-fna/Simulation.cs +++ b/isometric-park-fna/Simulation.cs @@ -40,6 +40,7 @@ public int trees; public int dead_trees; public int crowded_trees; + public int preserve_cells; //Kind of a hack but allows for tracking figures over time without creating a whole new infrastructure } @@ -112,6 +113,8 @@ public decimal enforcement; public decimal misc; + public int preserve_cells; + public Budget latestBudget { get @@ -359,7 +362,8 @@ upkeep = (int)(this.map.tree_count * 1.5), tree_planting = this.tree_planting * Simulation.TREE_PLANT_COST, tree_clearing = this.tree_clearing * Simulation.TREE_CLEAR_COST, - misc = this.misc + misc = this.misc, + preserve_cells = this.preserve_cells }; newBudget = this.applyBudget(newBudget); ;