package electrosphere.net.server;

import electrosphere.entity.Entity;
import electrosphere.main.Globals;
import electrosphere.net.parser.net.message.NetworkMessage;
import java.util.concurrent.Semaphore;

/**
 *
 * @author satellite
 */
public class Player {
    
    ServerConnectionHandler connectionHandler;
    int id;
    static Semaphore idIncrementerLock = new Semaphore(1);
    static int idIncrementer = 0;
    int worldX;
    int worldY;
    int simulationRadius = 3;
    Entity playerEntity;
    
    public Player(ServerConnectionHandler connectionHandler){
        this.connectionHandler = connectionHandler;
        idIncrementerLock.acquireUninterruptibly();
        id = idIncrementer;
        idIncrementer++;
        idIncrementerLock.release();
        this.simulationRadius = Globals.userSettings.getGameplayPhysicsCellRadius();
    }

    public int getId() {
        return id;
    }
    
    public void addMessage(NetworkMessage message){
        connectionHandler.addMessagetoOutgoingQueue(message);
    }

    public int getWorldX() {
        return worldX;
    }

    public int getWorldY() {
        return worldY;
    }

    public void setWorldX(int worldX) {
        this.worldX = worldX;
    }

    public void setWorldY(int worldY) {
        this.worldY = worldY;
    }

    public int getSimulationRadius() {
        return simulationRadius;
    }

    public void setSimulationRadius(int simulationRadius) {
        this.simulationRadius = simulationRadius;
    }

    public Entity getPlayerEntity() {
        return playerEntity;
    }

    public void setPlayerEntity(Entity playerEntity) {
        this.playerEntity = playerEntity;
    }
    
    
}
