public class MapUpdaterState extends java.lang.Object implements CrossfireTickListener, CrossfireUpdateMapListener, FacesManagerListener
CfMap
model from protocol commands.
The map updater is called from two threads: the
ClientSocket
reading
commands received from the Crossfire server, and
FileCacheFaceQueue
reading
faces from the (file) cache. Synchronization is by sync
and applies
to the whole map model map
.
Constructor and Description |
---|
MapUpdaterState(@NotNull FacesManager facesManager,
@NotNull Animations animations,
@NotNull CfAnimations cfAnimations)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addCrossfireMapListener(@NotNull MapListener listener)
Adds a listener to notify about changed map squares.
|
void |
addCrossfireMapScrollListener(@NotNull MapScrollListener listener)
Adds a listener to notify about scrolled maps.
|
void |
addCrossfireNewmapListener(@NotNull NewmapListener listener)
Adds a listener to notify about cleared maps.
|
void |
addMapSizeListener(@NotNull MapSizeListener listener)
Adds a listener to be notified about map size changes.
|
void |
faceUpdated(@NotNull Face face)
Called when a
Face has been updated. |
@NotNull CfMap |
getMap()
Returns the current map instance.
|
int |
getMapHeight()
Returns the height of the visible map area.
|
int |
getMapWidth()
Returns the width of the visible map area.
|
void |
magicMap(int x,
int y,
byte[][] data)
Part of "magicmap" parsing: set the magic map color.
|
void |
mapAnimation(@NotNull Location location,
int animationNum,
int animationType)
Part of "map2" parsing: set the animation of a cell.
|
void |
mapAnimationSpeed(@NotNull Location location,
int animationSpeed)
Part of "map2" parsing: set the animation speed.
|
@NotNull java.lang.Object |
mapBegin()
Parsing of a "map2" command has been started.
|
void |
mapClear(int x,
int y)
Part of "map2" parsing: clear a cell.
|
void |
mapDarkness(int x,
int y,
int darkness)
Part of "map2" parsing: change the darkness of a cell.
|
void |
mapEnd()
Parsing of "map2" has been finished.
|
void |
mapEnd(boolean alwaysProcess)
Finishes processing of a set of map square changes.
|
void |
mapFace(@NotNull Location location,
int faceNum)
Part of "map2" parsing: set the face of a cell.
|
void |
mapFace(@NotNull Location location,
int faceNum,
boolean clearAnimation)
Updates a map square by changing a face.
|
void |
mapScroll(int dx,
int dy)
Part of "map2" parsing: scroll the map view.
|
void |
mapSmooth(@NotNull Location location,
int smooth)
Part of "map2" parsing: set the smooth level.
|
void |
newMap(int mapWidth,
int mapHeight)
A "newmap" command has been received.
|
void |
removeCrossfireMapListener(@NotNull MapListener listener)
Removes a listener to notify about changed map squares.
|
void |
removeCrossfireMapScrollListener(@NotNull MapScrollListener listener)
Removes a listener to notify about scrolled maps.
|
void |
removeCrossfireNewmapListener(@NotNull NewmapListener listener)
Removes a listener to notify about cleared maps.
|
void |
removeMapSizeListener(@NotNull MapSizeListener listener)
Removes a listener to be notified about map size changes.
|
void |
reset()
Resets the animation state.
|
void |
tick(int tickNo)
A "tick" command has been received.
|
public MapUpdaterState(@NotNull @NotNull FacesManager facesManager, @NotNull @NotNull Animations animations, @NotNull @NotNull CfAnimations cfAnimations)
facesManager
- the faces manager to track for updated facesanimations
- the known animationscfAnimations
- the animations manager to usepublic void addCrossfireMapListener(@NotNull @NotNull MapListener listener)
listener
- the listener to addpublic void removeCrossfireMapListener(@NotNull @NotNull MapListener listener)
listener
- the listener to removepublic void addCrossfireNewmapListener(@NotNull @NotNull NewmapListener listener)
listener
- the listener to addpublic void removeCrossfireNewmapListener(@NotNull @NotNull NewmapListener listener)
listener
- the listener to removepublic void addCrossfireMapScrollListener(@NotNull @NotNull MapScrollListener listener)
listener
- the listener to addpublic void removeCrossfireMapScrollListener(@NotNull @NotNull MapScrollListener listener)
listener
- the listener to removepublic void addMapSizeListener(@NotNull @NotNull MapSizeListener listener)
listener
- the listener to addpublic void removeMapSizeListener(@NotNull @NotNull MapSizeListener listener)
listener
- the listener to removepublic void reset()
@NotNull public @NotNull java.lang.Object mapBegin()
CrossfireUpdateMapListener
mapBegin
in interface CrossfireUpdateMapListener
synchronized
while calling any other function (except newMap()
)public void mapClear(int x, int y)
CrossfireUpdateMapListener
mapClear
in interface CrossfireUpdateMapListener
x
- the x-coordinatey
- the y-coordinatepublic void mapFace(@NotNull @NotNull Location location, int faceNum)
CrossfireUpdateMapListener
mapFace
in interface CrossfireUpdateMapListener
location
- the locationfaceNum
- the face IDpublic void mapFace(@NotNull @NotNull Location location, int faceNum, boolean clearAnimation)
location
- the location to updatefaceNum
- the face to set; 0
clears the squareclearAnimation
- whether an animation should be clearedpublic void mapAnimation(@NotNull @NotNull Location location, int animationNum, int animationType)
CrossfireUpdateMapListener
mapAnimation
in interface CrossfireUpdateMapListener
location
- the locationanimationNum
- the animation IDanimationType
- the animation typepublic void mapAnimationSpeed(@NotNull @NotNull Location location, int animationSpeed)
CrossfireUpdateMapListener
mapAnimationSpeed
in interface CrossfireUpdateMapListener
location
- the locationanimationSpeed
- the animation speedpublic void mapSmooth(@NotNull @NotNull Location location, int smooth)
CrossfireUpdateMapListener
mapSmooth
in interface CrossfireUpdateMapListener
location
- the locationsmooth
- the smooth valuepublic void mapDarkness(int x, int y, int darkness)
CrossfireUpdateMapListener
mapDarkness
in interface CrossfireUpdateMapListener
x
- the x-coordinatey
- the y-coordinatedarkness
- the darkness valuepublic void magicMap(int x, int y, byte[][] data)
CrossfireUpdateMapListener
magicMap
in interface CrossfireUpdateMapListener
x
- the x-coordinatey
- the y-coordinatedata
- the magic map data (y, x); must not be changedpublic void mapEnd()
CrossfireUpdateMapListener
mapEnd
in interface CrossfireUpdateMapListener
public void mapEnd(boolean alwaysProcess)
alwaysProcess
- if set, notify listeners even if no changes are
presentpublic void mapScroll(int dx, int dy)
CrossfireUpdateMapListener
mapScroll
in interface CrossfireUpdateMapListener
dx
- the x-distancedy
- the y-distancepublic void faceUpdated(@NotNull @NotNull Face face)
FacesManagerListener
Face
has been updated.faceUpdated
in interface FacesManagerListener
face
- the facepublic void newMap(int mapWidth, int mapHeight)
CrossfireUpdateMapListener
newMap
in interface CrossfireUpdateMapListener
mapWidth
- the map widthmapHeight
- the map height@NotNull public @NotNull CfMap getMap()
public int getMapWidth()
public int getMapHeight()
public void tick(int tickNo)
CrossfireTickListener
tick
in interface CrossfireTickListener
tickNo
- the current tick