com.realtime.crossfire.jxclient.map
Class CfMapPatch

java.lang.Object
  extended by com.realtime.crossfire.jxclient.map.CfMapPatch

public class CfMapPatch
extends java.lang.Object

Represents a square area of CfMapSquares.


Field Summary
static int SIZE
          Size of patches in x- and y-direction.
static int SIZE_LOG
          Log2 of SIZE.
private  CfMapSquare[][] square
          The array of CfMapSquares.
 
Constructor Summary
CfMapPatch(CfMap map, int x0, int y0)
          Creates a new (empty) patch.
 
Method Summary
 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.
 Face getFace(int x, int y, int layer)
          Determines the face of one square.
 CfMapSquare getHeadMapSquare(int x, int y, int layer)
          Returns the map square of the head of a multi-square object.
 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.
 boolean 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, CfMapSquare mapSquare, boolean setAlways)
          Sets the map square containing the head face for a layer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE

public static final int SIZE
Size of patches in x- and y-direction.

See Also:
Constant Field Values

SIZE_LOG

public static final int SIZE_LOG
Log2 of SIZE.

See Also:
Constant Field Values

square

@NotNull
private final CfMapSquare[][] square
The array of CfMapSquares. Elements are never null.

Constructor Detail

CfMapPatch

public CfMapPatch(@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

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

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

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

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

getFace

@Nullable
public 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

getHeadMapSquare

@Nullable
public 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

getSquare

@NotNull
public 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

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

setColor

public boolean 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
Returns:
whether fog-of-war has been cleared

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

setHeadMapSquare

public void setHeadMapSquare(int x,
                             int y,
                             int layer,
                             @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