Description:
Don't allow towers to overlap other towers, water, or trees.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -25,7 +25,8 | |||
|
25 | 25 | typeof(PreserveComponent), |
|
26 | 26 | typeof(SelectedComponent), |
|
27 | 27 | typeof(ToolComponent), |
|
28 |
typeof(PointComponent) |
|
|
28 | typeof(PointComponent), | |
|
29 | typeof(StructureComponent))] | |
|
29 | 30 | [Sends(typeof(ChangeContractStatusMessage), |
|
30 | 31 | typeof(PlaySoundMessage), |
|
31 | 32 | typeof(SingleExpenseMessage))] |
@@ -234,6 +235,13 | |||
|
234 | 235 | occupied.AddRange(entitySquares); |
|
235 | 236 | } |
|
236 | 237 | |
|
238 | foreach (var (entity, point) in ReadEntities<StructureComponent>() | |
|
239 | .WhereF((e) => HasComponent<PointComponent>(e)) | |
|
240 | .Select((e) => (e, GetComponent<PointComponent>(e)))) { | |
|
241 | ||
|
242 | occupied.Add(point.Square); | |
|
243 | } | |
|
244 | ||
|
237 | 245 | foreach (ref readonly var message in ReadMessages<AdjustSelection>()) { |
|
238 | 246 | foreach (ref readonly var entity in ReadEntities<SelectedComponent>()) { |
|
239 | 247 | var selection = GetComponent<SelectedComponent>(entity); |
@@ -246,9 +254,10 | |||
|
246 | 254 | else if(message.Type == AdjustmentType.Complete) { |
|
247 | 255 | var point = GetComponent<PointComponent>(entity); |
|
248 | 256 | var structure_entity = CreateEntity(); |
|
257 | var cell = this.Map.cells[(int)point.Square.X][(int)point.Square.Y]; | |
|
249 | 258 | //Verify square is free: |
|
250 | 259 | // |
|
251 | if (!occupied.Contains(point.Square)) { | |
|
260 | if (!occupied.Contains(point.Square) && !cell.HasTree && !cell.HasWater) { | |
|
252 | 261 | |
|
253 | 262 | AddComponent(structure_entity, new PointComponent {Square = point.Square, |
|
254 | 263 | Tool = point.Tool} ); |
You need to be logged in to leave comments.
Login now