Package networking.response

Source Code of networking.response.ResponseCreateEnv

package networking.response;

import metadata.Constants;

import model.Environment;

import utility.GamePacket;

import worldManager.gameEngine.WaterSource;
import worldManager.gameEngine.Zone;

/**
*
* @author Gary
*/
public class ResponseCreateEnv extends GameResponse {

    private Environment env;

    public ResponseCreateEnv() {
        responseCode = Constants.SMSG_CREATE_ENV;
    }

    @Override
    public byte[] constructResponseInBytes() {;
        GamePacket packet = new GamePacket(responseCode);
        packet.addInt32(env.getID());
        packet.addShort16((short) env.getRow());
        packet.addShort16((short) env.getColumn());
        packet.addInt32(env.getOwnerID());
        packet.addInt32(env.getEnvironmentScore());

        for (Zone zone : env.getZones()) {
            packet.addShort16((short) zone.getID());
            packet.addShort16((short) zone.getType());

            WaterSource waterSource = zone.getWaterSource();
            packet.addBoolean(waterSource != null);

            if (waterSource != null) {
                packet.addInt32(waterSource.getID());
                packet.addInt32(waterSource.getMaxWater());
                packet.addInt32(waterSource.getWater());
            }
        }

        return packet.getBytes();
    }

    public void setEnvironment(Environment env) {
        this.env = env;
    }
}
TOP

Related Classes of networking.response.ResponseCreateEnv

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.