private bool CanPlace(IPlaceable placeable, Position position, Position3D position3D) { if (position3D == null) { return(false); } if (!placeable.CanPlace(position, this)) { return(false); } List <IPlaceable> overlappingContent = GetContent(position); if (overlappingContent == null) { return(false); } foreach (IPlaceable currentOccupant in overlappingContent) { if (!placeable.CanColocate(placeable)) { return(false); } } return(true); }
public bool Place(Floor floor, Coord pos, IGenerator rng) { int energy = StartingEnergy; Queue <Coord> frontier = new Queue <Coord>(); HashSet <Coord> explored = new HashSet <Coord>(); frontier.Enqueue(pos); while (frontier.Count > 0 && energy > 0) { Coord next = frontier.Dequeue(); if (rng.NextDouble() > SpreadChance) { energy--; if (rng.NextDouble() < DeadChance) { explored.Add(next); } continue; } if (!floor.MapInfo.Map.IsWalkable(next) || !_generator.CanPlace(floor, next, rng)) { continue; } _generator.Place(floor, next, rng); explored.Add(next); energy--; foreach (Coord neighbor in AdjacencyRule.CARDINALS.Neighbors(next)) { if (!explored.Contains(neighbor)) { frontier.Enqueue(neighbor); } } } return(true); }