Class Grid

java.lang.Object
group24.escaperoom.data.Grid
All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable

public class Grid extends Object implements com.badlogic.gdx.utils.Json.Serializable
  • Field Details

    • items

      public HashMap<Integer,Item> items
      items contains all items involved with this grid. This includes invisible items, contained items, etc.
    • placedItems

      public HashMap<Integer,Item> placedItems
      placedItems is a subset of items placedItems only contains items which are visible and represented on a tile.
    • onMapCompletion

      public static HashSet<Function<Grid,Void>> onMapCompletion
      ItemProperty initialization can depend on all items being available in the map. e.g. A container might need references to its inner items. During initialization, those properties can register functions here which will be called on map completion.
  • Constructor Details

    • Grid

      public Grid()
    • Grid

      public Grid(int w, int h)
  • Method Details

    • getDrawables

      public TreeSet<Drawable> getDrawables()
    • current

      public static Grid current()
      Get the current grid instance
    • getItemByID

      public Optional<Item> getItemByID(int id)
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • containsItemWhere

      public boolean containsItemWhere(Predicate<Item> predicate)
      Returns:
      whether or not a placed item on the grid fufills predicate
    • getSize

      public Types.Size getSize()
    • findItemWhere

      public Optional<Item> findItemWhere(Predicate<Item> predicate)
      Find the first item on the grid where predicate is true
    • getAt

      public Optional<Grid.Tile> getAt(int x, int y)
      Get the tile at x, y if it is within bounds
    • printGrid

      public void printGrid()
    • placeItem

      public boolean placeItem(Item item)
    • getTileDepthOf

      public int getTileDepthOf(Item item)
      Return the tile depth of this item For a stack of items in a given tile "TOP" ______________ | item A | | ndx=4 dpth=0 | |_______________| | item B | | ndx=3 dpth=1 | |_______________| | item C | | ndx=2 dpth=2 | |_______________| | item D | | ndx=1 dpth=3 | |_______________| | item E | | ndx=0 dpth=4 | |_______________| "BOTTOM"
    • removeItem

      public void removeItem(Item item)
      Remove this item from the grid. - This only removes the item from the grid and does perform any additionally operation that may need to occur on item removal
    • write

      public void write(com.badlogic.gdx.utils.Json json)
      Specified by:
      write in interface com.badlogic.gdx.utils.Json.Serializable
    • read

      public void read(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonData)
      Specified by:
      read in interface com.badlogic.gdx.utils.Json.Serializable