public void Decorate(Floor floor, MapArea area, IGenerator rng) { IEnumerable <Coord> wallCoords = area.Perimeter(); Coord roomTop = area.Bounds.MinExtent; Coord roomMax = area.Bounds.MaxExtent; int xSkip = 4; int ySkip = 4; foreach (Coord pos in wallCoords) { // only place on walls if (floor.MapInfo.Map.WalkabilityView[pos]) { continue; } Coord offset = pos - roomTop; if (offset.X % xSkip != 0 && pos.X != roomMax.X) { continue; } if (offset.Y % ySkip != 0 && pos.Y != roomMax.Y) { continue; } _placeable.Place(floor, pos, rng); } area.Bounds.PerimeterPositions(); }
public IRoom Generate(Floor floor, RoomConnection connectAt, IGenerator rng) { MapArea area = GenerateArea(floor.MapInfo, connectAt, rng); HashSet <Coord> perimeter = new HashSet <Coord>(area.Perimeter()); foreach (Coord pos in area.Positions) { if (perimeter.Contains(pos)) { _wall.Place(floor, pos, rng); } else { _floor.Place(floor, pos, rng); } } List <Coord> perimeterList = new List <Coord>(perimeter); List <RoomConnection> connections = new List <RoomConnection>(); HashSet <Direction> usedDirections = new HashSet <Direction>(); for (int n = 0; n < 20 && connections.Count < 4; n++) { Coord connectionPos = perimeterList[rng.Next(perimeterList.Count)]; if (IsCorner(connectionPos, area)) { continue; } Direction dir = GetDirection(connectionPos, area); if (usedDirections.Contains(dir)) { continue; } connections.Add(new RoomConnection(connectionPos, dir, NeighborPossibilities, true)); usedDirections.Add(dir); } return(new BasicRoom(area, connections, this)); }