Package net.sf.gridarta.model.mapmodel
Class SavedSquares<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.mapmodel.SavedSquares<G,A,R>
-
- All Implemented Interfaces:
java.io.Serializable
public class SavedSquares<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements java.io.SerializableRecords a set of changed map squares.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SavedSquares(@NotNull GameObjectFactory<G,A,R> gameObjectFactory, @NotNull GameObjectMatchers gameObjectMatchers)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyChanges(@NotNull MapModel<G,A,R> mapModel)Applies the saved squares to the given map model.voidclear()Forgets all saved squares.@NotNull SavedSquares<G,A,R>cloneAndClear()Creates a new instance having the same contents as this instance, then forgets all saves squares in this instance.booleanisEmpty()Returns whether no saved squares exist.voidrecordMapSquare(@NotNull MapSquare<G,A,R> mapSquare)Records a map square as changed.voidremoveEmptySquares(@NotNull Size2D size)Removes empty squares outside a given area.
-
-
-
Constructor Detail
-
SavedSquares
public SavedSquares(@NotNull @NotNull GameObjectFactory<G,A,R> gameObjectFactory, @NotNull @NotNull GameObjectMatchers gameObjectMatchers)Creates a new instance.- Parameters:
gameObjectFactory- the game object factory to usegameObjectMatchers- the game object matchers to use
-
-
Method Detail
-
recordMapSquare
public void recordMapSquare(@NotNull @NotNull MapSquare<G,A,R> mapSquare)Records a map square as changed. Does nothing if the square already has been saved.- Parameters:
mapSquare- the map square to save
-
isEmpty
public boolean isEmpty()
Returns whether no saved squares exist.- Returns:
- whether no saved squares exist
-
clear
public void clear()
Forgets all saved squares.
-
cloneAndClear
@NotNull public @NotNull SavedSquares<G,A,R> cloneAndClear()
Creates a new instance having the same contents as this instance, then forgets all saves squares in this instance.- Returns:
- the new instance
-
applyChanges
public void applyChanges(@NotNull @NotNull MapModel<G,A,R> mapModel)Applies the saved squares to the given map model.- Parameters:
mapModel- the map model to change
-
removeEmptySquares
public void removeEmptySquares(@NotNull @NotNull Size2D size)Removes empty squares outside a given area.- Parameters:
size- the area
-
-