Gridarta Editor
net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R > Class Template Reference

A rectangular grid of MapSquare instances. More...

+ Inheritance diagram for net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
+ Collaboration diagram for net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:

Public Member Functions

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. More...
 
void collectHeads (final int minX, final int minY, final int maxX, final int maxY, @NotNull final Collection< GameObject< G, A, R >> objectsToDelete)
 Adds all head parts for game object within an area to a collection. More...
 
Size2D getMapSize ()
 Returns the size of this map grid in map squares. More...
 
MapSquare< G, A, R > getMapSquare (final int x, final int y)
 Returns the MapSquare at a given location. More...
 
boolean isEmpty ()
 Returns whether the map is empty. More...
 
 MapSquareGrid (@NotNull final MapModel< G, A, R > mapModel, @NotNull final Size2D mapSize)
 Creates a new instance. More...
 
void resize (@NotNull final Size2D newSize)
 Resizes the map grid to a new size. More...
 

Private Member Functions

List< List< MapSquare< G, A, R > > > newMapGrid (@NotNull final Size2D mapSize)
 Allocates a new 2-dimensional MapSquare array of the given size. More...
 

Private Attributes

List< List< MapSquare< G, A, R > > > mapGrid
 The MapSquare of this grid. More...
 
final MapModel< G, A, R > mapModel
 The associated MapModel. More...
 
Size2D mapSize
 The size of mapGrid. More...
 

Static Private Attributes

static final long serialVersionUID = 1L
 The serial version UID. More...
 

Detailed Description

A rectangular grid of MapSquare instances.

Author
Andreas Kirschbaum

Definition at line 36 of file MapSquareGrid.java.

Constructor & Destructor Documentation

◆ MapSquareGrid()

net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.MapSquareGrid ( @NotNull final MapModel< G, A, R >  mapModel,
@NotNull final Size2D  mapSize 
)

Creates a new instance.

Parameters
mapModelthe associated map model
mapSizethe map size

Definition at line 69 of file MapSquareGrid.java.

Member Function Documentation

◆ clearMap()

void net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.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.

Definition at line 119 of file MapSquareGrid.java.

Referenced by net.sf.gridarta.model.mapmodel.DefaultMapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.clearMap().

+ Here is the caller graph for this function:

◆ collectHeads()

void net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.collectHeads ( final int  minX,
final int  minY,
final int  maxX,
final int  maxY,
@NotNull final Collection< GameObject< G, A, R >>  objectsToDelete 
)

Adds all head parts for game object within an area to a collection.

Parameters
minXthe x coordinate of the left border of the area
minYthe y coordinate of the top border of the area
maxXthe x coordinate of the right border of the area
maxYthe y coordinate of the bottom border of the area
objectsToDeletethe collection where the heads are added to

Definition at line 184 of file MapSquareGrid.java.

Referenced by net.sf.gridarta.model.mapmodel.DefaultMapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.resizeMapInt().

+ Here is the caller graph for this function:

◆ getMapSize()

Size2D net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getMapSize ( )

Returns the size of this map grid in map squares.

Returns
the size

Definition at line 199 of file MapSquareGrid.java.

Referenced by net.sf.gridarta.model.mapmodel.DefaultMapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.resizeMapInt().

+ Here is the caller graph for this function:

◆ getMapSquare()

◆ isEmpty()

boolean net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isEmpty ( )

Returns whether the map is empty.

Returns
true
if the map is empty, or
false
if the map is not empty

Definition at line 142 of file MapSquareGrid.java.

Referenced by net.sf.gridarta.model.mapmodel.DefaultMapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isEmpty().

+ Here is the caller graph for this function:

◆ newMapGrid()

List<List<MapSquare<G, A, R> > > net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.newMapGrid ( @NotNull final Size2D  mapSize)
private

Allocates a new 2-dimensional MapSquare array of the given size.

Parameters
mapSizethe size
Returns
the array

Definition at line 86 of file MapSquareGrid.java.

Referenced by net.sf.gridarta.model.mapmodel.MapSquareGrid< G, A, R >.MapSquareGrid(), and net.sf.gridarta.model.mapmodel.MapSquareGrid< G, A, R >.resize().

+ Here is the caller graph for this function:

◆ resize()

void net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.resize ( @NotNull final Size2D  newSize)

Resizes the map grid to a new size.

Parameters
newSizethe new size

Definition at line 157 of file MapSquareGrid.java.

Referenced by net.sf.gridarta.model.mapmodel.DefaultMapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.resizeMapInt().

+ Here is the caller graph for this function:

Member Data Documentation

◆ mapGrid

List<List<MapSquare<G, A, R> > > net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapGrid
private

The MapSquare of this grid.

Definition at line 62 of file MapSquareGrid.java.

◆ mapModel

final MapModel<G, A, R> net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapModel
private

◆ mapSize

◆ serialVersionUID

final long net.sf.gridarta.model.mapmodel.MapSquareGrid< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.serialVersionUID = 1L
staticprivate

The serial version UID.

Definition at line 41 of file MapSquareGrid.java.


The documentation for this class was generated from the following file: