Class CfMapSquare
- java.lang.Object
-
- com.realtime.crossfire.jxclient.map.CfMapSquare
-
public class CfMapSquare extends java.lang.ObjectRepresents a square in aCfMap. A square comprises ofMap2.NUM_LAYERSfaces as well as a darkness value.This class assumes that the "head" part of a face is the part the server did sent. 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.
-
-
Field Summary
Fields Modifier and Type Field Description static intDARKNESS_FULL_BRIGHTThe darkness value for a full bright square.static intDEFAULT_COLORThe default magic map color for newly created squares.static intDEFAULT_DARKNESSThe default darkness value for newly created squares.static @Nullable FaceDEFAULT_FACEThe default face value for newly creates squares.static intDEFAULT_SMOOTHThe default smooth value for newly created squares.
-
Constructor Summary
Constructors Constructor Description CfMapSquare(@NotNull CfMap map, int x, int y)Creates a new (empty) square.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Marks this square as 'fog-og-war'.voiddirty()Marks this square as dirty, i.e., needing redraw.intgetColor()Returns the magic map color of this square.intgetDarkness()Returns the darkness value of this square.@Nullable FacegetFace(int layer)Returns the face of a layer.@Nullable CfMapSquaregetHeadMapSquare(int layer)Returns the map square of the head of a multi-square object.intgetSmooth(int layer)Returns the smooth value of this square.intgetX()Returns the absolute map x-coordinate of this square.intgetY()Returns the absolute map y-coordinate of this square.booleanisFogOfWar()Determines if the square is not up-to-date.booleanresetFogOfWar()Returns and resets the "fog-of-war" flag.voidsetColor(int color)Sets the magic map color of this square.booleansetDarkness(int darkness)Sets the darkness value of this square.voidsetFace(int layer, @Nullable Face face)Sets the face of a layer.voidsetHeadMapSquare(int layer, @Nullable CfMapSquare mapSquare, boolean setAlways)Sets the map square containing the head face for a layer.intsetSmooth(int layer, int smooth)Sets the smooth value of this square.@NotNull java.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT_DARKNESS
public static final int DEFAULT_DARKNESS
The default darkness value for newly created squares.- See Also:
- Constant Field Values
-
DEFAULT_SMOOTH
public static final int DEFAULT_SMOOTH
The default smooth value for newly created squares.- See Also:
- Constant Field Values
-
DEFAULT_COLOR
public static final int DEFAULT_COLOR
The default magic map color for newly created squares.- See Also:
- Constant Field Values
-
DARKNESS_FULL_BRIGHT
public static final int DARKNESS_FULL_BRIGHT
The darkness value for a full bright square.- See Also:
- Constant Field Values
-
DEFAULT_FACE
@Nullable public static final @Nullable Face DEFAULT_FACE
The default face value for newly creates squares.
-
-
Constructor Detail
-
CfMapSquare
public CfMapSquare(@NotNull @NotNull CfMap map, int x, int y)Creates a new (empty) square.- Parameters:
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 patch
-
-
Method Detail
-
getX
public int getX()
Returns the absolute map x-coordinate of this square.- Returns:
- the x-coordinate
-
getY
public int getY()
Returns the absolute map y-coordinate of this square.- Returns:
- the y-coordinate
-
dirty
public void dirty()
Marks this square as dirty, i.e., needing redraw.
-
clear
public void clear()
Marks this square as 'fog-og-war'. The values will be still returned until a new value will be set.
-
setDarkness
public boolean setDarkness(int darkness)
Sets the darkness value of this square.- Parameters:
darkness- the new darkness value between0and255; 0=dark, 255=full bright- Returns:
- whether fog-of-war has been cleared
-
getDarkness
public int getDarkness()
Returns the darkness value of this square.- Returns:
- the darkness value of the square; 0=dark, 255=full bright
-
setSmooth
public int setSmooth(int layer, int smooth)Sets the smooth value of this square.- Parameters:
layer- the layer between0andLAYERS-1smooth- the new smooth value- Returns:
- whether fog-of-war has been cleared (1) or whether the smooth value has changed (2)
-
getSmooth
public int getSmooth(int layer)
Returns the smooth value of this square.- Parameters:
layer- the layer between0andLAYERS-1- Returns:
- the smooth value of the square
-
setColor
public void setColor(int color)
Sets the magic map color of this square.- Parameters:
color- the new color
-
getColor
public int getColor()
Returns the magic map color of this square.- Returns:
- the color
-
setFace
public void setFace(int layer, @Nullable @Nullable Face face)Sets the face of a layer.- Parameters:
layer- the layer for the new face between0andLAYERS-1face- the face to set
-
getFace
@Nullable public @Nullable Face getFace(int layer)
Returns the face of a layer.- Parameters:
layer- the layer to return the face- Returns:
- the face value
-
setHeadMapSquare
public void setHeadMapSquare(int layer, @Nullable @Nullable CfMapSquare mapSquare, boolean setAlways)Sets the map square containing the head face for a layer.- Parameters:
layer- the layer for the new head face between0andLAYERS-1mapSquare- the map square containing the head face; may benullsetAlways- if set, always update the face; if unset, only update when fog-of-war
-
getHeadMapSquare
@Nullable public @Nullable CfMapSquare getHeadMapSquare(int layer)
Returns the map square of the head of a multi-square object.- Parameters:
layer- the layer to return the head for- Returns:
- the head map square, or
nullif this square does not contain a multi-tail
-
isFogOfWar
public boolean isFogOfWar()
Determines if the square is not up-to-date.- Returns:
- whether this square contains fog-of-war data
-
resetFogOfWar
public boolean resetFogOfWar()
Returns and resets the "fog-of-war" flag.- Returns:
- whether this square's fog-of-war state has been reset
-
toString
@NotNull public @NotNull java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-