71 lines
1.4 KiB
Java
71 lines
1.4 KiB
Java
package electrosphere.net.server;
|
|
|
|
import electrosphere.entity.Entity;
|
|
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(){
|
|
idIncrementerLock.acquireUninterruptibly();
|
|
id = idIncrementer;
|
|
idIncrementer++;
|
|
idIncrementerLock.release();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
}
|