Description:
Prevent overlapping preserves with contracts and other preserves.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r540:42ee0bb805f8 -

@@ -6,6 +6,7
6 using Microsoft.Xna.Framework.Input;
6 using Microsoft.Xna.Framework.Input;
7
7
8 using Encompass;
8 using Encompass;
9 using JM.LinqFaster;
9
10
10 using isometricparkfna.Messages;
11 using isometricparkfna.Messages;
11 using isometricparkfna.Components;
12 using isometricparkfna.Components;
@@ -18,7 +19,9
18 // typeof(SelectedComponent),
19 // typeof(SelectedComponent),
19 typeof(PreserveComponent))]
20 typeof(PreserveComponent))]
20 [Reads(typeof(SelectedComponent),
21 [Reads(typeof(SelectedComponent),
21 typeof(AreaComponent))]
22 typeof(ContractStatusComponent),
23 typeof(AreaComponent),
24 typeof(PreserveComponent))]
22 public class BuildToolEngine : Engine {
25 public class BuildToolEngine : Engine {
23
26
24 private CellMap Map;
27 private CellMap Map;
@@ -43,6 +46,26
43 }
46 }
44
47
45 public override void Update(double dt) {
48 public override void Update(double dt) {
49 var occupied = new List<Vector2>();
50 foreach (var (entity, status) in ReadEntities<AreaComponent>()
51 .WhereF((e) => HasComponent<ContractStatusComponent>(e))
52 .SelectWhereF((e) => (e, GetComponent<ContractStatusComponent>(e)),
53 (e) => ((e.Item2.status != ContractStatus.Broken)
54 && (e.Item2.status != ContractStatus.Rejected)
55 && (e.Item2.status != ContractStatus.Expired)
56 && (e.Item2.status != ContractStatus.Completed)
57 && (e.Item2.status != ContractStatus.Proposed))
58 )) {
59 var entitySquares = GetComponent<AreaComponent>(entity).squares;
60 occupied.AddRange(entitySquares);
61 }
62 foreach (var entity in ReadEntities<AreaComponent>()
63 .WhereF((e) => HasComponent<PreserveComponent>(e))) {
64 var entitySquares = GetComponent<AreaComponent>(entity).squares;
65 occupied.AddRange(entitySquares);
66 }
67
68
46
69
47 foreach (ref readonly var message in ReadMessages<SpawnSelection>())
70 foreach (ref readonly var message in ReadMessages<SpawnSelection>())
48 {
71 {
@@ -77,7 +100,10
77
100
78 foreach (var i in step_until(area.squares[0].X, end_x)) {
101 foreach (var i in step_until(area.squares[0].X, end_x)) {
79 foreach (var j in step_until(area.squares[0].Y, end_y)) {
102 foreach (var j in step_until(area.squares[0].Y, end_y)) {
80 newSquares.Add(new Vector2(i, j));
103 var newSquare = new Vector2(i, j);
104 if (!occupied.Contains(newSquare)) {
105 newSquares.Add(newSquare);
106 }
81 }
107 }
82 }
108 }
83
109
You need to be logged in to leave comments. Login now