Class GridGroup
java.lang.Object
dev.prozilla.pine.core.component.Component
dev.prozilla.pine.core.component.sprite.GridGroup
- All Implemented Interfaces:
Destructible,Printable,ApplicationContext,ApplicationProvider,ComponentsContext,ComponentsProvider,EntityContext,EntityProvider,SceneContext,SceneProvider
A component that groups 2D tiles together and aligns them in a grid pattern.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTile(TileRenderer tile) Adds a tile to this grid based on the tile's current coordinate.addTile(TilePrefab tilePrefab, int x, int y) addTile(TilePrefab tilePrefab, Vector2i coordinate) coordinateToPosition(int x, int y) coordinateToPosition(Vector2i coordinate) booleandestroyTile(Vector2i coordinate) booleandestroyTile(TileRenderer tile) booleandestroyTile(Entity entity) getName()getTile(int x, int y) booleanhasTile(int x, int y) booleanbooleanisHovering(TileRenderer tile) booleanisHovering(Entity entity) voidpositionToCoordinate(float x, float y) positionToCoordinate(Vector2f position) booleanremoveTile(Vector2i coordinate) booleanremoveTile(TileRenderer tile) booleanremoveTile(Entity entity) static Vector2i[]subgrid(int width, int height) Returns an array of coordinates of a subgrid defined by the given dimensions.static Vector2i[]Returns an array of coordinates of a subgrid defined by the given dimensions.static Vector2i[]Returns an array of coordinates of a subgrid defined by the given dimensions, with a given offset.Methods inherited from class dev.prozilla.pine.core.component.Component
destroy, equals, getApplication, getEntity, getScene, hashCode, onEntityChange, setActive, setEntity, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.prozilla.pine.core.ApplicationProvider
getAudioDevice, getConfig, getInput, getLocalStorage, getLogger, getModManager, getRenderer, getTimer, getTracker, getWindowMethods inherited from interface dev.prozilla.pine.core.component.ComponentsProvider
getComponent, getComponentInParent, getComponentInParent, getComponents, getComponentsInChildrenMethods inherited from interface dev.prozilla.pine.core.entity.EntityContext
isDescendantOfMethods inherited from interface dev.prozilla.pine.core.entity.EntityProvider
getChild, getChildWithTag, getFirstChild, getLastChild, getParentWithTag, getTransform, isDescendantOfMethods inherited from interface dev.prozilla.pine.core.scene.SceneProvider
getCameraData, getWorld
-
Field Details
-
size
public int size -
coordinateToTile
-
hoveringTile
-
-
Constructor Details
-
GridGroup
public GridGroup(int size)
-
-
Method Details
-
getName
-
addTile
-
addTile
-
addTile
-
addTile
-
addTile
Adds a tile to this grid based on the tile's current coordinate.- Parameters:
tile- Tile to add to this grid- Throws:
IllegalStateException- If there is already a tile in this grid with the same coordinateNullPointerException
-
destroyTile
-
destroyTile
-
destroyTile
-
removeTile
-
removeTile
-
removeTile
-
hasTile
public boolean hasTile(int x, int y) -
hasTile
-
getTile
-
getTile
-
moveTile
-
isHovering
-
isHovering
-
positionToCoordinate
-
positionToCoordinate
-
coordinateToPosition
-
coordinateToPosition
-
subgrid
Returns an array of coordinates of a subgrid defined by the given dimensions, with a given offset.- Parameters:
dimensions- The dimensions of the subgridoffset- The offset of the subgrid- Returns:
- The coordinates of the subgrid
- See Also:
-
subgrid
Returns an array of coordinates of a subgrid defined by the given dimensions.- Parameters:
dimensions- The dimensions of the subgrid- Returns:
- The coordinates of the subgrid
- See Also:
-
subgrid
Returns an array of coordinates of a subgrid defined by the given dimensions.The x-coordinates go from
0towidth - 1and the y-coordinates go from0toheight - 1.The array is sorted first based on the x-coordinate, then the y-coordinate.
- Parameters:
width- The width of the subgridheight- The height of the subgrid- Returns:
- The coordinates of the subgrid
-