Package group24.escaperoom.data
Class Grid
java.lang.Object
group24.escaperoom.data.Grid
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classclassA Tile of the Grid -
Field Summary
FieldsModifier and TypeFieldDescriptionitemscontains all items involved with this grid.ItemPropertyinitialization can depend on all items being available in the map.placedItemsis a subset ofitemsplacedItemsonly contains items which are visible and represented on a tile. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsItemWhere(Predicate<Item> predicate) static Gridcurrent()Get the current grid instancefindItemWhere(Predicate<Item> predicate) Find the first item on the grid wherepredicateis truegetAt(int x, int y) Get the tile atx, yif it is within boundsintgetItemByID(int id) getSize()intgetTileDepthOf(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"intgetWidth()booleanPlace anitemon the Grid - a precondition to this function is thatMapScreen.canPlace(group24.escaperoom.entities.Item, group24.escaperoom.data.Types.IntVector2, group24.escaperoom.data.Grid)returned truevoidvoidread(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonData) voidremoveItem(Item item) Remove this item from the grid.voidwrite(com.badlogic.gdx.utils.Json json)
-
Field Details
-
items
itemscontains all items involved with this grid. This includes invisible items, contained items, etc. -
placedItems
placedItemsis a subset ofitemsplacedItemsonly contains items which are visible and represented on a tile. -
onMapCompletion
ItemPropertyinitialization 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
-
current
Get the current grid instance -
getItemByID
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
containsItemWhere
- Returns:
- whether or not a placed item on the grid fufills
predicate
-
getSize
-
findItemWhere
Find the first item on the grid wherepredicateis true -
getAt
Get the tile atx, yif it is within bounds -
printGrid
public void printGrid() -
placeItem
Place anitemon the Grid - a precondition to this function is thatMapScreen.canPlace(group24.escaperoom.entities.Item, group24.escaperoom.data.Types.IntVector2, group24.escaperoom.data.Grid)returned true -
getTileDepthOf
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
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:
writein interfacecom.badlogic.gdx.utils.Json.Serializable
-
read
public void read(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonData) - Specified by:
readin interfacecom.badlogic.gdx.utils.Json.Serializable
-