Class SavedSquares<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<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.Serializable
    Records a set of changed map squares.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void applyChanges​(@NotNull MapModel<G,​A,​R> mapModel)
      Applies the saved squares to the given map model.
      void clear()
      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.
      boolean isEmpty()
      Returns whether no saved squares exist.
      void recordMapSquare​(@NotNull MapSquare<G,​A,​R> mapSquare)
      Records a map square as changed.
      void removeEmptySquares​(@NotNull Size2D size)
      Removes empty squares outside a given area.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 use
        gameObjectMatchers - 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