public class GameMovementMessage extends Message {
private IEntity entity;
public GameMovementMessage(IEntity entity) {
this.entity = entity;
}
@Override
public void serialize() {
getOutput().append("GM");
getOutput().append("|+");
getOutput().append(entity.getCell().getId()).append(";");
getOutput().append(entity.getOrientation()).append(";");
getOutput().append("0;");
getOutput().append(entity.getUnicId()).append(";");
if(entity instanceof MutantEntity) {
IEntity monster = ((MutantEntity)entity).getMonster();
getOutput().append(monster.getId()).append(";");
getOutput().append("-7;").append(monster.getGfxId()).append("^").append(monster.getSize());
getOutput().append(";").append("0").append(";").append("5").append(";");
getOutput().append(entity.getStuffString()).append(";;;").append(0);
} else {
getOutput().append(entity.getName()).append(";");
getOutput().append(((PlayableCharacter)entity).getId());
Optional<Title> title = ((List<Title>)entity.getProperties(Title.class).getList()).values().stream().filter(t -> t.isSelected()).findFirst();
if(title.isPresent()) {
packet.append(",").append(title.get().getTitle()).append(",").append(title.get().getColor());
}
getOutput().append(";");
getOutput().append(entity.getGfxId()).append("^").append(entity.getSize());
Item follower = null;
if((follower = ((PlayableCharacter)entity).getItemByPosition(ItemConst.ITEM_POS_PNJ_SUIVEUR)) != null) {
getOutput().append(",").append(Constants.getFollowerIdByTemplateId(follower.getTemplate().getId()));
getOutput().append("^100");
}
getOutput().append(";");
getOutput().append(entity.getSexe()).append(";");
getOutput().append(entity.getAlign().getAlignment()).append(",0,");
getOutput().append(entity.getAlign().isShowWings() ? entity.getAlign().getGrade() : 0).append(",").append((entity.getLvl() > 200 ? 200 : entity.getLvl())+entity.getId()).append(","); //TODO
if(entity.getAlign().isShowWings() && entity.getAlign().getDeshonors() > 0) getOutput().append("1;");
else getOutput().append("0;");
getOutput().append((entity.colors.get(0) != -1 ? Integer.toHexString(entity.colors.get(0)) : entity.colors.get(0))+";");
getOutput().append((entity.colors.get(1) != -1 ? Integer.toHexString(entity.colors.get(1)) : entity.colors.get(1))+";");
getOutput().append((entity.colors.get(2) != -1 ? Integer.toHexString(entity.colors.get(2)) : entity.colors.get(2))+";");
getOutput().append(((PlayableCharacter)entity).getStuffString()).append(";");
if(entity.getLvl() > 199)
getOutput().append("2;");
else if(entity.getLvl() > 99)
getOutput().append("1;");
else
getOutput().append("0;");
getOutput().append(";");//Emote
getOutput().append(";");//Emote timer
getOutput().append((((PlayableCharacter)entity).getGuildMember() != null ? ((PlayableCharacter)entity).getGuildMember().getGuild().getName() : "")+";");//GuildName
getOutput().append((((PlayableCharacter)entity).getGuildMember() != null ? ((PlayableCharacter)entity).getGuildMember().getGuild().getEmblem() : "")+";");//Emblem
getOutput().append(entity.getProperties(ExternalRestrictions.class).getValue()).append(";");//Restriction
getOutput().append(((PlayableCharacter)entity).isOnMount() && ((PlayableCharacter)entity).getMount() != null ? ((PlayableCharacter)entity).getMount().getStringColor(entity) : ""+";");//Mount color
getOutput().append(";");//TODO
}
}
@Override
public void deserialize() {
}
}