Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
75 lines
1.8 KiB
Java
75 lines
1.8 KiB
Java
package electrosphere.net.server.player;
|
|
|
|
import electrosphere.engine.Globals;
|
|
import electrosphere.entity.Entity;
|
|
import electrosphere.net.parser.net.message.NetworkMessage;
|
|
import electrosphere.net.server.ServerConnectionHandler;
|
|
|
|
import java.util.concurrent.Semaphore;
|
|
|
|
import org.joml.Vector3i;
|
|
|
|
/**
|
|
*
|
|
* @author satellite
|
|
*/
|
|
public class Player {
|
|
|
|
ServerConnectionHandler connectionHandler;
|
|
int id;
|
|
static Semaphore idIncrementerLock = new Semaphore(1);
|
|
static int idIncrementer = 0;
|
|
Vector3i worldPos;
|
|
int simulationRadius = 3;
|
|
Entity playerEntity;
|
|
|
|
public Player(ServerConnectionHandler connectionHandler){
|
|
this.connectionHandler = connectionHandler;
|
|
idIncrementerLock.acquireUninterruptibly();
|
|
id = idIncrementer;
|
|
idIncrementer++;
|
|
idIncrementerLock.release();
|
|
connectionHandler.setPlayerId(id);
|
|
this.simulationRadius = Globals.userSettings.getGameplayPhysicsCellRadius();
|
|
}
|
|
|
|
//used for when client is creating a player object for itself
|
|
public Player(int id){
|
|
this.id = id;
|
|
}
|
|
|
|
public int getId() {
|
|
return id;
|
|
}
|
|
|
|
public void addMessage(NetworkMessage message){
|
|
connectionHandler.addMessagetoOutgoingQueue(message);
|
|
}
|
|
|
|
public Vector3i getWorldPos() {
|
|
return worldPos;
|
|
}
|
|
|
|
public void setWorldPos(Vector3i worldPos) {
|
|
this.worldPos = worldPos;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
}
|