Package net.sf.gridarta.model.mapmodel
Class MapSquareGrid<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.mapmodel.MapSquareGrid<G,A,R>
-
- All Implemented Interfaces:
java.io.Serializable
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.SerializableA rectangular grid ofMapSquareinstances.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearMap()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.voidcollectHeads(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 Size2DgetMapSize()Returns the size of this map grid in map squares.@NotNull MapSquare<G,A,R>getMapSquare(int x, int y)Returns theMapSquareat a given location.booleanisEmpty()Returns whether the map is empty.voidresize(@NotNull Size2D newSize)Resizes the map grid to a new size.
-
-
-
Method Detail
-
getMapSquare
@NotNull public @NotNull MapSquare<G,A,R> getMapSquare(int x, int y)
Returns theMapSquareat a given location.- Parameters:
x- the location's x coordinatey- the location's y coordinate- Returns:
- the map square
- Throws:
java.lang.IndexOutOfBoundsException- if the location is not within bounds
-
clearMap
public 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. An alternative implementation would manually clean every existing MapSquare but that probably wouldn't really be faster until we have reuse of GameObject instances similar to J2EE.
-
isEmpty
public boolean isEmpty()
Returns whether the map is empty.- Returns:
trueif the map is empty, orfalseif the map is not empty
-
resize
public void resize(@NotNull @NotNull Size2D newSize)Resizes the map grid to a new size.- Parameters:
newSize- the new size
-
collectHeads
public void collectHeads(int minX, int minY, int maxX, int maxY, @NotNull @NotNull java.util.Collection<GameObject<G,A,R>> objectsToDelete)Adds all head parts for game object within an area to a collection.- Parameters:
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
-
getMapSize
@NotNull public @NotNull Size2D getMapSize()
Returns the size of this map grid in map squares.- Returns:
- the size
-
-