public class MapSquare<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends GameObjectContainer<G,A,R>
The objects are stored bottom to top: GameObjectContainer.getFirst()
returns the object
at the bottom, GameObjectContainer.getLast()
returns the object at the top of the
square.
Constructor and Description |
---|
MapSquare(@NotNull MapModel<G,A,R> mapModel,
int mapX,
int mapY)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addLightSource(@NotNull MapSquare<G,A,R> mapSquare)
Adds a light emitting game object that affects this map square.
|
G |
asGameObject()
Returns this instance as a
GameObject or null if this
instance is not a game object. |
void |
beginSquareChange()
Method to notify the model that a map square is about to change.
|
protected @NotNull MapSquare<G,A,R> |
clone() |
void |
endSquareChange()
Method to notify the model that a map square was changed.
|
boolean |
equals(@Nullable java.lang.Object obj)
}
|
G |
getAfterLast(@NotNull GameObjectMatcher gameObjectMatcher)
Returns the game object after the last occurrence of a matching game
object.
|
G |
getBeforeFirst(@NotNull GameObjectMatcher gameObjectMatcher)
Returns the game object before the first occurrence of a matching game
object.
|
G |
getFirst(@NotNull GameObjectMatcher gameObjectMatcher)
Returns the first occurrence of a matching game object.
|
G |
getLast(@NotNull GameObjectMatcher gameObjectMatcher)
Returns the last occurrence of a matching game object.
|
G |
getLastOfLeadingSpan(@NotNull GameObjectMatcher gameObjectMatcher)
Returns the last game object of the initial segment of matching game
objects.
|
int |
getLightRadius()
Returns the maximum light radius of all light emitting objects within
this map square.
|
@NotNull java.awt.Point |
getMapLocation()
Returns the coordinate on the map.
|
void |
getMapLocation(@NotNull java.awt.Point pos)
Returns the coordinate on the map.
|
void |
getMapLocation(@NotNull java.awt.Point pos,
int dx,
int dy)
Returns the coordinate with an offset on the map.
|
@NotNull MapModel<G,A,R> |
getMapModel()
Returns the
MapModel this map square is part of. |
@NotNull MapSquare<G,A,R> |
getMapSquare()
Returns the
MapSquare this game object is part of. |
@NotNull MapSquare<G,A,R> |
getMapSquareOptional()
Returns the
MapSquare this game object is part of. |
int |
getMapX()
Returns the x coordinate on the map.
|
int |
getMapY()
Returns the y coordinate on the map.
|
int |
hashCode()
}
|
boolean |
isLight()
Returns whether this map square is affected by any light emitting game
objects.
|
protected void |
notifyBeginChange()
Notifies the map model that this container is about to change.
|
protected void |
notifyEndChange()
Notifies the map model that this container has changed.
|
void |
removeLightSource(@NotNull MapSquare<G,A,R> mapSquare)
Removes a light emitting game object that affects this map square.
|
void |
setLightRadius(int lightRadius)
Sets the maximum light radius of all light emitting objects within this
map square.
|
protected void |
setThisContainer(G gameObject)
Sets a
GameObject 's container to this container. |
@NotNull java.lang.String |
toString()
}
|
addFirst, addLast, getFirst, getLast, getNext, getPrev, hasSameContents, insertAfter, insertBefore, isBottom, isEmpty, isTop, iterator, moveBottom, moveDown, moveTop, moveUp, recursive, remove, removeAll, replace, reverse
public MapSquare(@NotNull @NotNull MapModel<G,A,R> mapModel, int mapX, int mapY)
mapModel
- the map model this map square is part ofmapX
- the x coordinate of this map square within the model's gridmapY
- the y coordinate of this map square within the model's grid@NotNull public @NotNull MapModel<G,A,R> getMapModel()
MapModel
this map square is part of.public int getMapX()
public int getMapY()
@NotNull public @NotNull java.awt.Point getMapLocation()
public void getMapLocation(@NotNull @NotNull java.awt.Point pos)
pos
- returns the coordinate on the mappublic void getMapLocation(@NotNull @NotNull java.awt.Point pos, int dx, int dy)
pos
- returns the coordinate on the mapdx
- the x offset to add to the coordinatedy
- the y offset to add to the coordinate@NotNull public @NotNull MapSquare<G,A,R> getMapSquare()
GameObjectContainer
MapSquare
this game object is part of.getMapSquare
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
@NotNull public @NotNull MapSquare<G,A,R> getMapSquareOptional()
GameObjectContainer
MapSquare
this game object is part of.getMapSquareOptional
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
if the game object is not part of
a mapprotected void notifyBeginChange()
GameObjectContainer
notifyBeginChange
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
protected void notifyEndChange()
GameObjectContainer
notifyEndChange
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
@NotNull protected @NotNull MapSquare<G,A,R> clone()
clone
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
protected void setThisContainer(@NotNull G gameObject)
GameObjectContainer
GameObject
's container to this container.setThisContainer
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
gameObject
- the game object@Nullable public G asGameObject()
GameObjectContainer
GameObject
or null
if this
instance is not a game object.asGameObject
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
@Nullable public G getLast(@NotNull @NotNull GameObjectMatcher gameObjectMatcher)
gameObjectMatcher
- the matcher to usenull
if no such game object exists@Nullable public G getAfterLast(@NotNull @NotNull GameObjectMatcher gameObjectMatcher)
gameObjectMatcher
- the matcher to usenull
if no such
game object exists@Nullable public G getFirst(@NotNull @NotNull GameObjectMatcher gameObjectMatcher)
gameObjectMatcher
- the matcher to usenull
if no such game object exists@Nullable public G getBeforeFirst(@NotNull @NotNull GameObjectMatcher gameObjectMatcher)
gameObjectMatcher
- the matcher to usenull
if no
such game object exists@Nullable public G getLastOfLeadingSpan(@NotNull @NotNull GameObjectMatcher gameObjectMatcher)
gameObjectMatcher
- the matcher to usenull
if the first game object does not
match gameObjectMatcher
public void beginSquareChange()
public void endSquareChange()
public boolean equals(@Nullable @Nullable java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
@NotNull public @NotNull java.lang.String toString()
toString
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public int getLightRadius()
0
if no light emitting objects are
presentpublic void setLightRadius(int lightRadius)
lightRadius
- the light radius or 0
if no light emitting
objects are presentpublic void addLightSource(@NotNull @NotNull MapSquare<G,A,R> mapSquare)
mapSquare
- the map square that contains the game objectpublic void removeLightSource(@NotNull @NotNull MapSquare<G,A,R> mapSquare)
mapSquare
- the map square that contains the game objectpublic boolean isLight()