Description:
Fix style and ensure preserve renders in red.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -19,7 +19,7 | |||||
|
19 | // typeof(SelectedComponent), |
|
19 | // typeof(SelectedComponent), |
|
20 | typeof(PreserveComponent))] |
|
20 | typeof(PreserveComponent))] |
|
21 | [Reads(typeof(SelectedComponent), |
|
21 | [Reads(typeof(SelectedComponent), |
|
22 |
|
|
22 | typeof(ContractStatusComponent), |
|
23 | typeof(AreaComponent), |
|
23 | typeof(AreaComponent), |
|
24 | typeof(PreserveComponent))] |
|
24 | typeof(PreserveComponent))] |
|
25 | public class BuildToolEngine : Engine { |
|
25 | public class BuildToolEngine : Engine { |
@@ -48,19 +48,19 | |||||
|
48 | public override void Update(double dt) { |
|
48 | public override void Update(double dt) { |
|
49 | var occupied = new List<Vector2>(); |
|
49 | var occupied = new List<Vector2>(); |
|
50 | foreach (var (entity, status) in ReadEntities<AreaComponent>() |
|
50 | foreach (var (entity, status) in ReadEntities<AreaComponent>() |
|
51 | .WhereF((e) => HasComponent<ContractStatusComponent>(e)) |
|
51 | .WhereF((e) => HasComponent<ContractStatusComponent>(e)) |
|
52 | .SelectWhereF((e) => (e, GetComponent<ContractStatusComponent>(e)), |
|
52 | .SelectWhereF((e) => (e, GetComponent<ContractStatusComponent>(e)), |
|
53 |
(e) => ((e.Item2.status != ContractStatus.Broken) |
|
53 | (e) => ((e.Item2.status != ContractStatus.Broken) |
|
54 |
&& (e.Item2.status != ContractStatus.Rejected) |
|
54 | && (e.Item2.status != ContractStatus.Rejected) |
|
55 | && (e.Item2.status != ContractStatus.Expired) |
|
55 | && (e.Item2.status != ContractStatus.Expired) |
|
56 | && (e.Item2.status != ContractStatus.Completed) |
|
56 | && (e.Item2.status != ContractStatus.Completed) |
|
57 | && (e.Item2.status != ContractStatus.Proposed)) |
|
57 | && (e.Item2.status != ContractStatus.Proposed)) |
|
58 | )) { |
|
58 | )) { |
|
59 | var entitySquares = GetComponent<AreaComponent>(entity).squares; |
|
59 | var entitySquares = GetComponent<AreaComponent>(entity).squares; |
|
60 | occupied.AddRange(entitySquares); |
|
60 | occupied.AddRange(entitySquares); |
|
61 | } |
|
61 | } |
|
62 | foreach (var entity in ReadEntities<AreaComponent>() |
|
62 | foreach (var entity in ReadEntities<AreaComponent>() |
|
63 | .WhereF((e) => HasComponent<PreserveComponent>(e))) { |
|
63 | .WhereF((e) => HasComponent<PreserveComponent>(e))) { |
|
64 | var entitySquares = GetComponent<AreaComponent>(entity).squares; |
|
64 | var entitySquares = GetComponent<AreaComponent>(entity).squares; |
|
65 | occupied.AddRange(entitySquares); |
|
65 | occupied.AddRange(entitySquares); |
|
66 | } |
|
66 | } |
@@ -71,10 +71,10 | |||||
|
71 | { |
|
71 | { |
|
72 | if (message.Start.X >= 0 && message.Start.X < this.Map.MapWidth |
|
72 | if (message.Start.X >= 0 && message.Start.X < this.Map.MapWidth |
|
73 | && message.Start.Y >= 0 && message.Start.Y < this.Map.MapHeight) { |
|
73 | && message.Start.Y >= 0 && message.Start.Y < this.Map.MapHeight) { |
|
74 | var entity = CreateEntity(); |
|
74 | var entity = CreateEntity(); |
|
75 |
|
75 | ||
|
76 | AddComponent(entity, new AreaComponent { squares = new[] {message.Start} }); |
|
76 | AddComponent(entity, new AreaComponent { squares = new[] {message.Start} }); |
|
77 | AddComponent(entity, new SelectedComponent { selected = true, Type= SelectionType.ActiveTool}); |
|
77 | AddComponent(entity, new SelectedComponent { selected = true, Type= SelectionType.ActiveTool}); |
|
78 | } |
|
78 | } |
|
79 | } |
|
79 | } |
|
80 |
|
80 |
@@ -21,7 +21,7 | |||||
|
21 | [Reads(typeof(AreaComponent), |
|
21 | [Reads(typeof(AreaComponent), |
|
22 | typeof(ContractStatusComponent), |
|
22 | typeof(ContractStatusComponent), |
|
23 | typeof(OptionsComponent), |
|
23 | typeof(OptionsComponent), |
|
24 |
|
|
24 | typeof(PreserveComponent))] |
|
25 | class GameBridgeEngine : Engine |
|
25 | class GameBridgeEngine : Engine |
|
26 | { |
|
26 | { |
|
27 |
|
27 | ||
@@ -89,7 +89,7 | |||||
|
89 |
|
89 | ||
|
90 | game.in_zone = false; |
|
90 | game.in_zone = false; |
|
91 | game.in_active_zone = false; |
|
91 | game.in_active_zone = false; |
|
92 |
|
|
92 | game.in_preserve = false; |
|
93 | foreach (ref readonly var entity in ReadEntities<AreaComponent>()) |
|
93 | foreach (ref readonly var entity in ReadEntities<AreaComponent>()) |
|
94 | { |
|
94 | { |
|
95 | var areaComponent = GetComponent<AreaComponent>(entity); |
|
95 | var areaComponent = GetComponent<AreaComponent>(entity); |
@@ -110,16 +110,16 | |||||
|
110 | } |
|
110 | } |
|
111 | } |
|
111 | } |
|
112 | } |
|
112 | } |
|
113 |
|
|
113 | else if (HasComponent<PreserveComponent>(entity)) { |
|
114 | foreach (var square in areaComponent.squares) { |
|
114 | foreach (var square in areaComponent.squares) { |
|
115 | if (game.mouseGrid == square) |
|
115 | if (game.mouseGrid == square) |
|
116 | { |
|
116 | { |
|
117 |
|
|||
|
118 | game.in_preserve = true; |
|
||
|
119 | } |
|
||
|
120 |
|
117 | ||
|
121 | } |
|
118 | game.in_preserve = true; |
|
122 | } |
|
119 | } |
|
|
120 | |||
|
|
121 | } | ||
|
|
122 | } | ||
|
123 | } |
|
123 | } |
|
124 |
|
124 | ||
|
125 |
|
125 |
@@ -188,7 +188,7 | |||||
|
188 | { |
|
188 | { |
|
189 | SendMessage(new ToggleWindowTypeMessage {Window = Window.InGameMenu}); |
|
189 | SendMessage(new ToggleWindowTypeMessage {Window = Window.InGameMenu}); |
|
190 | SendMessage(new GameRateMessage { paused = true, rate = null }); |
|
190 | SendMessage(new GameRateMessage { paused = true, rate = null }); |
|
191 |
|
|
191 | SendMessage(new AdjustSelection {Type = AdjustmentType.Complete }); |
|
192 | } |
|
192 | } |
|
193 | } |
|
193 | } |
|
194 |
|
194 |
@@ -21,7 +21,7 | |||||
|
21 | typeof(SelectMessage), |
|
21 | typeof(SelectMessage), |
|
22 | typeof(SetDialogMessage), |
|
22 | typeof(SetDialogMessage), |
|
23 | typeof(DialogChoiceMessage), |
|
23 | typeof(DialogChoiceMessage), |
|
24 |
|
|
24 | typeof(AdjustSelection))] |
|
25 | [Reads(typeof(DialogComponent), |
|
25 | [Reads(typeof(DialogComponent), |
|
26 | typeof(WindowTypeComponent), |
|
26 | typeof(WindowTypeComponent), |
|
27 | typeof(VisibilityComponent), |
|
27 | typeof(VisibilityComponent), |
@@ -103,19 +103,20 | |||||
|
103 | } |
|
103 | } |
|
104 |
|
104 | ||
|
105 | foreach (ref readonly var message in ReadMessages<AdjustSelection>()) { |
|
105 | foreach (ref readonly var message in ReadMessages<AdjustSelection>()) { |
|
106 |
|
|
106 | if(message.Type == AdjustmentType.Complete) { |
|
107 |
|
|
107 | foreach (ref readonly var entity in ReadEntities<SelectedComponent>()) { |
|
108 |
|
|
108 | var selection = GetComponent<SelectedComponent>(entity); |
|
109 |
|
|
109 | if(selection.Type == SelectionType.ActiveTool |
|
110 | && selection.selected) { |
|
110 | && selection.selected) { |
|
111 |
|
|
111 | SetComponent(entity, new SelectedComponent {Type = SelectionType.ActiveTool, |
|
112 | selected = false }); |
|
112 | selected = false |
|
113 | } |
|
113 | }); |
|
114 | } |
|
114 | } |
|
115 | } |
|
115 | } |
|
116 | } |
|
116 | } |
|
|
117 | } | ||
|
117 |
|
118 | ||
|
118 |
|
119 | ||
|
119 | } |
|
120 | } |
|
120 | } |
|
121 | } |
|
121 | } |
|
122 | } |
@@ -34,27 +34,24 | |||||
|
34 | // var SelectedComponent = GetComponent<SelectedComponent>(entity); |
|
34 | // var SelectedComponent = GetComponent<SelectedComponent>(entity); |
|
35 | var selected = GetComponent<SelectedComponent>(entity).selected; |
|
35 | var selected = GetComponent<SelectedComponent>(entity).selected; |
|
36 |
|
36 | ||
|
37 |
if |
|
37 | if (!HasComponent<ContractStatusComponent>(entity) ) |
|
38 | || GetComponent<ContractStatusComponent>(entity).status == ContractStatus.Accepted) |
|
38 | { |
|
39 | && !selected) |
|
39 | Quad.FillSquares(batch, areaComponent.squares, Color.Red, 0.5f, 0.79f); |
|
|
40 | Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Red); | ||
|
|
41 | } | ||
|
|
42 | else if ((!HasComponent<ContractStatusComponent>(entity) | ||
|
|
43 | || GetComponent<ContractStatusComponent>(entity).status == ContractStatus.Accepted) | ||
|
|
44 | && !selected) | ||
|
40 | { |
|
45 | { |
|
41 | Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal); |
|
46 | Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal); |
|
42 | Quad.FillSquares(batch, areaComponent.squares, Color.Teal, 0.5f, 0.78f); |
|
47 | Quad.FillSquares(batch, areaComponent.squares, Color.Teal, 0.5f, 0.78f); |
|
43 | } |
|
48 | } |
|
44 |
|
|||
|
45 | else if (HasComponent<ContractStatusComponent>(entity) |
|
49 | else if (HasComponent<ContractStatusComponent>(entity) |
|
46 | && selected |
|
50 | && selected) |
|
47 | // && GetComponent<SelectedComponent>(entity).selected |
|
||
|
48 | ) |
|
||
|
49 | { |
|
51 | { |
|
50 | Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal); |
|
52 | Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal); |
|
51 | Quad.FillSquares(batch, areaComponent.squares, Color.Gray, 0.5f, 0.78f); |
|
53 | Quad.FillSquares(batch, areaComponent.squares, Color.Gray, 0.5f, 0.78f); |
|
52 | } |
|
54 | } |
|
53 | else if (!HasComponent<ContractStatusComponent>(entity) ) |
|
||
|
54 | { |
|
||
|
55 | Quad.FillSquares(batch, areaComponent.squares, Color.Red, 0.5f, 0.79f); |
|
||
|
56 | Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Red); |
|
||
|
57 | } |
|
||
|
58 | } |
|
55 | } |
|
59 | } |
|
56 | } |
|
60 | } |
|
57 | } |
@@ -68,8 +68,8 | |||||
|
68 | } |
|
68 | } |
|
69 | } |
|
69 | } |
|
70 |
|
70 | ||
|
71 |
|
|
71 | public static float Clamp(float val, float min, float max) |
|
72 | { |
|
72 | { |
|
73 | if (val > max) |
|
73 | if (val > max) |
|
74 | { |
|
74 | { |
|
75 | return max; |
|
75 | return max; |
@@ -82,7 +82,7 | |||||
|
82 | { |
|
82 | { |
|
83 | return val; |
|
83 | return val; |
|
84 | } |
|
84 | } |
|
85 | } |
|
85 | } |
|
86 |
|
86 | ||
|
87 | protected float Decrement(float value, float delta) |
|
87 | protected float Decrement(float value, float delta) |
|
88 | { |
|
88 | { |
You need to be logged in to leave comments.
Login now