java.lang.Object com.realtime.crossfire.jxclient.map.CfMapSquare
public class CfMapSquare
Represents a square in a CfMap
. A square comprises of Map2.NUM_LAYERS
faces as well as a darkness value.
Field Summary | |
---|---|
private int |
color
The magic map color of the square. |
private int |
darkness
The darkness value of the square in the range [0..255]. |
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 Face |
DEFAULT_FACE
The default face value for newly creates squares. |
private Face[] |
faces
The faces (of head-parts) of all layers as sent by the server. |
private boolean |
fogOfWar
Flag used to defer clearing the values: when a CfMapSquare
is cleared, the old values remain valid until at least one field is
re-set. |
private CfMapSquare[] |
heads
If this square contains a non-head part of a multi-square object this points to the head square. |
private CfMap |
map
The CfMap this map square is part of. |
private int |
x
The absolute x-coordinate of this square in its CfMap . |
private int |
y
The absolute y-coordinate of this square in its CfMap . |
Constructor Summary | |
---|---|
CfMapSquare(CfMap map,
int x,
int y)
Creates a new (empty) square. |
Method Summary | |
---|---|
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. |
Face |
getFace(int layer)
Returns the face of a layer. |
CfMapSquare |
getHeadMapSquare(int layer)
Returns the map square of the head of a multi-square object. |
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. |
boolean |
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,
Face face)
Sets the face of a layer. |
void |
setHeadMapSquare(int layer,
CfMapSquare mapSquare,
boolean setAlways)
Sets the map square containing the head face for a layer. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int color
DEFAULT_COLOR
if none
is known.
private int darkness
DARKNESS_FULL_BRIGHT
.
public static final int DARKNESS_FULL_BRIGHT
public static final int DEFAULT_COLOR
public static final int DEFAULT_DARKNESS
@Nullable public static final Face DEFAULT_FACE
@NotNull private final Face[] faces
private boolean fogOfWar
CfMapSquare
is cleared, the old values remain valid until at least one field is
re-set.
@NotNull private final CfMapSquare[] heads
@NotNull private final CfMap map
CfMap
this map square is part of.
private final int x
CfMap
.
private final int y
CfMap
.
Constructor Detail |
---|
public CfMapSquare(@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
patchMethod Detail |
---|
public void clear()
public void dirty()
public int getColor()
public int getDarkness()
@Nullable public Face getFace(int layer)
layer
- the layer to return the face
@Nullable public CfMapSquare getHeadMapSquare(int layer)
layer
- the layer to return the head for
null
if this square does not
contain a multi-tailpublic int getX()
public int getY()
public boolean isFogOfWar()
public boolean resetFogOfWar()
public boolean setColor(int color)
color
- the new color
public boolean setDarkness(int darkness)
darkness
- the new darkness value between 0
and
255
; 0=dark, 255=full bright
public void setFace(int layer, @Nullable Face face)
layer
- the layer for the new face between 0
and
LAYERS-1
face
- the face to setpublic void setHeadMapSquare(int layer, @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@NotNull public java.lang.String toString()
toString
in class java.lang.Object