Class CfMap
java.lang.Object
com.realtime.crossfire.jxclient.map.CfMap
Represents a map (as seen by the client). A map is a grid in which
CfMapSquares can be stored.
The map will be automatically enlarged by accesses to new squares. Not yet set squares are considered dark.
All accesses must be synchronized on the map instance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearSquare(int x, int y) Clears the content of one square.voiddirty(int x, int y) Marks a single square as dirty.intgetColor(int x, int y) Returns the magic map color value of one square.intgetDarkness(int x, int y) Returns the darkness value of one square.@NotNull Set<CfMapSquare>Returns the dirty map squares.@Nullable FacegetFace(int x, int y, int layer) Determines the face of one square.@Nullable CfMapSquaregetHeadMapSquare(int x, int y, int layer) Returns the map square of the head of a multi-square object.@NotNull CfMapSquaregetMapSquare(int x, int y) Returns a map square.@Nullable CfMapSquaregetMapSquareUnlessDirty(int x, int y) Returns a map square.intReturns the offset to convert an absolute x-coordinate of a map square (CfMapSquare.getX()to a relative x-coordinate.intReturns the offset to convert an absolute y-coordinate of a map square (CfMapSquare.getY()to a relative y-coordinate.intgetSmooth(int x, int y, int layer) Returns the smooth value of one square.booleanisFogOfWar(int x, int y) Determines if the tile is not up-to-date.booleanprocessMapScroll(int dx, int dy, int width, int height) Processes a map scroll command.voidreset(int mapWidth, int mapHeight) Clears the map contents.voidsetDarkness(int x, int y, int darkness) Sets the darkness value of one square.voidSets the face of one square.voidsetMagicMap(int x0, int y0, byte @NotNull [] @NotNull [] data) Sets the magic map color of one square.voidsetSmooth(int x, int y, int layer, int smooth) Sets the smooth value of one square.voidsquareModified(@NotNull CfMapSquare mapSquare) Marks aCfMapSquareas dirty.voidsquarePendingFace(int x, int y, int faceNum) Marks aCfMapSquareas containing a pending face.voidupdateFace(int faceNum, int width, int height) Processes an updated face image.
-
Constructor Details
-
CfMap
public CfMap()
-
-
Method Details
-
reset
public void reset(int mapWidth, int mapHeight) Clears the map contents.- Parameters:
mapWidth- the width of the visible map areamapHeight- the height of the visible map area
-
setDarkness
public void setDarkness(int x, int y, int darkness) Sets the darkness value of one square.- Parameters:
x- the x-coordinate of the squarey- the y-coordinate of the squaredarkness- the darkness value to set; 0=dark, 255=full bright
-
getDarkness
public int getDarkness(int x, int y) Returns the darkness value of one square.- Parameters:
x- the x-coordinate of the squarey- 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 void setSmooth(int x, int y, int layer, int smooth) Sets the smooth value of one square.- Parameters:
x- the x-coordinate of the squarey- the y-coordinate of the squarelayer- the layer to setsmooth- the smooth value to set
-
getSmooth
public int getSmooth(int x, int y, int layer) Returns the smooth value of one square.- Parameters:
x- the x-coordinate of the squarey- the y-coordinate of the squarelayer- the layer of the square- Returns:
- the smooth value of the square
-
setMagicMap
public void setMagicMap(int x0, int y0, byte @NotNull [] @NotNull [] data) Sets the magic map color of one square.- Parameters:
x0- the x-coordinate of the squarey0- the y-coordinate of the squaredata- the magic map data (y, x); will not be changed
-
getColor
public int getColor(int x, int y) Returns the magic map color value of one square.- Parameters:
x- the x-coordinate of the squarey- the y-coordinate of the square- Returns:
- the color
-
setFace
Sets the face of one square. This function clears fog-of-war state if necessary.- Parameters:
x- the x-coordinate of the squarey- the y-coordinate of the squarelayer- the layer to setface- the face to set; may benullto remove the face
-
getFace
Determines the face of one square.- Parameters:
x- the x-coordinate of the squarey- the y-coordinate of the squarelayer- the layer of the face- Returns:
- the face; dark (i.e. not yet set) faces return
null
-
getHeadMapSquare
Returns the map square of the head of a multi-square object.- Parameters:
x- the x-coordinate of the squarey- the y-coordinate of the squarelayer- the layer to return the head for- Returns:
- the head map square, or
nullif this square does not contain a multi-tail
-
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 squarey- the y-coordinate of the square
-
dirty
public void dirty(int x, int y) Marks a single square as dirty.- Parameters:
x- the x-coordinate of the squarey- the y-coordinate of the square
-
isFogOfWar
public boolean isFogOfWar(int x, int y) Determines if the tile is not up-to-date.- Parameters:
x- the x-coordinate of the squarey- the y-coordinate of the square- Returns:
- whether the tile contains fog-of-war data
-
getMapSquare
Returns a map square.- Parameters:
x- the x-coordinatey- the y-coordinate- Returns:
- the map square
-
getMapSquareUnlessDirty
Returns a map square.- Parameters:
x- the x-coordinatey- the y-coordinate- Returns:
- the map square or
nullif it would be dirty
-
getOffsetX
public int getOffsetX()Returns the offset to convert an absolute x-coordinate of a map square (CfMapSquare.getX()to a relative x-coordinate.- Returns:
- the x offset
-
getOffsetY
public int getOffsetY()Returns the offset to convert an absolute y-coordinate of a map square (CfMapSquare.getY()to a relative y-coordinate.- Returns:
- the y offset
-
squareModified
Marks aCfMapSquareas dirty.- Parameters:
mapSquare- the map square
-
squarePendingFace
public void squarePendingFace(int x, int y, int faceNum) Marks aCfMapSquareas containing a pending face.- Parameters:
x- the x coordinate of the map squarey- the y coordinate of the map squarefaceNum- the pending face
-
getDirtyMapSquares
Returns the dirty map squares. The result may be modified by the caller.- Returns:
- the dirty map squares
-
updateFace
public void updateFace(int faceNum, int width, int height) Processes an updated face image.- Parameters:
faceNum- the face that has changedwidth- the width of the visible map areaheight- the height of the visible map area
-
processMapScroll
public boolean processMapScroll(int dx, int dy, int width, int height) Processes a map scroll command.- Parameters:
dx- the distance to scroll in x-direction in squaresdy- the distance to scroll in y-direction in squareswidth- the width of the visible map area in map squaresheight- the height of the visible map area in map squares- Returns:
- whether scrolling did clear the whole visible map area
-