public class CfMapSquare
extends java.lang.Object
CfMap
. A square comprises of
Map2.NUM_LAYERS
faces as well as a darkness value.
This class assumes that the "head" part of a face is the part the server did send. This is the bottom-right part for multi-square objects. Not that this definition is inconsistent to what the server assumes as the head part of an object.
Modifier and Type | Field and Description |
---|---|
static int |
DARKNESS_FULL_BRIGHT
The darkness value for a full bright square.
|
static int |
DEFAULT_COLOR
The default magic map color for newly created squares.
|
static int |
DEFAULT_DARKNESS
The default darkness value for newly created squares.
|
static @Nullable Face |
DEFAULT_FACE
The default face value for newly creates squares.
|
static int |
DEFAULT_SMOOTH
The default smooth value for newly created squares.
|
Constructor and Description |
---|
CfMapSquare(@NotNull CfMap map,
int x,
int y)
Creates a new (empty) square.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Marks this square as 'fog-og-war'.
|
void |
dirty()
Marks this square as dirty, i.e., needing redraw.
|
int |
getColor()
Returns the magic map color of this square.
|
int |
getDarkness()
Returns the darkness value of this square.
|
@Nullable Face |
getFace(int layer)
Returns the face of a layer.
|
@Nullable CfMapSquare |
getHeadMapSquare(int layer)
Returns the map square of the head of a multi-square object.
|
int |
getSmooth(int layer)
Returns the smooth value of this square.
|
int |
getX()
Returns the absolute map x-coordinate of this square.
|
int |
getY()
Returns the absolute map y-coordinate of this square.
|
boolean |
isFogOfWar()
Determines if the square is not up-to-date.
|
boolean |
resetFogOfWar()
Returns and resets the "fog-of-war" flag.
|
void |
setColor(int color)
Sets the magic map color of this square.
|
boolean |
setDarkness(int darkness)
Sets the darkness value of this square.
|
void |
setFace(int layer,
@Nullable Face face)
Sets the face of a layer.
|
void |
setHeadMapSquare(int layer,
@Nullable CfMapSquare mapSquare,
boolean setAlways)
Sets the map square containing the head face for a layer.
|
int |
setSmooth(int layer,
int smooth)
Sets the smooth value of this square.
|
@NotNull java.lang.String |
toString() |
public static final int DEFAULT_DARKNESS
public static final int DEFAULT_SMOOTH
public static final int DEFAULT_COLOR
public static final int DARKNESS_FULL_BRIGHT
@Nullable public static final @Nullable Face DEFAULT_FACE
public CfMapSquare(@NotNull @NotNull CfMap map, int x, int y)
map
- the map this map square is part ofx
- the absolute map x-coordinate of the top left corner of this
patchy
- the absolute map y-coordinate of the top left corner of this
patchpublic int getX()
public int getY()
public void dirty()
public void clear()
public boolean setDarkness(int darkness)
darkness
- the new darkness value between 0
and 255
;
0=dark, 255=full brightpublic int getDarkness()
public int setSmooth(int layer, int smooth)
layer
- the layer between 0
and LAYERS-1
smooth
- the new smooth valuepublic int getSmooth(int layer)
layer
- the layer between 0
and LAYERS-1
public void setColor(int color)
color
- the new colorpublic int getColor()
public void setFace(int layer, @Nullable @Nullable Face face)
layer
- the layer for the new face between 0
and
LAYERS-1
face
- the face to set@Nullable public @Nullable Face getFace(int layer)
layer
- the layer to return the facepublic void setHeadMapSquare(int layer, @Nullable @Nullable CfMapSquare mapSquare, boolean setAlways)
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@Nullable public @Nullable CfMapSquare getHeadMapSquare(int layer)
layer
- the layer to return the head fornull
if this square does not
contain a multi-tailpublic boolean isFogOfWar()
public boolean resetFogOfWar()
@NotNull public @NotNull java.lang.String toString()
toString
in class java.lang.Object