diff --git a/isometric-park-fna/Components/BudgetComponent.cs b/isometric-park-fna/Components/BudgetComponent.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Components/BudgetComponent.cs @@ -0,0 +1,11 @@ +using Encompass; + +namespace isometricparkfna.Components { + + public struct BudgetComponent : IComponent { + public Budget currentBudget; + public Budget priorBudget; + + } + +} diff --git a/isometric-park-fna/Components/BudgetWindowComponent.cs b/isometric-park-fna/Components/BudgetWindowComponent.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Components/BudgetWindowComponent.cs @@ -0,0 +1,12 @@ + +using Encompass; + +namespace isometricparkfna.Components { + + public struct BudgetWindowComponent : IComponent { + public Budget currentBudget; + public Budget priorBudget; + + } + +} diff --git a/isometric-park-fna/Components/VisibilityComponent.cs b/isometric-park-fna/Components/VisibilityComponent.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Components/VisibilityComponent.cs @@ -0,0 +1,8 @@ +using Encompass; + +namespace isometricparkfna.Components { + + public struct VisibilityComponent : IComponent { + public bool visible; + } +} diff --git a/isometric-park-fna/Engines/SimulationBridgeEngine.cs b/isometric-park-fna/Engines/SimulationBridgeEngine.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Engines/SimulationBridgeEngine.cs @@ -0,0 +1,39 @@ + +using Microsoft.Xna.Framework.Input; + +using Encompass; + +using isometricparkfna.Messages; +using isometricparkfna.Components; + +namespace isometricparkfna.Engines { + + // [Receives()] + [Reads(typeof(BudgetComponent))] + [Writes(typeof(BudgetComponent))] + class SimulationBridgeEngine : Engine + { + public Simulation simulation; + + public SimulationBridgeEngine(Simulation simulation) + { + this.simulation = simulation; + } + + public override void Update(double dt) + { + + foreach (ref readonly var entity in ReadEntities()) + { + ref readonly var budgetComponent = ref GetComponent(entity); + + SetComponent(entity, new BudgetComponent{currentBudget = this.simulation.latestBudget, + priorBudget = this.simulation.previousBudget}); + } + + } + + + } + +} diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -18,6 +18,7 @@ using isometricparkfna.Utils; using isometricparkfna.UI; using isometricparkfna.Engines; +using isometricparkfna.Components; using ImGuiNET.SampleProgram.XNA; using ImGuiNET; @@ -180,8 +181,17 @@ //let's see if this works: // WorldBuilder = new WorldBuilder(); var dummy_entity = WorldBuilder.CreateEntity(); + + + // WorldBuilder.AddGeneralRenderer(new BudgetWindowRenderer(this.batch, this.monoFont)); WorldBuilder.AddEngine(new InputEngine()); WorldBuilder.AddEngine(new GameBridgeEngine(this)); + WorldBuilder.AddEngine(new SimulationBridgeEngine(this.simulation)); + + var budgetWindow = WorldBuilder.CreateEntity(); + WorldBuilder.SetComponent(budgetWindow, new VisibilityComponent{visible = true}); + WorldBuilder.SetComponent(budgetWindow, new BudgetComponent()); + World = WorldBuilder.Build(); var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), @@ -462,7 +472,7 @@ if (this.showBudget) { - this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget); + // this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget); } diff --git a/isometric-park-fna/Renderers/BudgetWindowRenderer.cs b/isometric-park-fna/Renderers/BudgetWindowRenderer.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Renderers/BudgetWindowRenderer.cs @@ -0,0 +1,35 @@ +using Encompass; + +namespace isometricparkfna.Renderers +{ + public class BudgetWindowRenderer : GeneralRenderer + { + private SpriteBatch batch; + private SpriteFont font; + + + public BudgetWindowRenderer(SpriteBatch batch, SpriteFont font) + { + this.batch = batch; + this.font = font; + } + + + public override void Render() + { + + var budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0); + + foreach (ref readonly var entity in ReadEntities()) + { + // budgetWindow.update + // this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget); + + } + + + + + } + } +} diff --git a/isometric-park-fna/isometric-park-fna.csproj b/isometric-park-fna/isometric-park-fna.csproj --- a/isometric-park-fna/isometric-park-fna.csproj +++ b/isometric-park-fna/isometric-park-fna.csproj @@ -42,6 +42,7 @@ +