Description:
Track preserve cells to avoid repeatedly getting same dialog.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -113,7 +113,7 | |||||
|
113 | { |
|
113 | { |
|
114 |
|
114 | ||
|
115 | #region calculate_preserve_cells |
|
115 | #region calculate_preserve_cells |
|
116 |
|
|
116 | var preserve_cell_coordinates = new List<(int, int)>(); |
|
117 |
|
117 | ||
|
118 | Stopwatch iterPreserves = new Stopwatch(); |
|
118 | Stopwatch iterPreserves = new Stopwatch(); |
|
119 | iterPreserves.Start(); |
|
119 | iterPreserves.Start(); |
@@ -190,9 +190,11 | |||||
|
190 | SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "PoorTreeHealth"}); |
|
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 ( |
|
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 | SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "PreserveHalf"}); |
|
198 | SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "PreserveHalf"}); |
|
197 | var fundraiserEntity = CreateEntity(); |
|
199 | var fundraiserEntity = CreateEntity(); |
|
198 |
|
200 | ||
@@ -200,7 +202,8 | |||||
|
200 | category = "Misc", |
|
202 | category = "Misc", |
|
201 | amount = 20_000M }); |
|
203 | amount = 20_000M }); |
|
202 | } |
|
204 | } |
|
203 |
else if ( |
|
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 | SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "PreserveProgress"}); |
|
208 | SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "PreserveProgress"}); |
|
206 | } |
|
209 | } |
@@ -254,6 +257,7 | |||||
|
254 | Logging.Info(String.Format("Planted {0} trees, expected {1}, P(destroy)= {2}", added, (expected / 12.0), probability)); |
|
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 | this.ticksToSend = 0; |
|
262 | this.ticksToSend = 0; |
|
259 |
|
263 |
@@ -40,6 +40,7 | |||||
|
40 | public int trees; |
|
40 | public int trees; |
|
41 | public int dead_trees; |
|
41 | public int dead_trees; |
|
42 | public int crowded_trees; |
|
42 | public int crowded_trees; |
|
|
43 | public int preserve_cells; | ||
|
43 | //Kind of a hack but allows for tracking figures over time without creating a whole new infrastructure |
|
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 | public decimal enforcement; |
|
113 | public decimal enforcement; |
|
113 | public decimal misc; |
|
114 | public decimal misc; |
|
114 |
|
115 | ||
|
|
116 | public int preserve_cells; | ||
|
|
117 | |||
|
115 | public Budget latestBudget |
|
118 | public Budget latestBudget |
|
116 | { |
|
119 | { |
|
117 | get |
|
120 | get |
@@ -359,7 +362,8 | |||||
|
359 | upkeep = (int)(this.map.tree_count * 1.5), |
|
362 | upkeep = (int)(this.map.tree_count * 1.5), |
|
360 | tree_planting = this.tree_planting * Simulation.TREE_PLANT_COST, |
|
363 | tree_planting = this.tree_planting * Simulation.TREE_PLANT_COST, |
|
361 | tree_clearing = this.tree_clearing * Simulation.TREE_CLEAR_COST, |
|
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 | newBudget = this.applyBudget(newBudget); ; |
|
369 | newBudget = this.applyBudget(newBudget); ; |
You need to be logged in to leave comments.
Login now