 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.map;
30 import java.util.Collection;
31 import java.util.Collections;
32 import java.util.HashSet;
33 import java.util.Iterator;
35 import org.jetbrains.annotations.NotNull;
92 private final Set<Location>
locations =
new HashSet<>();
98 private final Collection<Integer>
tags =
new HashSet<>();
121 final int effectiveSpeed = Math.max(1,
speed);
122 if (this.speed == effectiveSpeed) {
126 final int tmpDelay = Math.min(
index%this.speed, effectiveSpeed-1);
127 this.speed = effectiveSpeed;
128 index = tmpIndex*effectiveSpeed+tmpDelay;
146 if (tickNo < this.tickNo) {
147 System.err.println(
"Ignoring inconsistent tick value: current tick number is "+
tickNo+
", previous tick number was "+this.tickNo+
".");
168 for (
int tag :
tags) {
169 itemSet.
updateItem(
UpdItem.
UPD_FACE, tag, 0, 0, 0, face2,
"",
"", 0, 0, 0);
179 throw new IllegalArgumentException(
"duplicate location "+location);
191 if (!
tags.add(tag)) {
192 throw new IllegalArgumentException(
"duplicate item tag "+tag);
195 itemSet.
updateItem(
UpdItem.
UPD_FACE, tag, 0, 0, 0,
facesManager.
getFace(
lastFace),
"",
"", 0, 0, 0);
205 throw new IllegalArgumentException(
"undefined location "+location);
220 public void free(
final int tag) {
221 if (!
tags.remove(tag)) {
222 throw new IllegalArgumentException(
"undefined item tag "+tag);
229 return Collections.unmodifiableSet(
locations).iterator();
239 public void scroll(
final int dx,
final int dy,
final int width,
final int height) {
240 final Collection<Location> tmp =
new HashSet<>();
242 if (0 <= location.getX() && location.getX() < width && 0 <= location.getY() && location.getY() < height) {
243 final int newX = location.getX()-dx;
244 final int newY = location.getY()-dy;
245 if (0 <= newX && newX < width && 0 <= newY && newY < height) {
247 tmp.add(newLocation);
Maintains a mapping of face numbers to face data.
int UPD_FACE
The update flags value for face updates.
Model class maintaining the CfItems known to the player.
void scroll(final int dx, final int dy, final int width, final int height)
Scrolls all map locations.
int getFace(final int index)
Returns one face of this animation.
Iterator< Location > iterator()
void mapFace(@NotNull Location location, int faceNum)
Part of "map2" parsing: set the face of a cell.
int getFaces()
Returns the number of faces of this animation.
Face getFace(int faceNum)
Returns the Face instance for a given face ID.
Interface defining constants for the "upditem" Crossfire protocol message.
Manages animations received from the server.
Manages image information ("faces") needed to display the map view, items, and spell icons.
final FacesManager facesManager
The FacesManager to track for updated faces.
final Animation animation
The Animation to display.
final Set< Location > locations
All map locations this animation is displayed at.
void updateTickNo(final int tickNo)
Sets the tick number and update affected faces.
int tickNo
The face was updated last in this tick number.
final ItemSet itemSet
The ItemSet to notify of changes.
void freeAllLocations()
Removes this animation state from all map Locations.
AnimationState(@NotNull final Animation animation, final int index, @NotNull final CfAnimationsMapListener mapListener, @NotNull final ItemSet itemSet, @NotNull final FacesManager facesManager)
Creates a new instance.
void setSpeed(final int speed)
Sets the animation speed.
void setTickNo(final int tickNo)
Sets the tick number.
void updateFace()
Updates the map or item face from the state.
int lastFace
Records the last known face.
void allocate(@NotNull final Location location)
Adds this animation state to a map Location.
void free(@NotNull final Location location)
Removes this animation state from a map Location.
void updateItem(final int flags, final int tag, final int valLocation, final int valFlags, final int valWeight, @NotNull final Face valFace, @NotNull final String valName, @NotNull final String valNamePl, final int valAnim, final int valAnimSpeed, final int valNrof)
Processes an "upditem" command.
final Collection< Integer > tags
All item tags this animation is displayed at.
void free(final int tag)
Removes this animation state from an item tag.
The state of an Animation on a map.
int speed
The animation speed.
int index
The face index currently shown.
final CfAnimationsMapListener mapListener
The CfAnimationsMapListener to notify of changes.
void allocate(final int tag)
Adds this animation state to an item tag.