io.leonis.subra.ipc.serialization.gson.PlayerCommandSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of subra Show documentation
Show all versions of subra Show documentation
soccer is simple, but it is difficult to play simple
The newest version!
package io.leonis.subra.ipc.serialization.gson;
import com.google.gson.*;
import io.leonis.subra.game.data.PlayerCommand;
import java.lang.reflect.Type;
/**
* Class for handling serialization of PlayerCommand objects.
*
* @author Ryan Meulenkamp
*/
public class PlayerCommandSerializer implements JsonSerializer {
@Override
public JsonElement serialize(
final PlayerCommand src,
final Type typeOfSrc,
final JsonSerializationContext context
) {
final JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("xVelocity", src.getVelocityX());
jsonObject.addProperty("yVelocity", src.getVelocityY());
jsonObject.addProperty("rVelocity", src.getVelocityR());
jsonObject.addProperty("flatKick", src.getFlatKick());
jsonObject.addProperty("chipKick", src.getChipKick());
jsonObject.addProperty("dribblerSpin", src.getDribblerSpin());
return jsonObject;
}
}