20 package net.sf.gridarta.model.mapmodel;
22 import java.awt.Point;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.List;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
80 private List<MapSquare<G, A, R>>
lightSources = Collections.emptyList();
125 return new Point(mapX, mapY);
143 public void getMapLocation(@NotNull
final Point pos,
final int dx,
final int dy) {
166 @SuppressWarnings(
"unchecked")
175 gameObject.setContainer(
this, mapX, mapY);
191 for (
final G gameObject :
reverse()) {
192 if (gameObjectMatcher.isMatching(gameObject)) {
210 for (
final G gameObject :
reverse()) {
211 if (gameObjectMatcher.isMatching(gameObject)) {
227 for (
final G gameObject :
this) {
228 if (gameObjectMatcher.isMatching(gameObject)) {
246 for (
final G gameObject :
this) {
247 if (gameObjectMatcher.isMatching(gameObject)) {
265 @Nullable G result = null;
266 for (
final G tmp :
this) {
267 if (!gameObjectMatcher.isMatching(tmp)) {
293 public boolean equals(@Nullable
final Object obj) {
294 if (obj == null || obj.getClass() != getClass()) {
299 return mapModel == mapSquare.
mapModel && mapX == mapSquare.
mapX && mapY == mapSquare.
mapY;
307 return System.identityHashCode(mapModel) + 13 * mapX + 65537 *
mapY;
336 if (this.lightRadius == lightRadius) {
353 if (lightSources.isEmpty()) {
354 lightSources =
new ArrayList<>();
359 lightSources.add(mapSquare);
372 if (!lightSources.remove(mapSquare)) {
375 if (lightSources.isEmpty()) {
376 lightSources = Collections.emptyList();
390 return !lightSources.isEmpty();
boolean equals(@Nullable final Object obj)
}
int getMapX()
Returns the x coordinate on the map.
int lightRadius
The maximum light radius of all objects within this map square.
Iterable< G > reverse()
Return an object that is the reverse representation.
final int mapY
The Y Coordinate of this map square within the model's grid.
MapSquare< G, A, R > getMapSquare()
boolean isLight()
Returns whether this map square is affected by any light emitting game objects.
Interface for classes that match GameObjects.
This package contains classes related to matching GameObjects, so called GameObjectMatchers.
void getMapLocation(@NotNull final Point pos)
Returns the coordinate on the map.
MapModel< G, A, R > getMapModel()
Returns the MapModel this map square is part of.
void addLightSource(@NotNull final MapSquare< G, A, R > mapSquare)
Adds a light emitting game object that affects this map square.
void endSquareChange(@NotNull MapSquare< G, A, R > mapSquare)
Method to notify the model that a map square was changed.
final MapModel< G, A, R > mapModel
The MaoModel this square is associated with.
static final long serialVersionUID
The serial version UID.
Base class for classes that contain GameObjects as children in the sense of containment.
MapSquare(@NotNull final MapModel< G, A, R > mapModel, final int mapX, final int mapY)
Creates a new instance.
G getAfterLast(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the game object after the last occurrence of a matching game object.
G getLastOfLeadingSpan(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the last game object of the initial segment of matching game objects.
void removeLightSource(@NotNull final MapSquare< G, A, R > mapSquare)
Removes a light emitting game object that affects this map square.
final int mapX
The X Coordinate of this map square within the model's grid.
Base package of all Gridarta classes.
int getLightRadius()
Returns the maximum light radius of all light emitting objects within this map square.
Reflects a game object (object on a map).
GameObjects are the objects based on Archetypes found on maps.
void endSquareChange()
Method to notify the model that a map square was changed.
Point getMapLocation()
Returns the coordinate on the map.
void setLightRadius(final int lightRadius)
Sets the maximum light radius of all light emitting objects within this map square.
G getFirst(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the first occurrence of a matching game object.
void beginSquareChange()
Method to notify the model that a map square is about to change.
G getBeforeFirst(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the game object before the first occurrence of a matching game object.
void beginSquareChange(@NotNull MapSquare< G, A, R > mapSquare)
Method to notify the model that a map square is about to change.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
MapSquare< G, A, R > clone()
void setThisContainer(@NotNull final G gameObject)
G getLast(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the last occurrence of a matching game object.
void getMapLocation(@NotNull final Point pos, final int dx, final int dy)
Returns the coordinate with an offset on the map.
int getMapY()
Returns the y coordinate on the map.
Interface for MapArchObjects.
List< MapSquare< G, A, R > > lightSources
The MapSquares on the map that contain light emitting game objects that affect this map square...