Description:
Actually remove trees and add some missing files.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r209:e84a491c9ab6 -

@@ -0,0 +1,8
1 using Encompass;
2
3 namespace isometricparkfna.Components {
4 public struct TreeDeltaComponent : IComponent
5 {
6 public int deltaTrees;
7 }
8 }
1 NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,6
1 using Encompass;
2
3 namespace isometricparkfna.Messages
4 {
5 struct TickMessage : IMessage { }
6 } No newline at end of file
@@ -10,9 +10,11
10 10
11 11 [Receives(typeof(GameRateMessage), typeof(TogglePauseMessage))]
12 12 [Sends(typeof(SpawnContractMessage), typeof(TickMessage))]
13 [Reads(typeof(BudgetComponent),
13 [Reads(typeof(AreaComponent),
14 typeof(BudgetComponent),
14 15 typeof(BudgetLineComponent),
15 typeof(ContractStatusComponent))]
16 typeof(ContractStatusComponent),
17 typeof(TreeDeltaComponent))]
16 18 [Writes(typeof(BudgetComponent))]
17 19 public class SimulationBridgeEngine : Engine
18 20 {
@@ -74,6 +76,7
74 76 }
75 77
76 78
79
77 80 if (this.ticksToSend > 0)
78 81 {
79 82
@@ -83,14 +86,44
83 86 {
84 87 SendMessage<TickMessage>(new TickMessage{});
85 88 //For now:
86 SendMessage<SpawnContractMessage>(new SpawnContractMessage{name = string.Format("Test {0}", this.simulation.DateTime.ToShortDateString())});
89 SendMessage<SpawnContractMessage>(new SpawnContractMessage{ max_squares = 100,
90 name = string.Format("Test {0}", this.simulation.DateTime.ToShortDateString()) });
91
92
93 foreach (ref readonly var entity in ReadEntities<TreeDeltaComponent>())
94 {
95 var status = GetComponent<ContractStatusComponent>(entity).status;
96 var area = GetComponent<AreaComponent>(entity);
97 var delta = GetComponent<TreeDeltaComponent>(entity);
87 98
99 if (status == ContractStatus.Accepted)
100 {
101 var removed = 0;
102 foreach (var square in area.squares)
103 {
104 var cell = simulation.map.cells[(int)square.X][(int)square.Y];
105 if (cell.hasTree)
106 {
107 cell.removeTree();
108 removed++;
109 }
110 if (-removed <= delta.deltaTrees)
111 {
112 break;
113 }
114
115 }
116
117 }
118
119
120 }
88 121 }
89 this.ticksToSend = 0;
122 this.ticksToSend = 0;
90 123
91 124 simulation.contracts = new_contract_amount;
92 125
93 }
94
95 }
126 }
127
128 }
96 129 }
@@ -19,11 +19,16
19 19 public const int CONTRACT_MINIMUM = 50;
20 20 public const int CONTRACT_MAXIMUM = 250;
21 21
22 private int MapWidth;
23 private int MapHeight;
22 24
23 public ContractSpawner()
25
26 public ContractSpawner(int mapWidth, int mapHeight)
24 27 {
25 28 this.random_generator = new Random();
26 29
30 this.MapWidth = mapWidth;
31 this.MapHeight = mapHeight;
27 32 }
28 33 private Vector2[] CreateArea(int start_x, int start_y, int max_size, HashSet<Vector2> occupied_squares)
29 34 {
@@ -44,7 +49,10
44 49 {
45 50 if (random_generator.NextDouble() < 0.5
46 51 && !squares.Contains(new_square)
47 && !occupied_squares.Contains(new_square))
52 && !occupied_squares.Contains(new_square)
53 && MathUtils.BetweenInclusive(new_square.X, 0, this.MapWidth)
54 && MathUtils.BetweenInclusive(new_square.Y, 0, this.MapHeight)
55 )
48 56 {
49 57 squares_to_add.Add(new_square);
50 58 }
@@ -89,6 +97,7
89 97 AddComponent(contract, new NameComponent { DisplayName = message.name });
90 98 AddComponent(contract, new SelectedComponent { selected = false });
91 99 AddComponent(contract, new ContractStatusComponent { status = ContractStatus.Proposed });
100 AddComponent(contract, new TreeDeltaComponent{ deltaTrees = -1});
92 101 AddComponent(contract, new BudgetLineComponent { category = "Contracts",
93 102 //Round to the nearest $5
94 103 amount = (decimal)((contract_amount/5)*5) });
@@ -207,7 +207,7
207 207 WorldBuilder.AddEngine(this.imGuiWindowBridgeEngine);
208 208 WorldBuilder.AddEngine(new ContractStatusEngine());
209 209
210 WorldBuilder.AddEngine(new ContractSpawner());
210 WorldBuilder.AddEngine(new ContractSpawner(simulation.map.MapWidth, simulation.map.MapHeight));
211 211
212 212 WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1);
213 213 WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(debugWindow.monoFont, this.imGuiWindowBridgeEngine), 2);
You need to be logged in to leave comments. Login now