Class Placement

java.lang.Object
squidpony.squidgrid.mapping.Placement

public class Placement
extends Object
Utility class for finding areas where game-specific terrain features might be suitable to place. Example placement for alongStraightWalls, using all regions where there's an extended straight wall in a room to place a rack of bows (as curly braces): https://gist.github.com/tommyettinger/2b69a265bd93304f091b Created by Tommy Ettinger on 3/13/2016.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    RoomFinder finder
    The RoomFinder this uses internally to find placement areas only where they are appropriate.
  • Constructor Summary

    Constructors 
    Constructor Description
    Placement​(RoomFinder finder)
    Constructs a Placement using the given RoomFinder, which will have collections of rooms, corridors, and caves.
  • Method Summary

    Modifier and Type Method Description
    OrderedSet<OrderedSet<Coord>> getAlongStraightWalls()
    Gets an OrderedSet of OrderedSet of Coord, where each inner OrderedSet of Coord refers to a placement region along a straight wall with length 3 or more, not including corners.
    OrderedSet<OrderedSet<Coord>> getCenters()
    Gets an OrderedSet of OrderedSet of Coord, where each inner OrderedSet of Coord refers to a room's cells that are furthest from the walls, and each Coord is one of those central positions.
    OrderedSet<OrderedSet<Coord>> getCorners()
    Gets an OrderedSet of OrderedSet of Coord, where each inner OrderedSet of Coord refers to a room's corners, and each Coord is one of those corners.
    OrderedSet<Coord> getHidingPlaces​(Radius radiusStrategy, int range)
    Gets an OrderedSet of Coord, where each Coord is hidden (using the given radiusStrategy and range for FOV calculations) from any doorways or similar narrow choke-points where a character might be easily ambushed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • finder

      The RoomFinder this uses internally to find placement areas only where they are appropriate.
  • Constructor Details

    • Placement

      public Placement​(RoomFinder finder)
      Constructs a Placement using the given RoomFinder, which will have collections of rooms, corridors, and caves. A common use case for this class involves the Placement field that is constructed in a SectionDungeonGenerator when generate() or generateRespectingStairs() in that class is called; if you use SectionDungeonGenerator, there isn't much need for this constructor, since you can normally use the one created as a field in that class.
      Parameters:
      finder - a RoomFinder that must not be null.
  • Method Details

    • getAlongStraightWalls

      Gets an OrderedSet of OrderedSet of Coord, where each inner OrderedSet of Coord refers to a placement region along a straight wall with length 3 or more, not including corners. Each Coord refers to a single cell along the straight wall. This could be useful for placing weapon racks in armories, chalkboards in schoolrooms (tutorial missions, perhaps?), or even large paintings/murals in palaces.
      Returns:
      a set of sets of Coord where each set of Coord is a wall's viable placement for long things along it
    • getCorners

      Gets an OrderedSet of OrderedSet of Coord, where each inner OrderedSet of Coord refers to a room's corners, and each Coord is one of those corners. There are more uses for corner placement than I can list. This doesn't always identify all corners, since it only finds ones in rooms, and a cave too close to a corner can cause that corner to be ignored.
      Returns:
      a set of sets of Coord where each set of Coord is a room's corners
    • getCenters

      Gets an OrderedSet of OrderedSet of Coord, where each inner OrderedSet of Coord refers to a room's cells that are furthest from the walls, and each Coord is one of those central positions. There are many uses for this, like finding a position to place a throne or shrine in a large room where it should be visible from all around. This doesn't always identify all centers, since it only finds ones in rooms, and it can also find multiple central points if they are all the same distance from a wall (common in something like a 3x7 room, where it will find a 1x5 column as the centers of that room).
      Returns:
      a set of sets of Coord where each set of Coord contains a room's cells that are furthest from the walls.
    • getHidingPlaces

      public OrderedSet<Coord> getHidingPlaces​(Radius radiusStrategy, int range)
      Gets an OrderedSet of Coord, where each Coord is hidden (using the given radiusStrategy and range for FOV calculations) from any doorways or similar narrow choke-points where a character might be easily ambushed. If multiple choke-points can see a cell (using shadow-casting FOV, which is asymmetrical), then the cell is very unlikely to be included in the returned Coords, but if a cell is visible from one or no choke-points and is far enough away, then it is more likely to be included.
      Parameters:
      radiusStrategy - a Radius object that will be used to determine visibility.
      range - the minimum distance things are expected to hide at; often related to player FOV range
      Returns:
      a Set of Coord where each Coord is either far away from or is concealed from a door-like area