com.realtime.crossfire.jxclient.map
Class AnimationState

java.lang.Object
  extended by com.realtime.crossfire.jxclient.map.AnimationState
All Implemented Interfaces:
java.lang.Iterable<Location>

public class AnimationState
extends java.lang.Object
implements java.lang.Iterable<Location>

The state of an Animation on a map.


Field Summary
private  Animation animation
          The Animation to display.
private  int index
          The face index currently shown.
private  int lastFace
          Records the last known face.
private  java.util.Set<Location> locations
          All map locations this animation is displayed at.
private  CfMapUpdater mapUpdater
          The CfMapUpdater instance to use.
private  int speed
          The animation speed.
private  int tickNo
          The face was updated last in this tick number.
 
Constructor Summary
AnimationState(CfMapUpdater mapUpdater, Animation animation, int index)
          Creates a new instance.
 
Method Summary
 void allocate(Location location)
          Adds this animation state to a map Location.
 void free(Location location)
          Removes this animation state from a map Location.
 java.util.Iterator<Location> iterator()
          
 void scroll(int dx, int dy, int width, int height)
          Scrolls all map locations.
 void setSpeed(int speed)
          Sets the animation speed.
 void setTickNo(int tickNo)
          Sets the tick number.
private  void updateFace()
          Updates the map face from the state.
 void updateTickNo(int tickNo)
          Sets the tick number and update affected faces.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

animation

@NotNull
private final Animation animation
The Animation to display.


index

private int index
The face index currently shown. May contain values between 0 and speed*animation.getFaces() (exclusive).


lastFace

private int lastFace
Records the last known face. Used to suppress redundant map updates.


locations

@NotNull
private final java.util.Set<Location> locations
All map locations this animation is displayed at.


mapUpdater

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


speed

private int speed
The animation speed.


tickNo

private int tickNo
The face was updated last in this tick number.

Constructor Detail

AnimationState

public AnimationState(@NotNull
                      CfMapUpdater mapUpdater,
                      @NotNull
                      Animation animation,
                      int index)
Creates a new instance.

Parameters:
mapUpdater - the map updater instance to use
animation - the animation to display
index - the initial face index
Method Detail

allocate

public void allocate(@NotNull
                     Location location)
Adds this animation state to a map Location.

Parameters:
location - the map location

free

public void free(@NotNull
                 Location location)
Removes this animation state from a map Location.

Parameters:
location - the location to free

iterator

@NotNull
public java.util.Iterator<Location> iterator()

Specified by:
iterator in interface java.lang.Iterable<Location>

scroll

public void scroll(int dx,
                   int dy,
                   int width,
                   int height)
Scrolls all map locations.

Parameters:
dx - the x distance to scroll
dy - the y distance to scroll
width - the map width
height - the map height

setSpeed

public void setSpeed(int speed)
Sets the animation speed.

Parameters:
speed - the new animation speed to set

setTickNo

public void setTickNo(int tickNo)
Sets the tick number. This function does not update the displayed face.

Parameters:
tickNo - the current tick number

updateFace

private void updateFace()
Updates the map face from the state.


updateTickNo

public void updateTickNo(int tickNo)
Sets the tick number and update affected faces.

Parameters:
tickNo - the tick number