com.realtime.crossfire.jxclient.map
Class CfMapAnimations

java.lang.Object
  extended by com.realtime.crossfire.jxclient.map.CfMapAnimations

public class CfMapAnimations
extends java.lang.Object

Manages a set of animated map squares.


Field Summary
private  AnimationMap animations
          The animations in the visible map area.
private  java.util.Map<AnimationState,java.lang.Void> animationStates
          All AnimationState instances referenced by animations.
private  CrossfireTickListener crossfireTickListener
          The listener for receiving "tick" commands.
private  int height
          The height of the visible map area.
private  CfMapUpdater mapUpdater
          The CfMapUpdater instance to update.
private  java.util.Collection<AnimationState> pendingTickUpdates
          The AnimationState instances that have been added but not yet received a "tick" value.
private  java.util.Random random
          The random number generator for Map2.ANIM_RANDOM type animations.
private  java.lang.Object sync
          Synchronization object.
private  java.util.Map<java.lang.Integer,AnimationState> syncAnimationStates
          All AnimationState for Map2.ANIM_SYNC animations.
private  int width
          The width of the visible map area.
 
Constructor Summary
CfMapAnimations(CfMapUpdater mapUpdater)
          Creates a new instance.
CfMapAnimations(CrossfireServerConnection crossfireServerConnection, CfMapUpdater mapUpdater)
          Creates a new instance.
 
Method Summary
 void add(Location location, Animation animation, int type)
          Adds a visible animation.
 void clear()
          Forgets all animations.
 void remove(int x, int y)
          Removes all visible animations for a tile.
 void remove(Location location)
          Removes a visible animation.
 void scroll(int dx, int dy)
          Scrolls the animations.
 void setMapSize(int width, int height)
          Updates the map size.
 void tick(int tickNo)
          Processes a tick command.
 void updateSpeed(Location location, int speed)
          Updates the animation speed value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

animations

@NotNull
private final AnimationMap animations
The animations in the visible map area.


animationStates

@NotNull
private final java.util.Map<AnimationState,java.lang.Void> animationStates
All AnimationState instances referenced by animations.


crossfireTickListener

@NotNull
private final CrossfireTickListener crossfireTickListener
The listener for receiving "tick" commands.


height

private int height
The height of the visible map area.


mapUpdater

@NotNull
private final CfMapUpdater mapUpdater
The CfMapUpdater instance to update.


pendingTickUpdates

@NotNull
private final java.util.Collection<AnimationState> pendingTickUpdates
The AnimationState instances that have been added but not yet received a "tick" value.


random

@NotNull
private final java.util.Random random
The random number generator for Map2.ANIM_RANDOM type animations.


sync

@NotNull
private final java.lang.Object sync
Synchronization object.


syncAnimationStates

@NotNull
private final java.util.Map<java.lang.Integer,AnimationState> syncAnimationStates
All AnimationState for Map2.ANIM_SYNC animations.


width

private int width
The width of the visible map area.

Constructor Detail

CfMapAnimations

public CfMapAnimations(@NotNull
                       CfMapUpdater mapUpdater)
Creates a new instance.

Parameters:
mapUpdater - the instance to update

CfMapAnimations

public CfMapAnimations(@NotNull
                       CrossfireServerConnection crossfireServerConnection,
                       @NotNull
                       CfMapUpdater mapUpdater)
Creates a new instance.

Parameters:
crossfireServerConnection - the connection to watch
mapUpdater - the instance to update
Method Detail

add

public void add(@NotNull
                Location location,
                @NotNull
                Animation animation,
                int type)
Adds a visible animation.

Parameters:
location - the location to animate
animation - the animation to display
type - the animation type

clear

public void clear()
Forgets all animations.


remove

public void remove(int x,
                   int y)
Removes all visible animations for a tile.

Parameters:
x - the x-coordinate to un-animate
y - the y-coordinate to un-animate

remove

public void remove(@NotNull
                   Location location)
Removes a visible animation.

Parameters:
location - the location to un-animate

scroll

public void scroll(int dx,
                   int dy)
Scrolls the animations. Animations scrolled off the visible are are dropped.

Parameters:
dx - the x-distance to scroll
dy - the y-distance to scroll

setMapSize

public void setMapSize(int width,
                       int height)
Updates the map size.

Parameters:
width - the map width
height - the map height

tick

public void tick(int tickNo)
Processes a tick command.

Parameters:
tickNo - the current tick number

updateSpeed

public void updateSpeed(@NotNull
                        Location location,
                        int speed)
Updates the animation speed value.

Parameters:
location - the location to update
speed - the new animation speed