Description:
Spawn trees differently in preserves.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -17,7 +17,8 | |||||
|
17 | typeof(BudgetComponent), |
|
17 | typeof(BudgetComponent), |
|
18 | typeof(BudgetLineComponent), |
|
18 | typeof(BudgetLineComponent), |
|
19 | typeof(ContractStatusComponent), |
|
19 | typeof(ContractStatusComponent), |
|
20 |
typeof(TreeDeltaComponent) |
|
20 | typeof(TreeDeltaComponent), |
|
|
21 | typeof(PreserveComponent))] | ||
|
21 | [Writes(typeof(BudgetComponent))] |
|
22 | [Writes(typeof(BudgetComponent))] |
|
22 | public class SimulationBridgeEngine : Engine |
|
23 | public class SimulationBridgeEngine : Engine |
|
23 | { |
|
24 | { |
@@ -68,6 +69,18 | |||||
|
68 | decimal new_enforcement_amount = 0M; |
|
69 | decimal new_enforcement_amount = 0M; |
|
69 | decimal new_misc_amount = 0M; |
|
70 | decimal new_misc_amount = 0M; |
|
70 | // decimal new_upkeep_amount = 0M; |
|
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 | foreach (ref readonly var entity in ReadEntities<BudgetLineComponent>()) |
|
85 | foreach (ref readonly var entity in ReadEntities<BudgetLineComponent>()) |
|
73 | { |
|
86 | { |
@@ -129,7 +129,9 | |||||
|
129 | Logging.Debug(String.Format("Creating contract {0} without organizations.", message.name )); |
|
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 | var entitySquares = GetComponent<AreaComponent>(entity).squares; |
|
135 | var entitySquares = GetComponent<AreaComponent>(entity).squares; |
|
134 | occupied.AddRange(entitySquares); |
|
136 | occupied.AddRange(entitySquares); |
|
135 | } |
|
137 | } |
@@ -60,6 +60,10 | |||||
|
60 | private const float NEIGHBOR_NEW_TREE_CHANCE = 0.995f; |
|
60 | private const float NEIGHBOR_NEW_TREE_CHANCE = 0.995f; |
|
61 | private const float NEIGHBOR_CROWDS_TREE_CHANCE = 0.995f; |
|
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 | public const int TREE_PLANT_COST = 500; |
|
67 | public const int TREE_PLANT_COST = 500; |
|
64 | public const int TREE_CLEAR_COST = 250; |
|
68 | public const int TREE_CLEAR_COST = 250; |
|
65 |
|
69 | ||
@@ -172,6 +176,8 | |||||
|
172 |
|
176 | ||
|
173 | public CellMap map; |
|
177 | public CellMap map; |
|
174 |
|
178 | ||
|
|
179 | public HashSet<Cell> PreserveCells; | ||
|
|
180 | |||
|
175 | public int ticksPerAdvance; |
|
181 | public int ticksPerAdvance; |
|
176 | private float lastAdvance; |
|
182 | private float lastAdvance; |
|
177 | public bool paused; |
|
183 | public bool paused; |
@@ -254,6 +260,8 | |||||
|
254 | this.budgets = new List<Budget>(); |
|
260 | this.budgets = new List<Budget>(); |
|
255 |
|
261 | ||
|
256 | this.BridgeEngine = new SimulationBridgeEngine(this); |
|
262 | this.BridgeEngine = new SimulationBridgeEngine(this); |
|
|
263 | |||
|
|
264 | this.PreserveCells = new HashSet<Cell>(); | ||
|
257 | } |
|
265 | } |
|
258 |
|
266 | ||
|
259 | private void advanceSimulation() |
|
267 | private void advanceSimulation() |
@@ -268,7 +276,7 | |||||
|
268 |
|
276 | ||
|
269 | foreach (Cell cell in this.map.iterate_cells()) |
|
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 | var random_type = random.Next(0, 4); |
|
281 | var random_type = random.Next(0, 4); |
|
274 | cell.AddTree(this.DateTime, (TreeType)random_type); |
|
282 | cell.AddTree(this.DateTime, (TreeType)random_type); |
@@ -281,7 +289,7 | |||||
|
281 | var neighbor = this.map.iterate_neighbors(x, y).First(); |
|
289 | var neighbor = this.map.iterate_neighbors(x, y).First(); |
|
282 | var cell = this.map.cells[x][y]; |
|
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 | var random_type = random.Next(0, 4); |
|
294 | var random_type = random.Next(0, 4); |
|
287 | cell.AddTree(this.DateTime, neighbor.Type); |
|
295 | cell.AddTree(this.DateTime, neighbor.Type); |
@@ -292,7 +300,7 | |||||
|
292 | int crowded_out = 0; |
|
300 | int crowded_out = 0; |
|
293 | foreach (Cell cell in this.map.iterate_cells_with_neighbors(7)) |
|
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 | cell.MarkTreeDead(); |
|
305 | cell.MarkTreeDead(); |
|
298 | crowded_out += 1; |
|
306 | crowded_out += 1; |
You need to be logged in to leave comments.
Login now