Class CfMapPatch


  • public class CfMapPatch
    extends java.lang.Object
    Represents a square area of CfMapSquares.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int SIZE
      Size of patches in x- and y-direction.
      static int SIZE_LOG
      Log2 of SIZE.
    • Constructor Summary

      Constructors 
      Constructor Description
      CfMapPatch​(@NotNull CfMap map, int x0, int y0)
      Creates a new (empty) patch.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearSquare​(int x, int y)
      Clears the content of one square.
      void dirty​(int x, int y)
      Marks a square as dirty.
      int getColor​(int x, int y)
      Determines the magic map color value of one square.
      int getDarkness​(int x, int y)
      Determines the darkness value of one square.
      @Nullable Face getFace​(int x, int y, int layer)
      Determines the face of one square.
      @Nullable CfMapSquare getHeadMapSquare​(int x, int y, int layer)
      Returns the map square of the head of a multi-square object.
      int getSmooth​(int x, int y, int layer)
      Determines the smooth value of one square.
      @NotNull CfMapSquare getSquare​(int x, int y)
      Returns one map square.
      boolean isFogOfWar​(int x, int y)
      Determines if a square is not up-to-date.
      boolean resetFogOfWar​(int x, int y)
      Returns and reset the "fog-of-war" flag of a square.
      void setColor​(int x, int y, int color)
      Sets the magic map color of one square.
      boolean setDarkness​(int x, int y, int darkness)
      Sets the darkness value of one square.
      void setHeadMapSquare​(int x, int y, int layer, @Nullable CfMapSquare mapSquare, boolean setAlways)
      Sets the map square containing the head face for a layer.
      int setSmooth​(int x, int y, int layer, int smooth)
      Sets the smooth value of one square.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CfMapPatch

        public CfMapPatch​(@NotNull
                          @NotNull CfMap map,
                          int x0,
                          int y0)
        Creates a new (empty) patch.
        Parameters:
        map - the map this map patch is part of
        x0 - the absolute map x-coordinate of the top left corner of this patch
        y0 - the absolute map y-coordinate of the top left corner of this patch
    • Method Detail

      • dirty

        public void dirty​(int x,
                          int y)
        Marks a square as dirty.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
      • clearSquare

        public void clearSquare​(int x,
                                int y)
        Clears the content of one square. Note: the old square content remains available until at least one value will be changed ("fog of war").
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
      • setDarkness

        public boolean setDarkness​(int x,
                                   int y,
                                   int darkness)
        Sets the darkness value of one square.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        darkness - the darkness value to set; 0=dark, 255=full bright
        Returns:
        whether fog-of-war has been cleared
      • getDarkness

        public int getDarkness​(int x,
                               int y)
        Determines the darkness value of one square.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        Returns:
        the darkness value of the square; 0=dark, 255=full bright; not yet set faces return 0
      • setSmooth

        public int setSmooth​(int x,
                             int y,
                             int layer,
                             int smooth)
        Sets the smooth value of one square.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        layer - the layer to set
        smooth - the smooth value to set
        Returns:
        whether fog-of-war has been cleared (1) or whether the smooth value has changed (2)
      • getSmooth

        public int getSmooth​(int x,
                             int y,
                             int layer)
        Determines the smooth value of one square.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        layer - the layer of the square
        Returns:
        the smooth value of the square
      • setColor

        public void setColor​(int x,
                             int y,
                             int color)
        Sets the magic map color of one square.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        color - the color to set
      • getColor

        public int getColor​(int x,
                            int y)
        Determines the magic map color value of one square.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        Returns:
        the color
      • getFace

        @Nullable
        public @Nullable Face getFace​(int x,
                                      int y,
                                      int layer)
        Determines the face of one square.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        layer - the layer of the face
        Returns:
        the face; dark (i.e. not yet set) faces return null
      • setHeadMapSquare

        public void setHeadMapSquare​(int x,
                                     int y,
                                     int layer,
                                     @Nullable
                                     @Nullable CfMapSquare mapSquare,
                                     boolean setAlways)
        Sets the map square containing the head face for a layer.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        layer - the layer for the new head face between 0 and LAYERS-1
        mapSquare - the map square containing the head face; may be null
        setAlways - if set, always update the face; if unset, only update when fog-of-war
      • getHeadMapSquare

        @Nullable
        public @Nullable CfMapSquare getHeadMapSquare​(int x,
                                                      int y,
                                                      int layer)
        Returns the map square of the head of a multi-square object.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        layer - the layer to return the head for
        Returns:
        the head map square, or null if this square does not contain a multi-tail
      • isFogOfWar

        public boolean isFogOfWar​(int x,
                                  int y)
        Determines if a square is not up-to-date.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        Returns:
        whether the square is up-to-date
      • resetFogOfWar

        public boolean resetFogOfWar​(int x,
                                     int y)
        Returns and reset the "fog-of-war" flag of a square.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        Returns:
        whether this square's fog-of-war state has been reset
      • getSquare

        @NotNull
        public @NotNull CfMapSquare getSquare​(int x,
                                              int y)
        Returns one map square.
        Parameters:
        x - the x-coordinate of the square
        y - the y-coordinate of the square
        Returns:
        the map square