# HG changeset patch # User Alys Brooks # Date 2022-02-14 07:51:11 # Node ID 361e830439369478bcc8b24b4d02188723b2c7a3 # Parent 3b7a9426f15bc991a04c1fc7a26cf3e074cde932 Fix style and ensure preserve renders in red. 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 @@ -19,7 +19,7 @@ // typeof(SelectedComponent), typeof(PreserveComponent))] [Reads(typeof(SelectedComponent), - typeof(ContractStatusComponent), + typeof(ContractStatusComponent), typeof(AreaComponent), typeof(PreserveComponent))] public class BuildToolEngine : Engine { @@ -48,19 +48,19 @@ public override void Update(double dt) { var occupied = new List(); foreach (var (entity, status) in ReadEntities() - .WhereF((e) => HasComponent(e)) - .SelectWhereF((e) => (e, GetComponent(e)), - (e) => ((e.Item2.status != ContractStatus.Broken) - && (e.Item2.status != ContractStatus.Rejected) - && (e.Item2.status != ContractStatus.Expired) - && (e.Item2.status != ContractStatus.Completed) - && (e.Item2.status != ContractStatus.Proposed)) - )) { + .WhereF((e) => HasComponent(e)) + .SelectWhereF((e) => (e, GetComponent(e)), + (e) => ((e.Item2.status != ContractStatus.Broken) + && (e.Item2.status != ContractStatus.Rejected) + && (e.Item2.status != ContractStatus.Expired) + && (e.Item2.status != ContractStatus.Completed) + && (e.Item2.status != ContractStatus.Proposed)) + )) { var entitySquares = GetComponent(entity).squares; occupied.AddRange(entitySquares); } foreach (var entity in ReadEntities() - .WhereF((e) => HasComponent(e))) { + .WhereF((e) => HasComponent(e))) { var entitySquares = GetComponent(entity).squares; occupied.AddRange(entitySquares); } @@ -71,10 +71,10 @@ { if (message.Start.X >= 0 && message.Start.X < this.Map.MapWidth && message.Start.Y >= 0 && message.Start.Y < this.Map.MapHeight) { - var entity = CreateEntity(); + var entity = CreateEntity(); - AddComponent(entity, new AreaComponent { squares = new[] {message.Start} }); - AddComponent(entity, new SelectedComponent { selected = true, Type= SelectionType.ActiveTool}); + AddComponent(entity, new AreaComponent { squares = new[] {message.Start} }); + AddComponent(entity, new SelectedComponent { selected = true, Type= SelectionType.ActiveTool}); } } 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 @@ -21,7 +21,7 @@ [Reads(typeof(AreaComponent), typeof(ContractStatusComponent), typeof(OptionsComponent), - typeof(PreserveComponent))] + typeof(PreserveComponent))] class GameBridgeEngine : Engine { @@ -89,7 +89,7 @@ game.in_zone = false; game.in_active_zone = false; - game.in_preserve = false; + game.in_preserve = false; foreach (ref readonly var entity in ReadEntities()) { var areaComponent = GetComponent(entity); @@ -110,16 +110,16 @@ } } } - else if (HasComponent(entity)) { + else if (HasComponent(entity)) { foreach (var square in areaComponent.squares) { if (game.mouseGrid == square) { - - game.in_preserve = true; - } - } - } + game.in_preserve = true; + } + + } + } } diff --git a/isometric-park-fna/Engines/InputEngine.cs b/isometric-park-fna/Engines/InputEngine.cs --- a/isometric-park-fna/Engines/InputEngine.cs +++ b/isometric-park-fna/Engines/InputEngine.cs @@ -188,7 +188,7 @@ { SendMessage(new ToggleWindowTypeMessage {Window = Window.InGameMenu}); SendMessage(new GameRateMessage { paused = true, rate = null }); - SendMessage(new AdjustSelection {Type = AdjustmentType.Complete }); + SendMessage(new AdjustSelection {Type = AdjustmentType.Complete }); } } diff --git a/isometric-park-fna/Engines/UIEngine.cs b/isometric-park-fna/Engines/UIEngine.cs --- a/isometric-park-fna/Engines/UIEngine.cs +++ b/isometric-park-fna/Engines/UIEngine.cs @@ -21,7 +21,7 @@ typeof(SelectMessage), typeof(SetDialogMessage), typeof(DialogChoiceMessage), - typeof(AdjustSelection))] + typeof(AdjustSelection))] [Reads(typeof(DialogComponent), typeof(WindowTypeComponent), typeof(VisibilityComponent), @@ -103,19 +103,20 @@ } foreach (ref readonly var message in ReadMessages()) { - if(message.Type == AdjustmentType.Complete) { - foreach (ref readonly var entity in ReadEntities()) { - var selection = GetComponent(entity); - if(selection.Type == SelectionType.ActiveTool - && selection.selected) { - SetComponent(entity, new SelectedComponent {Type = SelectionType.ActiveTool, - selected = false }); - } - } - } - } + if(message.Type == AdjustmentType.Complete) { + foreach (ref readonly var entity in ReadEntities()) { + var selection = GetComponent(entity); + if(selection.Type == SelectionType.ActiveTool + && selection.selected) { + SetComponent(entity, new SelectedComponent {Type = SelectionType.ActiveTool, + selected = false + }); + } + } + } + } - } - } + } + } } diff --git a/isometric-park-fna/Renderers/AreaRenderer.cs b/isometric-park-fna/Renderers/AreaRenderer.cs --- a/isometric-park-fna/Renderers/AreaRenderer.cs +++ b/isometric-park-fna/Renderers/AreaRenderer.cs @@ -34,27 +34,24 @@ // var SelectedComponent = GetComponent(entity); var selected = GetComponent(entity).selected; - if ((!HasComponent(entity) - || GetComponent(entity).status == ContractStatus.Accepted) - && !selected) + if (!HasComponent(entity) ) + { + Quad.FillSquares(batch, areaComponent.squares, Color.Red, 0.5f, 0.79f); + Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Red); + } + else if ((!HasComponent(entity) + || GetComponent(entity).status == ContractStatus.Accepted) + && !selected) { Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal); Quad.FillSquares(batch, areaComponent.squares, Color.Teal, 0.5f, 0.78f); } - else if (HasComponent(entity) - && selected - // && GetComponent(entity).selected - ) + && selected) { Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal); Quad.FillSquares(batch, areaComponent.squares, Color.Gray, 0.5f, 0.78f); } - else if (!HasComponent(entity) ) - { - Quad.FillSquares(batch, areaComponent.squares, Color.Red, 0.5f, 0.79f); - Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Red); - } } } } diff --git a/isometric-park-fna/Utils/MathUtils.cs b/isometric-park-fna/Utils/MathUtils.cs --- a/isometric-park-fna/Utils/MathUtils.cs +++ b/isometric-park-fna/Utils/MathUtils.cs @@ -68,8 +68,8 @@ } } - public static float Clamp(float val, float min, float max) - { + public static float Clamp(float val, float min, float max) + { if (val > max) { return max; @@ -82,7 +82,7 @@ { return val; } - } + } protected float Decrement(float value, float delta) {