 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.mapmodel;
22 import java.awt.Point;
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.List;
34 import org.jetbrains.annotations.NotNull;
35 import org.jetbrains.annotations.Nullable;
53 private final List<ArrayList<ArrayList<G>>>
savedSquares =
new ArrayList<>();
83 final int x = mapSquare.getMapX();
84 final int y = mapSquare.getMapY();
90 for (
final G content : mapSquare) {
91 if (content.isHead()) {
107 final ArrayList<ArrayList<G>> col;
112 col =
new ArrayList<>();
115 final ArrayList<ArrayList<G>> tmp =
savedSquares.get(x);
117 col =
new ArrayList<>();
124 final ArrayList<G> result;
125 if (y >= col.size()) {
126 while (col.size() < y) {
129 result =
new ArrayList<>();
132 final Collection<G> tmp = col.get(y);
137 result =
new ArrayList<>();
177 final Point point =
new Point();
179 final Collection<G> objectsToDelete =
new ArrayList<>();
183 for (
final Iterable<G> square : col) {
184 if (square !=
null) {
186 for (
final G gameObject : mapSquare) {
187 if (gameObject.isHead()) {
188 objectsToDelete.add(gameObject);
191 for (
final G gameObject : objectsToDelete) {
192 mapModel.removeGameObject(gameObject,
false);
194 objectsToDelete.clear();
195 for (
final G gameObject : square) {
196 mapSquare.addLast(gameObject);
205 final Point point2 =
new Point();
210 for (
final Iterable<G> square : col) {
211 if (square !=
null) {
213 final Point map = gameObject.getMapLocation();
214 for (G tailGameObject = gameObject.getMultiNext(); tailGameObject !=
null; tailGameObject = tailGameObject.getMultiNext()) {
215 point2.x = map.x + tailGameObject.getArchetype().getMultiX();
216 point2.y = map.y + tailGameObject.getArchetype().getMultiY();
218 mapSquare.
addLast(tailGameObject);
234 final int width = size.getWidth();
235 final int height = size.getHeight();
238 throw new IllegalArgumentException(
"area outside " + width +
"x" + height +
" is not empty");
241 for (
int x = 0; x < width && x <
savedSquares.size(); x++) {
244 for (
int y = col.size() - 1; y >= height; y--) {
249 for (
int x =
savedSquares.size() - 1; x >= width; x--) {
261 for (
int x = 0; x < width && x <
savedSquares.size(); x++) {
264 for (
int y = height; y < col.size(); y++) {
265 final Collection<G> square = col.get(y);
266 if (!square.isEmpty()) {
276 for (
final Collection<G> square : col) {
277 if (square !=
null && !square.isEmpty()) {
Abstract factory for creating GameObject instances.
final List< ArrayList< ArrayList< G > > > savedSquares
The saved squares.
Base package of all Gridarta classes.
ArrayList< G > allocateMapSquare(final int x, final int y)
Allocates a saved map square.
final GameObjectFactory< G, A, R > gameObjectFactory
The GameObjectFactory to use.
SavedSquares(@NotNull final GameObjectFactory< G, A, R > gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers)
Creates a new instance.
Reflects a game object (object on a map).
Records a set of changed map squares.
void applyChanges(@NotNull final MapModel< G, A, R > mapModel)
Applies the saved squares to the given map model.
GameObjects are the objects based on Archetypes found on maps.
void clear()
Forgets all saved squares.
void addLast(@NotNull final G gameObject)
Adds the given game object at the end of this container.
void recordMapSquare(@NotNull final MapSquare< G, A, R > mapSquare)
Records a map square as changed.
Classes related to matching {GameObjects}, so called { net.sf.gridarta.model.match....
boolean isOutsideEmpty(final int width, final int height)
Returns whether all squares outside a given area are empty or unchanged.
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing list
Interface for MapArchObjects.
Maintains GameObjectMatcher instances.
void removeEmptySquares(@NotNull final Size2D size)
Removes empty squares outside a given area.
SavedSquares< G, A, R > cloneAndClear()
Creates a new instance having the same contents as this instance, then forgets all saves squares in t...
boolean isEmpty()
Returns whether no saved squares exist.
G cloneMultiGameObject(@NotNull G gameObject)
Creates a copy of a game object, including tail parts.
Base class for classes that contain GameObjects as children in the sense of containment.
The class Size2D represents a 2d rectangular area.
abstract MapSquare< G, A, R > getMapSquare()
Returns the MapSquare this game object is part of.
final GameObjectMatchers gameObjectMatchers
The GameObjectMatchers to use.
static final long serialVersionUID
The serial version UID.