private final Collection<IAttribute> _attributes;
public interface IAttribute {
void write(ByteBuffer buf);
}
public void addAttribute(CharParamType id, int value) {
_attributes.add(new Attribute(id, value));
}
public void addAttribute64(CharParamType id, long value) {
_attributes.add(new Attribute64(id, value));
}
@Override
protected void writeImpl(GameClient client, ByteBuffer buf) {
writeD(buf, _objectId);
writeD(buf, _attackObjectId);
writeC(buf, _visible.ordinal());
writeC(buf, _attributes.size());
for (IAttribute temp : _attributes)
temp.write(buf);
}
record Attribute(CharParamType id, int value) implements IAttribute {
public void write(ByteBuffer buf) {
writeC(buf, id.ordinal());
writeD(buf, value);
}
}
record Attribute64(CharParamType id, long value) implements IAttribute {
public void write(ByteBuffer buf) {
writeC(buf, id.ordinal());
writeQ(buf, value);
}
}