Description:
Subtract towers from budget.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -27,7 +27,8 | |||
|
27 | 27 | typeof(ToolComponent), |
|
28 | 28 | typeof(PointComponent))] |
|
29 | 29 | [Sends(typeof(ChangeContractStatusMessage), |
|
30 |
typeof(PlaySoundMessage) |
|
|
30 | typeof(PlaySoundMessage), | |
|
31 | typeof(SingleExpenseMessage))] | |
|
31 | 32 | public class BuildToolEngine : Engine { |
|
32 | 33 | |
|
33 | 34 | private CellMap Map; |
@@ -255,6 +256,8 | |||
|
255 | 256 | new StructureComponent { Structure = Structure.Tower}); |
|
256 | 257 | Destroy(entity); |
|
257 | 258 | SendMessage(new PlaySoundMessage { SoundName = "ConstructionShort" }); |
|
259 | SendMessage(new SingleExpenseMessage { category = "Construction", | |
|
260 | amount = 500M }); | |
|
258 | 261 | Logging.Success("Placed Tower!"); |
|
259 | 262 | } |
|
260 | 263 |
@@ -21,6 +21,7 | |||
|
21 | 21 | typeof(TreeDeltaComponent), |
|
22 | 22 | typeof(PreserveComponent))] |
|
23 | 23 | [Writes(typeof(BudgetComponent))] |
|
24 | [Receives(typeof(SingleExpenseMessage))] | |
|
24 | 25 | public class SimulationBridgeEngine : Engine |
|
25 | 26 | { |
|
26 | 27 | public Simulation simulation; |
@@ -55,6 +56,11 | |||
|
55 | 56 | public override void Update(double dt) |
|
56 | 57 | { |
|
57 | 58 | |
|
59 | foreach (ref readonly var message in ReadMessages<SingleExpenseMessage>()) | |
|
60 | { | |
|
61 | this.simulation.AddConstruction(message.amount); | |
|
62 | } | |
|
63 | ||
|
58 | 64 | foreach (ref readonly var entity in ReadEntities<BudgetComponent>()) |
|
59 | 65 | { |
|
60 | 66 | ref readonly var budgetComponent = ref GetComponent<BudgetComponent>(entity); |
@@ -29,6 +29,7 | |||
|
29 | 29 | public decimal tree_clearing; |
|
30 | 30 | public decimal miscellaneous; |
|
31 | 31 | public decimal enforcement; |
|
32 | public decimal construction; | |
|
32 | 33 | |
|
33 | 34 | |
|
34 | 35 | public decimal final_money; |
@@ -137,6 +138,7 | |||
|
137 | 138 | return new Budget { }; |
|
138 | 139 | } |
|
139 | 140 | } |
|
141 | ||
|
140 | 142 | } |
|
141 | 143 | |
|
142 | 144 | public System.Collections.Generic.IEnumerable<Budget> allBudgets() |
@@ -391,6 +393,17 | |||
|
391 | 393 | } |
|
392 | 394 | } |
|
393 | 395 | |
|
396 | public void AddConstruction(decimal construction_amount) | |
|
397 | { | |
|
398 | if (this.budgets.Count >= 1) { | |
|
399 | var budget = this.budgets[this.budgets.Count - 1]; | |
|
400 | ||
|
401 | budget.final_money -= construction_amount; | |
|
402 | budget.construction += construction_amount; | |
|
403 | this.budgets[this.budgets.Count - 1] = budget; | |
|
404 | } | |
|
405 | } | |
|
406 | ||
|
394 | 407 | public void updateNews() { |
|
395 | 408 | this.latestNewsItems = this.sourceNewsItems.Select(s => s.Flatten(this.grammar)).ToList().Shuffle(); |
|
396 | 409 | } |
@@ -402,6 +415,7 | |||
|
402 | 415 | this.updateNews(); |
|
403 | 416 | } |
|
404 | 417 | |
|
418 | ||
|
405 | 419 | public void update(TimeSpan deltaTime) |
|
406 | 420 | { |
|
407 | 421 | if (!this.paused) |
@@ -122,6 +122,7 | |||
|
122 | 122 | batch.DrawString(font, line_format("Tree Planting", this.budget.tree_planting, this.previous_budget.tree_planting), new Vector2(x, bar_height * 12 + y), Color.Black); |
|
123 | 123 | batch.DrawString(font, line_format("Tree Clearing", this.budget.tree_clearing, this.previous_budget.tree_clearing), new Vector2(x, bar_height * 13 + y), Color.Black); |
|
124 | 124 | batch.DrawString(font, line_format("Enforcement", this.budget.enforcement, this.previous_budget.enforcement), new Vector2(x, bar_height * 14 + y), Color.Black); |
|
125 | batch.DrawString(font, line_format("Construction", this.budget.construction, this.previous_budget.construction), new Vector2(x, bar_height * 15 + y), Color.Black); | |
|
125 | 126 | |
|
126 | 127 | Color cashflow_color = Color.Black; |
|
127 | 128 | if (this.budget.cashflow < 0) { |
@@ -132,8 +133,8 | |||
|
132 | 133 | final_color = Color.Red; |
|
133 | 134 | } |
|
134 | 135 | |
|
135 |
batch.DrawString(font, line_format("Cashflow", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 1 |
|
|
136 |
batch.DrawString(font, line_format("Ending Funds", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 1 |
|
|
136 | batch.DrawString(font, line_format("Cashflow", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 17 + y), cashflow_color); | |
|
137 | batch.DrawString(font, line_format("Ending Funds", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 18 + y), final_color); | |
|
137 | 138 | |
|
138 | 139 | |
|
139 | 140 | FilledRectangle.drawFilledRectangle(batch, new Rectangle(50, 50, 50, 50), new Color (0, 0,0, 0), 0.99f); |
You need to be logged in to leave comments.
Login now