Search in sources :

Example 1 with GasParticleTypes

use of ladysnake.gaspunk.api.basetype.GasParticleTypes in project Gaspunk by Ladysnake.

the class GasDeserializer method write.

@Override
public void write(JsonWriter out, AbstractGas value) throws IOException {
    out.beginObject();
    if (value.getType() instanceof GasTypes) {
        GasTypes type = (GasTypes) value.getType();
        out.name("gasType");
        out.value(type.name());
    } else
        throw new RuntimeException("Cannot serialize unknown type " + value.getType());
    if (value.getParticleType() instanceof GasParticleTypes) {
        GasParticleTypes type = (GasParticleTypes) value.getParticleType();
        out.name("particleType");
        out.value(type.name());
    } else
        throw new RuntimeException("Cannot serialize unknown type " + value.getParticleType());
    out.name("color");
    out.value(Long.toString(value.getColor(), 16));
    out.name("bottleColor");
    out.value(Long.toString(value.getBottleColor(), 16));
    out.name("agents");
    out.beginArray();
    for (Gas.AgentEffect effect : value.getAgents()) {
        out.beginObject();
        out.name("agent");
        out.value(GasAgents.getId(effect.getAgent()).toString());
        out.name("potency");
        out.value(effect.getPotency());
        out.endObject();
    }
    out.endArray();
    String[] tooltipLines = value.getTooltipLines();
    if (tooltipLines.length > 0) {
        out.name("tooltipLines");
        out.beginArray();
        for (String s : value.getTooltipLines()) out.value(s);
        out.endArray();
    }
    out.endObject();
}
Also used : GasTypes(ladysnake.gaspunk.api.basetype.GasTypes) GasParticleTypes(ladysnake.gaspunk.api.basetype.GasParticleTypes) AbstractGas(ladysnake.gaspunk.api.AbstractGas) IGas(ladysnake.gaspunk.api.IGas) Gas(ladysnake.gaspunk.gas.Gas)

Aggregations

AbstractGas (ladysnake.gaspunk.api.AbstractGas)1 IGas (ladysnake.gaspunk.api.IGas)1 GasParticleTypes (ladysnake.gaspunk.api.basetype.GasParticleTypes)1 GasTypes (ladysnake.gaspunk.api.basetype.GasTypes)1 Gas (ladysnake.gaspunk.gas.Gas)1