Hey, is this good way to use animations?
Code:
package lrps.engine.util;
import java.util.HashMap;
import java.util.Map;
import liuxx.io.RAFStream;
/*
* Author: Liuxx (lukas265)
* Date: 2011-09-03
* E-Mail: [email protected]
* Skype: liuksius86
* MSN: [email protected]
*/
public class Animation {
public static final Map<String,Short> animation = new HashMap<String,Short>();
static {
load();
}
public static void load() {
try {
RAFStream rafs = new RAFStream("Animations.dat", "rw");
animation.clear();
while(rafs.length() != rafs.getFilePointer()) {
short id = rafs.readShort();
String name = rafs.readSizedString();
animation.put(name, id);
}
Logger.log(Animation.class, "Loaded animations ["+animation.size()+"]...");
rafs.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static short get(String anim) {
Object o = animation.get(anim);
return o == null ? 0 : (Short)o;
}
public final short id;
public final String name;
public Animation(int id, String name) {
this.id = (short)id;
this.name = name;
}
@Override
public String toString() {
return id+" - "+name;
}
}
Instead:
Code:
player.animate(426); // Do ranging emote
I would use this:
Code:
player.animate(Animation.get("Ranging"));// Do ranging emote
or
Code:
player.animate("Ranging");
Rasier to remember animations.