Description:
Allow finalizing preserve areas.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -0,0 +1,10 | |||
|
1 | ||
|
2 | using Encompass; | |
|
3 | using System; | |
|
4 | ||
|
5 | namespace isometricparkfna.Components { | |
|
6 | ||
|
7 | public struct PreserveComponent : IComponent { | |
|
8 | public DateTime date; | |
|
9 | } | |
|
10 | } |
@@ -14,7 +14,9 | |||
|
14 | 14 | |
|
15 | 15 | [Receives(typeof(SpawnSelection), |
|
16 | 16 | typeof(AdjustSelection))] |
|
17 |
[Writes(typeof(AreaComponent) |
|
|
17 | [Writes(typeof(AreaComponent), | |
|
18 | // typeof(SelectedComponent), | |
|
19 | typeof(PreserveComponent))] | |
|
18 | 20 | [Reads(typeof(SelectedComponent), |
|
19 | 21 | typeof(AreaComponent))] |
|
20 | 22 | public class BuildToolEngine : Engine { |
@@ -44,28 +46,32 | |||
|
44 | 46 | |
|
45 | 47 | foreach (ref readonly var message in ReadMessages<SpawnSelection>()) |
|
46 | 48 | { |
|
49 | if (message.Start.X >= 0 && message.Start.X < this.Map.MapWidth | |
|
50 | && message.Start.Y >= 0 && message.Start.Y < this.Map.MapHeight) { | |
|
47 | 51 | var entity = CreateEntity(); |
|
48 | 52 | |
|
49 | 53 | AddComponent(entity, new AreaComponent { squares = new[] {message.Start} }); |
|
50 | 54 | AddComponent(entity, new SelectedComponent { selected = true, Type= SelectionType.ActiveTool}); |
|
55 | } | |
|
51 | 56 | } |
|
52 | 57 | |
|
53 | foreach (ref readonly var message in ReadMessages<AdjustSelection>()) | |
|
54 | { | |
|
55 | foreach (ref readonly var entity in ReadEntities<SelectedComponent>()) | |
|
56 | { | |
|
58 | foreach (ref readonly var message in ReadMessages<AdjustSelection>()) { | |
|
59 | foreach (ref readonly var entity in ReadEntities<SelectedComponent>()) { | |
|
57 | 60 | var selection = GetComponent<SelectedComponent>(entity); |
|
58 |
if(selection.Type == SelectionType.ActiveTool |
|
|
59 |
|
|
|
61 | if(selection.Type == SelectionType.ActiveTool | |
|
62 | && selection.selected) { | |
|
63 | if(message.Type == AdjustmentType.Clear) { | |
|
60 | 64 | Destroy(entity); |
|
61 | 65 | } |
|
66 | else if(message.Type == AdjustmentType.Complete) { | |
|
67 | SetComponent(entity, new PreserveComponent {}); | |
|
68 | // SetComponent(entity, new SelectedComponent {selected = false }); | |
|
69 | } | |
|
62 | 70 | else { |
|
63 | 71 | var area = GetComponent<AreaComponent>(entity); |
|
64 | 72 | |
|
65 | 73 | var newSquares = new List<Vector2>(); |
|
66 | 74 | |
|
67 | newSquares.Add(area.squares[0]); | |
|
68 | ||
|
69 | 75 | var end_x = MathUtils.Clamp(message.End.X, 0.0f, this.Map.MapWidth); |
|
70 | 76 | var end_y = MathUtils.Clamp(message.End.Y, 0.0f, this.Map.MapHeight); |
|
71 | 77 | |
@@ -75,8 +81,6 | |||
|
75 | 81 | } |
|
76 | 82 | } |
|
77 | 83 | |
|
78 | newSquares.Add(message.End); | |
|
79 | ||
|
80 | 84 | SetComponent(entity, new AreaComponent { squares = newSquares.ToArray() /*( new[]{ area.squares[0], message.End}*/}); |
|
81 | 85 | } |
|
82 | 86 | } |
@@ -188,6 +188,7 | |||
|
188 | 188 | { |
|
189 | 189 | SendMessage(new ToggleWindowTypeMessage {Window = Window.InGameMenu}); |
|
190 | 190 | SendMessage(new GameRateMessage { paused = true, rate = null }); |
|
191 | SendMessage(new AdjustSelection {Type = AdjustmentType.Complete }); | |
|
191 | 192 | } |
|
192 | 193 | } |
|
193 | 194 | |
@@ -248,7 +249,7 | |||
|
248 | 249 | |
|
249 | 250 | if ( mouseCur.LeftButton == ButtonState.Released && mousePrev.LeftButton == ButtonState.Pressed ) |
|
250 | 251 | { |
|
251 |
SendMessage(new AdjustSelection { |
|
|
252 | SendMessage(new AdjustSelection {Type = AdjustmentType.Complete }); | |
|
252 | 253 | } |
|
253 | 254 | |
|
254 | 255 | if (mouseCur.LeftButton == ButtonState.Pressed && mousePrev.LeftButton == ButtonState.Pressed) |
@@ -20,7 +20,8 | |||
|
20 | 20 | typeof(SetWindowVisibilityMessage), |
|
21 | 21 | typeof(SelectMessage), |
|
22 | 22 | typeof(SetDialogMessage), |
|
23 |
typeof(DialogChoiceMessage) |
|
|
23 | typeof(DialogChoiceMessage), | |
|
24 | typeof(AdjustSelection))] | |
|
24 | 25 | [Reads(typeof(DialogComponent), |
|
25 | 26 | typeof(WindowTypeComponent), |
|
26 | 27 | typeof(VisibilityComponent), |
@@ -101,7 +102,20 | |||
|
101 | 102 | new SelectedComponent { selected = true }); |
|
102 | 103 | } |
|
103 | 104 | |
|
105 | foreach (ref readonly var message in ReadMessages<AdjustSelection>()) { | |
|
106 | if(message.Type == AdjustmentType.Complete) { | |
|
107 | foreach (ref readonly var entity in ReadEntities<SelectedComponent>()) { | |
|
108 | var selection = GetComponent<SelectedComponent>(entity); | |
|
109 | if(selection.Type == SelectionType.ActiveTool | |
|
110 | && selection.selected) { | |
|
111 | SetComponent(entity, new SelectedComponent {Type = SelectionType.ActiveTool, | |
|
112 | selected = false }); | |
|
113 | } | |
|
114 | } | |
|
115 | } | |
|
116 | } | |
|
104 | 117 | |
|
105 | } | |
|
106 | } | |
|
118 | ||
|
119 | } | |
|
120 | } | |
|
107 | 121 | } |
You need to be logged in to leave comments.
Login now