Package be.demmel.jgws.actions

Source Code of be.demmel.jgws.actions.RotatePlayerAction

package be.demmel.jgws.actions;

import io.netty.channel.Channel;
import io.netty.channel.group.ChannelGroup;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import be.demmel.jgws.CharacterData;
import be.demmel.jgws.SessionKey;
import be.demmel.jgws.QueueAction;
import be.demmel.jgws.packets.gameserver.outbound.P035_RotateAgent;

public class RotatePlayerAction implements QueueAction {

    private static final Logger LOGGER = LoggerFactory.getLogger(RotatePlayerAction.class);
    private Channel rotatingPlayer;
    private final ChannelGroup channels;

    // Position must be passed so that it can't be changed before the queue processes this action?
    public RotatePlayerAction(Channel rotatingPlayer, ChannelGroup channels) {
        this.rotatingPlayer = rotatingPlayer;
        this.channels = channels;
    }

    @Override
    public void execute() {
        try {
            // Let each player on the map know about this player's rotation
            for (Channel player : channels) {
                rotatePlayer(rotatingPlayer, player);
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void rotatePlayer(Channel rotatingPlayer, Channel recipient) throws Exception {
        CharacterData character = rotatingPlayer.attr(SessionKey.SESSION_KEY).get().getCurrentCharacter();
       
        P035_RotateAgent rotateAgent = new P035_RotateAgent();
        rotateAgent.setAgentId(character.getAgentID());
        rotateAgent.setRotation(character.getRotation());
        rotateAgent.setUnknown3(0x40060A92);
        recipient.write(rotateAgent);
    }
}
TOP

Related Classes of be.demmel.jgws.actions.RotatePlayerAction

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.