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(MapModel<G,A,R> mapModel,
int mapX,
int mapY)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addLightSource(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 MapSquare<G,A,R> |
clone() |
void |
endSquareChange()
Method to notify the model that a map square was changed.
|
boolean |
equals(java.lang.Object obj)
}
|
G |
getAfterLast(GameObjectMatcher gameObjectMatcher)
Returns the game object after the last occurrence of a matching game
object.
|
G |
getBeforeFirst(GameObjectMatcher gameObjectMatcher)
Returns the game object before the first occurrence of a matching game
object.
|
G |
getFirst(GameObjectMatcher gameObjectMatcher)
Returns the first occurrence of a matching game object.
|
G |
getLast(GameObjectMatcher gameObjectMatcher)
Returns the last occurrence of a matching game object.
|
G |
getLastOfLeadingSpan(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.
|
java.awt.Point |
getMapLocation()
Returns the coordinate on the map.
|
void |
getMapLocation(java.awt.Point pos)
Returns the coordinate on the map.
|
void |
getMapLocation(java.awt.Point pos,
int dx,
int dy)
Returns the coordinate with an offset on the map.
|
MapModel<G,A,R> |
getMapModel()
Returns the
MapModel this map square is part of. |
MapSquare<G,A,R> |
getMapSquare()
Returns the
MapSquare of this container. |
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()
Notify the map model that this container is about to change.
|
protected void |
notifyEndChange()
Notify the map model that this container has changed.
|
void |
removeLightSource(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. |
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 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 MapModel<G,A,R> getMapModel()
MapModel
this map square is part of.public int getMapX()
public int getMapY()
@NotNull public java.awt.Point getMapLocation()
public void getMapLocation(@NotNull java.awt.Point pos)
pos
- returns the coordinate on the mappublic void getMapLocation(@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 MapSquare<G,A,R> getMapSquare()
MapSquare
of this container.getMapSquare
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
if this
GameObjectContainer is not (yet?) connected to a map (a MapSquare
would return itself)protected void notifyBeginChange()
notifyBeginChange
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
protected void notifyEndChange()
notifyEndChange
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
@NotNull protected 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)
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()
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 GameObjectMatcher gameObjectMatcher)
gameObjectMatcher
- the matcher to usenull
if no such game object exists@Nullable public G getAfterLast(@NotNull GameObjectMatcher gameObjectMatcher)
gameObjectMatcher
- the matcher to usenull
if no such
game object exists@Nullable public G getFirst(@NotNull GameObjectMatcher gameObjectMatcher)
gameObjectMatcher
- the matcher to usenull
if no such game object exists@Nullable public G getBeforeFirst(@NotNull GameObjectMatcher gameObjectMatcher)
gameObjectMatcher
- the matcher to usenull
if no
such game object exists@Nullable public G getLastOfLeadingSpan(@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 java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
@NotNull public 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 MapSquare<G,A,R> mapSquare)
mapSquare
- the map square that contains the game objectpublic void removeLightSource(@NotNull MapSquare<G,A,R> mapSquare)
mapSquare
- the map square that contains the game objectpublic boolean isLight()