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 @@ -219,6 +219,19 @@ } } + 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)) + )) { + var entitySquares = GetComponent(entity).squares; + occupied.AddRange(entitySquares); + } + foreach (ref readonly var message in ReadMessages()) { foreach (ref readonly var entity in ReadEntities()) { var selection = GetComponent(entity); @@ -231,13 +244,17 @@ else if(message.Type == AdjustmentType.Complete) { var point = GetComponent(entity); var structure_entity = CreateEntity(); + //Verify square is free: + // + if (!occupied.Contains(point.Square)) { - AddComponent(structure_entity, new PointComponent {Square = point.Square, - Tool = point.Tool} ); - AddComponent(structure_entity, - new StructureComponent { Structure = Structure.Tower}); - Destroy(entity); - Logging.Success("Placed Tower!"); + AddComponent(structure_entity, new PointComponent {Square = point.Square, + Tool = point.Tool} ); + AddComponent(structure_entity, + new StructureComponent { Structure = Structure.Tower}); + Destroy(entity); + Logging.Success("Placed Tower!"); + } } else {