clean up main file by removing globals
This commit is contained in:
parent
70f54fefd5
commit
0bd0c00f27
@ -11,6 +11,7 @@
|
||||
"graphicsPerformanceLODChunkRadius" : 3,
|
||||
"graphicsPerformanceEnableVSync" : false,
|
||||
"graphicsPerformanceDrawShadows" : true,
|
||||
"graphicsViewRange" : 20000.0,
|
||||
|
||||
"graphicsDebugDrawCollisionSpheres" : false,
|
||||
"graphicsDebugDrawPhysicsObjects" : false,
|
||||
|
||||
@ -39,6 +39,8 @@ public class UserSettings {
|
||||
boolean graphicsDebugDrawPhysicsObjects;
|
||||
boolean graphicsDebugDrawMovementVectors;
|
||||
boolean graphicsDebugDrawNavmesh;
|
||||
|
||||
float graphicsViewRange;
|
||||
|
||||
|
||||
|
||||
@ -91,6 +93,10 @@ public class UserSettings {
|
||||
return graphicsPerformanceLODChunkRadius;
|
||||
}
|
||||
|
||||
public float getGraphicsViewDistance(){
|
||||
return graphicsViewRange;
|
||||
}
|
||||
|
||||
public boolean graphicsDebugDrawNavmesh() {
|
||||
return graphicsDebugDrawNavmesh;
|
||||
}
|
||||
@ -111,6 +117,10 @@ public class UserSettings {
|
||||
public void setGraphicsDebugDrawNavmesh(boolean draw){
|
||||
this.graphicsDebugDrawNavmesh = draw;
|
||||
}
|
||||
|
||||
public void setGraphicsViewRange(float range){
|
||||
graphicsViewRange = range;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ public class ServerDataCell {
|
||||
*/
|
||||
public void broadcastNetworkMessage(NetworkMessage message){
|
||||
for(Player player : activePlayers){
|
||||
if(player != Globals.serverPlayer){
|
||||
if(player != Globals.clientPlayer){
|
||||
player.addMessage(message);
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ public class ServerDataCell {
|
||||
* Commonly, this should be called when a player is added to the cell
|
||||
*/
|
||||
void serializeStateToPlayer(Player player){
|
||||
if(player != Globals.serverPlayer){
|
||||
if(player != Globals.clientPlayer){
|
||||
for(Entity entity : loadedEntities){
|
||||
if(CreatureUtils.isCreature(entity)){
|
||||
CreatureUtils.sendEntityToPlayer(player, entity);
|
||||
|
||||
@ -174,7 +174,7 @@ public class Globals {
|
||||
//Player manager
|
||||
//
|
||||
public static PlayerManager playerManager;
|
||||
public static Player serverPlayer;
|
||||
public static Player clientPlayer;
|
||||
|
||||
//
|
||||
//Generic OpenGL Statements
|
||||
|
||||
@ -71,42 +71,9 @@ public class Main {
|
||||
static double lastFrame = 0.0f;
|
||||
static long frameCount = 0;
|
||||
public static float deltaFrames = 0;
|
||||
//View Controls
|
||||
public static float view_Range = 200000.0f;
|
||||
/*
|
||||
Mouse Controls
|
||||
*/
|
||||
// static float mouse_lastX = 400;
|
||||
// static float mouse_lastY = 300;
|
||||
// static double xpos = 400;
|
||||
// static double ypos = 300;
|
||||
// static float mouseSensitivity = .1f;
|
||||
// static double mouse_X_Buffer[] = new double[1];
|
||||
// static double mouse_Y_Buffer[] = new double[1];
|
||||
// static float cameraSpeed;
|
||||
// static float yaw = 150;
|
||||
// static float pitch = 50;
|
||||
|
||||
|
||||
|
||||
|
||||
static int playerStartRealX = 0;
|
||||
static int playerStartRealY = 0;
|
||||
|
||||
// public static Camera cam_Player_Orbit;
|
||||
//Camera angles using theta-phi system
|
||||
//Euler angles where theta is applied, then phi
|
||||
//There is no bank applied to the camera
|
||||
|
||||
public static Model model;
|
||||
|
||||
public static int playerId = -1;
|
||||
|
||||
|
||||
public static boolean running = true;
|
||||
|
||||
public static Entity letterEntity;
|
||||
|
||||
//target amount of time per frame
|
||||
public static float targetFrameRate = 60.0f;
|
||||
static float targetFramePeriod = 1.0f/targetFrameRate;
|
||||
|
||||
@ -53,7 +53,7 @@ public class EntityProtocol {
|
||||
Entity target = Globals.entityManager.getEntityFromId(message.getentityID());
|
||||
if(target != null){
|
||||
CreatureUtils.setControllerPlayerId(target, message.getpropertyValue());
|
||||
if(message.getpropertyValue() == Main.playerId){
|
||||
if(Globals.clientPlayer != null && message.getpropertyValue() == Globals.clientPlayer.getId()){
|
||||
Globals.clientCharacterID = message.getentityID();
|
||||
Globals.playerEntity = target;
|
||||
}
|
||||
|
||||
@ -4,14 +4,15 @@ import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.main.Main;
|
||||
import electrosphere.net.parser.net.message.PlayerMessage;
|
||||
import electrosphere.net.server.player.Player;
|
||||
|
||||
public class PlayerProtocol {
|
||||
|
||||
protected static void handlePlayerMessage(PlayerMessage message){
|
||||
switch(message.getMessageSubtype()){
|
||||
case SET_ID:
|
||||
Main.playerId = message.getplayerID();
|
||||
LoggerInterface.loggerNetworking.DEBUG("Player ID is " + Main.playerId);
|
||||
Globals.clientPlayer = new Player(message.getplayerID());
|
||||
LoggerInterface.loggerNetworking.DEBUG("Player ID is " + Globals.clientPlayer.getId());
|
||||
break;
|
||||
case SETINITIALDISCRETEPOSITION:
|
||||
Globals.clientPlayerData.setWorldPosition(message.getinitialDiscretePositionX(), message.getinitialDiscretePositionY());
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package electrosphere.net.server;
|
||||
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.main.Main;
|
||||
import electrosphere.net.NetUtils;
|
||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||
@ -74,7 +75,7 @@ public class Server implements Runnable{
|
||||
|
||||
public void broadcastMessage(NetworkMessage message){
|
||||
for(ServerConnectionHandler client : clientMap.values()){
|
||||
if(client.playerID != Main.playerId){
|
||||
if(Globals.clientPlayer == null || client.playerID != Globals.clientPlayer.getId()){
|
||||
client.addMessagetoOutgoingQueue(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,11 @@ public class Player {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ public class AuthProtocol {
|
||||
Player newPlayer = new Player(connectionHandler);
|
||||
Globals.playerManager.registerPlayer(newPlayer);
|
||||
if(connectionHandler.getIPAddress().contains("127.0.0.1")){
|
||||
Globals.serverPlayer = newPlayer;
|
||||
Globals.clientPlayer = newPlayer;
|
||||
}
|
||||
connectionHandler.addMessagetoOutgoingQueue(PlayerMessage.constructSet_IDMessage(connectionHandler.getPlayerId()));
|
||||
} else {
|
||||
|
||||
@ -60,7 +60,7 @@ public class CharacterProtocol {
|
||||
// Entity sword = ItemUtils.spawnBasicItem("Katana");
|
||||
// AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031");
|
||||
//set controller id
|
||||
if(playerObject == Globals.serverPlayer){
|
||||
if(playerObject == Globals.clientPlayer){
|
||||
Globals.playerEntity = newPlayerEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public class EntityProtocol {
|
||||
|
||||
void queueChunkState(ServerConnectionHandler connectionHandler){
|
||||
//queue messages for that chunk
|
||||
if(Globals.RUN_SERVER && Main.playerId == -1){
|
||||
if(Globals.RUN_SERVER && Globals.clientPlayer == null){
|
||||
|
||||
} else {
|
||||
for(Entity currentEntity : Globals.entityManager.getMoveable()){
|
||||
|
||||
@ -14,7 +14,6 @@ import electrosphere.game.server.pathfinding.navmesh.NavMesh;
|
||||
import electrosphere.game.server.pathfinding.navmesh.NavShape;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.main.Globals;
|
||||
import static electrosphere.main.Main.view_Range;
|
||||
import static electrosphere.renderer.RenderUtils.createScreenTextureVAO;
|
||||
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
@ -392,7 +391,7 @@ public class RenderingEngine {
|
||||
float verticalFOV = (float)(Globals.verticalFOV * Math.PI /180.0f);
|
||||
float aspectRatio = (float)Globals.WINDOW_WIDTH / (float)Globals.WINDOW_HEIGHT;
|
||||
float nearClip = 0.001f;
|
||||
Globals.projectionMatrix.setPerspective(verticalFOV, aspectRatio, nearClip, view_Range);
|
||||
Globals.projectionMatrix.setPerspective(verticalFOV, aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance());
|
||||
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user