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 @@ -25,7 +25,8 @@ typeof(PreserveComponent), typeof(SelectedComponent), typeof(ToolComponent), - typeof(PointComponent))] + typeof(PointComponent), + typeof(StructureComponent))] [Sends(typeof(ChangeContractStatusMessage), typeof(PlaySoundMessage), typeof(SingleExpenseMessage))] @@ -234,6 +235,13 @@ occupied.AddRange(entitySquares); } + foreach (var (entity, point) in ReadEntities() + .WhereF((e) => HasComponent(e)) + .Select((e) => (e, GetComponent(e)))) { + + occupied.Add(point.Square); + } + foreach (ref readonly var message in ReadMessages()) { foreach (ref readonly var entity in ReadEntities()) { var selection = GetComponent(entity); @@ -246,9 +254,10 @@ else if(message.Type == AdjustmentType.Complete) { var point = GetComponent(entity); var structure_entity = CreateEntity(); + var cell = this.Map.cells[(int)point.Square.X][(int)point.Square.Y]; //Verify square is free: // - if (!occupied.Contains(point.Square)) { + if (!occupied.Contains(point.Square) && !cell.HasTree && !cell.HasWater) { AddComponent(structure_entity, new PointComponent {Square = point.Square, Tool = point.Tool} );