diff --git a/isometric-park-fna/Engines/BuildToolEngine.cs b/isometric-park-fna/Engines/BuildToolEngine.cs --- a/isometric-park-fna/Engines/BuildToolEngine.cs +++ b/isometric-park-fna/Engines/BuildToolEngine.cs @@ -27,7 +27,8 @@ typeof(ToolComponent), typeof(PointComponent))] [Sends(typeof(ChangeContractStatusMessage), - typeof(PlaySoundMessage))] + typeof(PlaySoundMessage), + typeof(SingleExpenseMessage))] public class BuildToolEngine : Engine { private CellMap Map; @@ -255,6 +256,8 @@ new StructureComponent { Structure = Structure.Tower}); Destroy(entity); SendMessage(new PlaySoundMessage { SoundName = "ConstructionShort" }); + SendMessage(new SingleExpenseMessage { category = "Construction", + amount = 500M }); Logging.Success("Placed Tower!"); } diff --git a/isometric-park-fna/Engines/SimulationBridgeEngine.cs b/isometric-park-fna/Engines/SimulationBridgeEngine.cs --- a/isometric-park-fna/Engines/SimulationBridgeEngine.cs +++ b/isometric-park-fna/Engines/SimulationBridgeEngine.cs @@ -21,6 +21,7 @@ typeof(TreeDeltaComponent), typeof(PreserveComponent))] [Writes(typeof(BudgetComponent))] + [Receives(typeof(SingleExpenseMessage))] public class SimulationBridgeEngine : Engine { public Simulation simulation; @@ -55,6 +56,11 @@ public override void Update(double dt) { + foreach (ref readonly var message in ReadMessages()) + { + this.simulation.AddConstruction(message.amount); + } + foreach (ref readonly var entity in ReadEntities()) { ref readonly var budgetComponent = ref GetComponent(entity); diff --git a/isometric-park-fna/Simulation.cs b/isometric-park-fna/Simulation.cs --- a/isometric-park-fna/Simulation.cs +++ b/isometric-park-fna/Simulation.cs @@ -29,6 +29,7 @@ public decimal tree_clearing; public decimal miscellaneous; public decimal enforcement; + public decimal construction; public decimal final_money; @@ -137,6 +138,7 @@ return new Budget { }; } } + } public System.Collections.Generic.IEnumerable allBudgets() @@ -391,6 +393,17 @@ } } + public void AddConstruction(decimal construction_amount) + { + if (this.budgets.Count >= 1) { + var budget = this.budgets[this.budgets.Count - 1]; + + budget.final_money -= construction_amount; + budget.construction += construction_amount; + this.budgets[this.budgets.Count - 1] = budget; + } + } + public void updateNews() { this.latestNewsItems = this.sourceNewsItems.Select(s => s.Flatten(this.grammar)).ToList().Shuffle(); } @@ -402,6 +415,7 @@ this.updateNews(); } + public void update(TimeSpan deltaTime) { if (!this.paused) diff --git a/isometric-park-fna/UI/BudgetWindow.cs b/isometric-park-fna/UI/BudgetWindow.cs --- a/isometric-park-fna/UI/BudgetWindow.cs +++ b/isometric-park-fna/UI/BudgetWindow.cs @@ -122,6 +122,7 @@ 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); 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); batch.DrawString(font, line_format("Enforcement", this.budget.enforcement, this.previous_budget.enforcement), new Vector2(x, bar_height * 14 + y), Color.Black); + batch.DrawString(font, line_format("Construction", this.budget.construction, this.previous_budget.construction), new Vector2(x, bar_height * 15 + y), Color.Black); Color cashflow_color = Color.Black; if (this.budget.cashflow < 0) { @@ -132,8 +133,8 @@ final_color = Color.Red; } - batch.DrawString(font, line_format("Cashflow", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 16 + y), cashflow_color); - batch.DrawString(font, line_format("Ending Funds", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 17 + y), final_color); + batch.DrawString(font, line_format("Cashflow", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 17 + y), cashflow_color); + 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); FilledRectangle.drawFilledRectangle(batch, new Rectangle(50, 50, 50, 50), new Color (0, 0,0, 0), 0.99f);