/*
 * This file is part of the Yildiz-Engine project, licenced under the MIT License  (MIT)
 *
 * Copyright (c) 2017 Grégory Van den Borre
 *
 * More infos available: https://www.yildiz-games.be
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without
 * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial
 * portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
 * OR COPYRIGHT  HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  SOFTWARE.
 */

package be.yildiz.shared.protocol.request;

import be.yildiz.common.id.ActionId;
import be.yildiz.common.id.EntityId;
import be.yildiz.common.vector.Point3D;
import be.yildiz.module.network.exceptions.InvalidNetworkMessage;
import be.yildiz.module.network.protocol.MessageWrapper;
import be.yildiz.module.network.protocol.NetworkMessage;
import be.yildiz.module.network.protocol.ServerRequest;
import be.yildiz.shared.entity.action.Action;

/**
 * @author Grégory Van den Borre
 */
public final class ActionRequest extends NetworkMessage implements ServerRequest {

    public final EntityId entityId;

    /**
     * Module executing the action.
     */
    public final ActionId moduleId;

    public final Point3D destination;

    public final EntityId targetId;

    /**
     * Full constructor.
     *
     * @param message Message from the server to parse.
     * @throws InvalidNetworkMessage If an error occurs while parsing the message.
     */
    public ActionRequest(final MessageWrapper message) throws InvalidNetworkMessage {
        super(message);
        this.entityId = this.getEntityId();
        this.moduleId = this.getActionId();
        this.destination = this.getPoint3D();
        this.targetId = this.getEntityId();
    }

    /**
     * Full constructor.
     * @param e Entity id.
     * @param a Action to request.
     */
    public ActionRequest(final EntityId e, final Action a) {
        super(NetworkMessage.convertParams(e, a.id, a.getDestination(), a.getTargetId()));
        this.entityId = e;
        this.moduleId = a.id;
        this.destination = a.getDestination();
        this.targetId = a.getTargetId();
    }

    @Override
    public int command() {
        return ClientCommand.ACTION.ordinal();
    }
}

@@ -1583,30 +1583,29 @@
 rotocol.
-NetworkMessage
+ServerRequest
 ;%0Aimport
@@ -1619,91 +1619,88 @@
 diz.
-module.network.protocol.ServerRequest;%0Aimport be.yildiz.shared.entity.action.Action
+shared.entity.action.Action;%0Aimport be.yildiz.shared.protocol.BaseNetworkMessage
 ;%0A%0A/
@@ -1780,16 +1780,20 @@
 extends 
+Base
 NetworkM
@@ -2351,35 +2351,35 @@
 tyId = this.
-get
+to(
 EntityId
 ();%0A        
@@ -2362,25 +2362,30 @@
 .to(EntityId
-(
+.class
 );%0A        t
@@ -2408,19 +2408,19 @@
 his.
-get
+to(
 ActionId
 ();%0A
@@ -2415,17 +2415,22 @@
 ActionId
-(
+.class
 );%0A     
@@ -2460,19 +2460,24 @@
 his.
-get
+to(
 Point3D
-(
+.class
 );%0A 
@@ -2508,19 +2508,19 @@
 his.
-get
+to(
 EntityId
 ();%0A
@@ -2515,17 +2515,22 @@
 EntityId
-(
+.class
 );%0A    %7D
@@ -2713,66 +2713,201 @@
 per(
-NetworkMessage.convertParams(e, a.id, a.getDestination(), 
+%0A                BaseNetworkMessage.from(e),%0A                BaseNetworkMessage.from(a.id),%0A                BaseNetworkMessage.from(a.getDestination()),%0A                BaseNetworkMessage.from(
 a.ge

Use BaseNetworkMessage.