Description:
Track preserve cells to avoid repeatedly getting same dialog.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r678:5a7d2efe8cea -

@@ -113,7 +113,7
113 113 {
114 114
115 115 #region calculate_preserve_cells
116 var preserve_cell_coordinates = new List<(int, int)>();
116 var preserve_cell_coordinates = new List<(int, int)>();
117 117
118 118 Stopwatch iterPreserves = new Stopwatch();
119 119 iterPreserves.Start();
@@ -190,9 +190,11
190 190 SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "PoorTreeHealth"});
191 191 }
192 192
193 Logging.Spy(new {count = preserve_cell_coordinates.Count()} );
193 Logging.Spy(new {count = preserve_cell_coordinates.Count(), half = (simulation.map.tree_capacity * 0.5)} );
194 194
195 if (preserve_cell_coordinates.Count() > (simulation.map.tree_capacity * 0.5)) {
195 if ((simulation.latestBudget.preserve_cells > (simulation.map.tree_capacity * 0.5))
196 && (simulation.previousBudget.preserve_cells <= (simulation.map.tree_capacity * 0.5)))
197 {
196 198 SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "PreserveHalf"});
197 199 var fundraiserEntity = CreateEntity();
198 200
@@ -200,7 +202,8
200 202 category = "Misc",
201 203 amount = 20_000M });
202 204 }
203 else if (preserve_cell_coordinates.Count() > (simulation.map.tree_capacity * 0.25))
205 else if ((simulation.latestBudget.preserve_cells > (simulation.map.tree_capacity * 0.25))
206 && (simulation.previousBudget.preserve_cells <= (simulation.map.tree_capacity * 0.25)))
204 207 {
205 208 SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "PreserveProgress"});
206 209 }
@@ -254,6 +257,7
254 257 Logging.Info(String.Format("Planted {0} trees, expected {1}, P(destroy)= {2}", added, (expected / 12.0), probability));
255 258 }
256 259 }
260 simulation.preserve_cells = preserve_cell_coordinates.Count();
257 261 }
258 262 this.ticksToSend = 0;
259 263
@@ -40,6 +40,7
40 40 public int trees;
41 41 public int dead_trees;
42 42 public int crowded_trees;
43 public int preserve_cells;
43 44 //Kind of a hack but allows for tracking figures over time without creating a whole new infrastructure
44 45
45 46 }
@@ -112,6 +113,8
112 113 public decimal enforcement;
113 114 public decimal misc;
114 115
116 public int preserve_cells;
117
115 118 public Budget latestBudget
116 119 {
117 120 get
@@ -359,7 +362,8
359 362 upkeep = (int)(this.map.tree_count * 1.5),
360 363 tree_planting = this.tree_planting * Simulation.TREE_PLANT_COST,
361 364 tree_clearing = this.tree_clearing * Simulation.TREE_CLEAR_COST,
362 misc = this.misc
365 misc = this.misc,
366 preserve_cells = this.preserve_cells
363 367 };
364 368
365 369 newBudget = this.applyBudget(newBudget); ;
You need to be logged in to leave comments. Login now