Description:
Toggle for Forest Policy plus more tweaks to crowding.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -344,21 +344,16 | |||||
|
344 | this.showBudget = !this.showBudget; |
|
344 | this.showBudget = !this.showBudget; |
|
345 |
|
345 | ||
|
346 | } |
|
346 | } |
|
|
347 | if (keyboardCur.IsKeyDown(Keys.F) && keyboardPrev.IsKeyUp(Keys.F)) | ||
|
|
348 | { | ||
|
|
349 | this.showForest = !this.showForest; | ||
|
|
350 | |||
|
|
351 | } | ||
|
347 | if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C)) |
|
352 | if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C)) |
|
348 | { |
|
353 | { |
|
349 | this.camera.Jump(Vector2.Zero); |
|
354 | this.camera.Jump(Vector2.Zero); |
|
350 |
|
355 | ||
|
351 | } |
|
356 | } |
|
352 | if (keyboardCur.IsKeyDown(Keys.O) && keyboardPrev.IsKeyUp(Keys.O)) |
|
||
|
353 | { |
|
||
|
354 | this.simulation.tree_planting -= 1; |
|
||
|
355 |
|
|||
|
356 | } |
|
||
|
357 | if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P)) |
|
||
|
358 | { |
|
||
|
359 | this.simulation.tree_planting += 1; |
|
||
|
360 |
|
|||
|
361 | } |
|
||
|
362 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) |
|
357 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) |
|
363 | { |
|
358 | { |
|
364 | sound.Play(volume, pitch, pan); |
|
359 | sound.Play(volume, pitch, pan); |
@@ -832,7 +827,10 | |||||
|
832 | ref this.simulation.paused, debugWindow.monoFont, this.currentNode); |
|
827 | ref this.simulation.paused, debugWindow.monoFont, this.currentNode); |
|
833 | } |
|
828 | } |
|
834 |
|
829 | ||
|
835 | ForestWindow.Render(ref this.showForest, debugWindow.monoFont, this.simulation); |
|
830 | if (this.showForest) |
|
|
831 | { | ||
|
|
832 | ForestWindow.Render(ref this.showForest, debugWindow.monoFont, this.simulation); | ||
|
|
833 | } | ||
|
836 |
|
834 | ||
|
837 |
|
835 | ||
|
838 | _imGuiRenderer.AfterLayout(); |
|
836 | _imGuiRenderer.AfterLayout(); |
@@ -42,8 +42,8 | |||||
|
42 | private const float NEIGHBOR_NEW_TREE_CHANCE = 0.995f; |
|
42 | private const float NEIGHBOR_NEW_TREE_CHANCE = 0.995f; |
|
43 | private const float NEIGHBOR_CROWDS_TREE_CHANCE = 0.995f; |
|
43 | private const float NEIGHBOR_CROWDS_TREE_CHANCE = 0.995f; |
|
44 |
|
44 | ||
|
45 |
public const int TREE_PLANT_COST = |
|
45 | public const int TREE_PLANT_COST = 750; |
|
46 |
public const int TREE_CLEAR_COST = |
|
46 | public const int TREE_CLEAR_COST = 500; |
|
47 |
|
47 | ||
|
48 | public int Tick |
|
48 | public int Tick |
|
49 | { |
|
49 | { |
@@ -142,7 +142,7 | |||||
|
142 | _tree_planting = MathUtils.Clamp(value, 0, 25); |
|
142 | _tree_planting = MathUtils.Clamp(value, 0, 25); |
|
143 | } |
|
143 | } |
|
144 | } |
|
144 | } |
|
145 |
public int _tree_clearing = |
|
145 | public int _tree_clearing = 0; |
|
146 | public int tree_clearing |
|
146 | public int tree_clearing |
|
147 | { |
|
147 | { |
|
148 | get { |
|
148 | get { |
@@ -153,10 +153,18 | |||||
|
153 | } |
|
153 | } |
|
154 | } |
|
154 | } |
|
155 |
|
155 | ||
|
|
156 | public int crowded_trees | ||
|
|
157 | { | ||
|
|
158 | get { | ||
|
|
159 | return this.map.iterate_cells_with_neighbors(7).Where(c => c.hasTree).Count(); | ||
|
|
160 | |||
|
|
161 | } | ||
|
|
162 | } | ||
|
|
163 | |||
|
156 | public float healthy_percent |
|
164 | public float healthy_percent |
|
157 | { |
|
165 | { |
|
158 | get { |
|
166 | get { |
|
159 |
return |
|
167 | return (float)(this.map.tree_count - this.map.iterate_cells_with_neighbors(7).Where(c => c.hasTree).Count()) / this.map.tree_count * 100; |
|
160 | } |
|
168 | } |
|
161 | } |
|
169 | } |
|
162 |
|
170 | ||
@@ -182,6 +190,7 | |||||
|
182 |
|
190 | ||
|
183 | this.DateTime = this.DateTime.AddMonths(1); |
|
191 | this.DateTime = this.DateTime.AddMonths(1); |
|
184 |
|
192 | ||
|
|
193 | |||
|
185 | foreach (Cell cell in this.map.iterate_cells()) |
|
194 | foreach (Cell cell in this.map.iterate_cells()) |
|
186 | { |
|
195 | { |
|
187 | if (random.NextDouble() > SPONTANEOUS_NEW_TREE_CHANCE) |
|
196 | if (random.NextDouble() > SPONTANEOUS_NEW_TREE_CHANCE) |
@@ -190,21 +199,27 | |||||
|
190 | } |
|
199 | } |
|
191 | } |
|
200 | } |
|
192 |
|
201 | ||
|
|
202 | int new_planted = 0; | ||
|
193 | foreach (Cell cell in this.map.iterate_cells_with_neighbors(4)) |
|
203 | foreach (Cell cell in this.map.iterate_cells_with_neighbors(4)) |
|
194 | { |
|
204 | { |
|
195 | if (random.NextDouble() > NEIGHBOR_NEW_TREE_CHANCE) |
|
205 | if (random.NextDouble() > NEIGHBOR_NEW_TREE_CHANCE) |
|
196 | { |
|
206 | { |
|
197 | cell.hasTree = true; |
|
207 | cell.hasTree = true; |
|
|
208 | new_planted += 1; | ||
|
198 | } |
|
209 | } |
|
199 | } |
|
210 | } |
|
|
211 | System.Console.WriteLine(String.Format("New {0}", new_planted)); | ||
|
200 |
|
212 | ||
|
|
213 | int crowded_out = 0; | ||
|
201 | foreach (Cell cell in this.map.iterate_cells_with_neighbors(7)) |
|
214 | foreach (Cell cell in this.map.iterate_cells_with_neighbors(7)) |
|
202 | { |
|
215 | { |
|
203 | if (random.NextDouble() > NEIGHBOR_CROWDS_TREE_CHANCE) |
|
216 | if (random.NextDouble() > NEIGHBOR_CROWDS_TREE_CHANCE) |
|
204 | { |
|
217 | { |
|
205 | cell.hasTree = false; |
|
218 | cell.hasTree = false; |
|
|
219 | crowded_out += 1; | ||
|
206 | } |
|
220 | } |
|
207 | } |
|
221 | } |
|
|
222 | System.Console.Write(String.Format("Crowded {0}", crowded_out)); | ||
|
208 |
|
223 | ||
|
209 | int trees_to_plant = this.tree_planting; |
|
224 | int trees_to_plant = this.tree_planting; |
|
210 |
|
225 | ||
@@ -219,22 +234,18 | |||||
|
219 | } |
|
234 | } |
|
220 | } |
|
235 | } |
|
221 |
|
236 | ||
|
|
237 | |||
|
|
238 | // while (trees_to_clear > 0 && neigh.Current != null) | ||
|
222 | int trees_to_clear = this.tree_clearing; |
|
239 | int trees_to_clear = this.tree_clearing; |
|
223 |
|
240 | System.Console.Write(String.Format("Found {0}; ", this.map.iterate_cells_with_neighbors(7).Where(c => c.hasTree).Count())); | |
|
224 |
|
|
241 | foreach (Cell cell in this.map.iterate_cells_with_neighbors(7).Where(c => c.hasTree)) |
|
225 | neigh.MoveNext(); |
|
||
|
226 |
|
|||
|
227 | while (trees_to_clear > 0 && neigh.Current != null) |
|
||
|
228 | { |
|
242 | { |
|
229 | Cell current = neigh.Current; |
|
243 | if (trees_to_clear > 0) { |
|
230 |
|
|
244 | cell.hasTree = false; |
|
231 | neigh.MoveNext(); |
|
245 | trees_to_clear -= 1; |
|
232 |
|
|
246 | } |
|
233 | } |
|
247 | } |
|
234 |
|
248 | ||
|
235 | //this.money -= (this.map.tree_count * 1); |
|
||
|
236 | //this.money += 1000; |
|
||
|
237 |
|
|||
|
238 | Budget newBudget = new Budget |
|
249 | Budget newBudget = new Budget |
|
239 | { |
|
250 | { |
|
240 | DateTime = this.DateTime, |
|
251 | DateTime = this.DateTime, |
@@ -1,7 +1,6 | |||||
|
1 | using ImGuiNET; |
|
1 | using ImGuiNET; |
|
2 |
|
2 | ||
|
3 | using Num = System.Numerics; |
|
3 | using Num = System.Numerics; |
|
4 | using System.Linq; |
|
||
|
5 |
|
4 | ||
|
6 | namespace isometricparkfna.UI |
|
5 | namespace isometricparkfna.UI |
|
7 | { |
|
6 | { |
@@ -42,7 +41,7 | |||||
|
42 | ImGui.SliderInt("Tree Clearing", ref new_tree_clearing, 0, 25, string.Format("%d (${0})", new_tree_clearing*Simulation.TREE_CLEAR_COST)); |
|
41 | ImGui.SliderInt("Tree Clearing", ref new_tree_clearing, 0, 25, string.Format("%d (${0})", new_tree_clearing*Simulation.TREE_CLEAR_COST)); |
|
43 | sim.tree_clearing = new_tree_clearing; |
|
42 | sim.tree_clearing = new_tree_clearing; |
|
44 |
|
43 | ||
|
45 |
ImGui.Text(string.Format("Crowded Trees: {0}", sim. |
|
44 | ImGui.Text(string.Format("Crowded Trees: {0}", sim.crowded_trees )); |
|
46 | ImGui.Text(string.Format("Percent Healthy Trees: {0:F2}", sim.healthy_percent)); |
|
45 | ImGui.Text(string.Format("Percent Healthy Trees: {0:F2}", sim.healthy_percent)); |
|
47 |
|
46 | ||
|
48 | if (ImGui.Button("Okay")) |
|
47 | if (ImGui.Button("Okay")) |
You need to be logged in to leave comments.
Login now