diff --git a/isometric-park-fna/Components/AreaComponent.cs b/isometric-park-fna/Components/AreaComponent.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Components/AreaComponent.cs @@ -0,0 +1,11 @@ + +using Microsoft.Xna.Framework; + +using Encompass; + +namespace isometricparkfna.Components { + + public struct AreaComponent : IComponent { + public Vector2[] squares; + } +} diff --git a/isometric-park-fna/Engines/GameBridgeEngine.cs b/isometric-park-fna/Engines/GameBridgeEngine.cs --- a/isometric-park-fna/Engines/GameBridgeEngine.cs +++ b/isometric-park-fna/Engines/GameBridgeEngine.cs @@ -4,10 +4,12 @@ using Encompass; using isometricparkfna.Messages; +using isometricparkfna.Components; namespace isometricparkfna.Engines { [Receives(typeof(ToggleWindowMessage), typeof(ToggleVisibilityMessage))] + [Reads(typeof(AreaComponent))] class GameBridgeEngine : Engine { @@ -51,6 +53,20 @@ } } + foreach (ref readonly var entity in ReadEntities()) + { + game.in_zone = false; + var areaComponent = GetComponent(entity); + foreach (var square in areaComponent.squares) + { + if (game.mouseGrid == square) + { + game.in_zone = true; + } + } + + } + } } 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 @@ -58,9 +58,12 @@ Simulation simulation; - Vector2 mouseGrid; + public Vector2 mouseGrid; Vector2 original_point; + //for now + public bool in_zone; + private ImGuiRenderer _imGuiRenderer; private DebugWindow debugWindow; @@ -723,7 +726,10 @@ String status_left = ""; if (MathUtils.Between(this.mouseGrid.X, -1, this.simulation.map.MapWidth) && MathUtils.Between(this.mouseGrid.Y, -1, this.simulation.map.MapHeight)) { - status_left = String.Format("{0:},{1:} {2}", this.mouseGrid.X, this.mouseGrid.Y, this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status); + status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y, + this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status, + this.in_zone ? "Contracted" : "Unzoned" + ); } String header_left = String.Format("${0:}|{1:} \ue124", this.simulation.money, this.simulation.map.tree_count); diff --git a/isometric-park-fna/Renderers/AreaRenderer.cs b/isometric-park-fna/Renderers/AreaRenderer.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Renderers/AreaRenderer.cs @@ -0,0 +1,39 @@ + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using isometricparkfna.UI; +using isometricparkfna.Components; + +using Encompass; +using SpriteFontPlus; + +namespace isometricparkfna.Renderers +{ + public class AreaRenderer : GeneralRenderer + { + private SpriteBatch batch; + private SpriteFont font; + + + public AreaRenderer(SpriteBatch batch, SpriteFont font) + { + this.batch = batch; + this.font = font; + } + + + public override void Render() + { + + var budgetWindow = new BudgetWindow(new Budget { }, this.font, 0, 0); + + foreach (ref readonly var entity in ReadEntities()) + { + var areaComponent = GetComponent(entity); + Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal); + + } + } + } +}