Description:
Spawn trees differently in preserves.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r549:f1b00533ab6a -

@@ -17,7 +17,8
17 17 typeof(BudgetComponent),
18 18 typeof(BudgetLineComponent),
19 19 typeof(ContractStatusComponent),
20 typeof(TreeDeltaComponent))]
20 typeof(TreeDeltaComponent),
21 typeof(PreserveComponent))]
21 22 [Writes(typeof(BudgetComponent))]
22 23 public class SimulationBridgeEngine : Engine
23 24 {
@@ -68,6 +69,18
68 69 decimal new_enforcement_amount = 0M;
69 70 decimal new_misc_amount = 0M;
70 71 // decimal new_upkeep_amount = 0M;
72
73 this.simulation.PreserveCells.Clear();
74
75 foreach (ref readonly var entity in ReadEntities<PreserveComponent>()) {
76 ref readonly var areaComponent = ref GetComponent<AreaComponent>(entity);
77
78 foreach (var square in areaComponent.squares) {
79 this.simulation.PreserveCells.Add(this.simulation.map.cells[(int)square.X][(int)square.Y]);
80 }
81
82
83 }
71 84
72 85 foreach (ref readonly var entity in ReadEntities<BudgetLineComponent>())
73 86 {
@@ -129,7 +129,9
129 129 Logging.Debug(String.Format("Creating contract {0} without organizations.", message.name ));
130 130 }
131 131
132 foreach (var (entity, status) in ReadEntities<AreaComponent>().SelectWhereF((e) => (e, GetComponent<ContractStatusComponent>(e)), (e) => ((e.Item2.status != ContractStatus.Broken) && (e.Item2.status != ContractStatus.Rejected) && (e.Item2.status != ContractStatus.Expired)))) {
132 foreach (var (entity, status) in ReadEntities<AreaComponent>()
133 .WhereF((e) => HasComponent<ContractStatusComponent>(e))
134 .SelectWhereF((e) => (e, GetComponent<ContractStatusComponent>(e)), (e) => ((e.Item2.status != ContractStatus.Broken) && (e.Item2.status != ContractStatus.Rejected) && (e.Item2.status != ContractStatus.Expired)))) {
133 135 var entitySquares = GetComponent<AreaComponent>(entity).squares;
134 136 occupied.AddRange(entitySquares);
135 137 }
@@ -60,6 +60,10
60 60 private const float NEIGHBOR_NEW_TREE_CHANCE = 0.995f;
61 61 private const float NEIGHBOR_CROWDS_TREE_CHANCE = 0.995f;
62 62
63 private const float PRESERVE_SPONTANEOUS_NEW_TREE_CHANCE = 0.995f;
64 private const float PRESERVE_NEIGHBOR_NEW_TREE_CHANCE = 0.995f;
65 private const float PRESERVE_NEIGHBOR_CROWDS_TREE_CHANCE = 0.9995f;
66
63 67 public const int TREE_PLANT_COST = 500;
64 68 public const int TREE_CLEAR_COST = 250;
65 69
@@ -172,6 +176,8
172 176
173 177 public CellMap map;
174 178
179 public HashSet<Cell> PreserveCells;
180
175 181 public int ticksPerAdvance;
176 182 private float lastAdvance;
177 183 public bool paused;
@@ -254,6 +260,8
254 260 this.budgets = new List<Budget>();
255 261
256 262 this.BridgeEngine = new SimulationBridgeEngine(this);
263
264 this.PreserveCells = new HashSet<Cell>();
257 265 }
258 266
259 267 private void advanceSimulation()
@@ -268,7 +276,7
268 276
269 277 foreach (Cell cell in this.map.iterate_cells())
270 278 {
271 if (random.NextDouble() > SPONTANEOUS_NEW_TREE_CHANCE)
279 if (random.NextDouble() > (this.PreserveCells.Contains(cell) ? PRESERVE_SPONTANEOUS_NEW_TREE_CHANCE : SPONTANEOUS_NEW_TREE_CHANCE ))
272 280 {
273 281 var random_type = random.Next(0, 4);
274 282 cell.AddTree(this.DateTime, (TreeType)random_type);
@@ -281,7 +289,7
281 289 var neighbor = this.map.iterate_neighbors(x, y).First();
282 290 var cell = this.map.cells[x][y];
283 291
284 if (random.NextDouble() > NEIGHBOR_NEW_TREE_CHANCE)
292 if (random.NextDouble() > (this.PreserveCells.Contains(cell) ? PRESERVE_NEIGHBOR_NEW_TREE_CHANCE : NEIGHBOR_NEW_TREE_CHANCE ))
285 293 {
286 294 var random_type = random.Next(0, 4);
287 295 cell.AddTree(this.DateTime, neighbor.Type);
@@ -292,7 +300,7
292 300 int crowded_out = 0;
293 301 foreach (Cell cell in this.map.iterate_cells_with_neighbors(7))
294 302 {
295 if (random.NextDouble() > NEIGHBOR_CROWDS_TREE_CHANCE)
303 if (random.NextDouble() > (this.PreserveCells.Contains(cell) ? PRESERVE_NEIGHBOR_CROWDS_TREE_CHANCE : NEIGHBOR_CROWDS_TREE_CHANCE ) )
296 304 {
297 305 cell.MarkTreeDead();
298 306 crowded_out += 1;
You need to be logged in to leave comments. Login now