public class MapSquareGrid<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
extends java.lang.Object
implements java.io.Serializable
MapSquare instances.| Constructor and Description |
|---|
MapSquareGrid(@NotNull MapModel<G,A,R> mapModel,
@NotNull Size2D mapSize)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearMap()
This implementation is very safe by recreating every single MapSquare as
new empty square with the trade-off of some strain of the
garbage-collector.
|
void |
collectHeads(int minX,
int minY,
int maxX,
int maxY,
@NotNull java.util.Collection<GameObject<G,A,R>> objectsToDelete)
Adds all head parts for game object within an area to a collection.
|
@NotNull Size2D |
getMapSize()
Returns the size of this map grid in map squares.
|
@NotNull MapSquare<G,A,R> |
getMapSquare(int x,
int y)
Returns the
MapSquare at a given location. |
boolean |
isEmpty()
Returns whether the map is empty.
|
void |
resize(@NotNull Size2D newSize)
Resizes the map grid to a new size.
|
@NotNull public @NotNull MapSquare<G,A,R> getMapSquare(int x, int y)
MapSquare at a given location.x - the location's x coordinatey - the location's y coordinatejava.lang.IndexOutOfBoundsException - if the location is not within boundspublic void clearMap()
public boolean isEmpty()
true if the map is empty, or false if the map is
not emptypublic void resize(@NotNull
@NotNull Size2D newSize)
newSize - the new sizepublic void collectHeads(int minX,
int minY,
int maxX,
int maxY,
@NotNull
@NotNull java.util.Collection<GameObject<G,A,R>> objectsToDelete)
minX - the x coordinate of the left border of the areaminY - the y coordinate of the top border of the areamaxX - the x coordinate of the right border of the areamaxY - the y coordinate of the bottom border of the areaobjectsToDelete - the collection where the heads are added to@NotNull public @NotNull Size2D getMapSize()