move more state into clientState
This commit is contained in:
parent
bf982f0a87
commit
ac9c1a017e
@ -1,17 +1,24 @@
|
||||
package electrosphere.client;
|
||||
|
||||
import electrosphere.client.block.ClientBlockManager;
|
||||
import electrosphere.client.block.cells.ClientBlockCellManager;
|
||||
import electrosphere.client.chemistry.ClientChemistryCollisionCallback;
|
||||
import electrosphere.client.entity.character.ClientCharacterManager;
|
||||
import electrosphere.client.fluid.manager.ClientFluidManager;
|
||||
import electrosphere.client.player.ClientPlayerData;
|
||||
import electrosphere.client.scene.ClientLevelEditorData;
|
||||
import electrosphere.client.scene.ClientSceneWrapper;
|
||||
import electrosphere.client.scene.ClientWorldData;
|
||||
import electrosphere.client.sim.ClientSimulation;
|
||||
import electrosphere.client.terrain.cells.ClientDrawCellManager;
|
||||
import electrosphere.client.terrain.foliage.FoliageCellManager;
|
||||
import electrosphere.client.terrain.manager.ClientTerrainManager;
|
||||
import electrosphere.collision.CollisionEngine;
|
||||
import electrosphere.data.common.CommonEntityType;
|
||||
import electrosphere.data.voxel.VoxelType;
|
||||
import electrosphere.entity.scene.Scene;
|
||||
import electrosphere.net.client.ClientNetworking;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.net.synchronization.client.ClientSynchronizationManager;
|
||||
|
||||
/**
|
||||
@ -42,7 +49,7 @@ public class ClientState {
|
||||
/**
|
||||
* The synchronization manager on the client
|
||||
*/
|
||||
public ClientSynchronizationManager clientSynchronizationManager;
|
||||
public ClientSynchronizationManager clientSynchronizationManager = new ClientSynchronizationManager();
|
||||
|
||||
/**
|
||||
* The client network connection
|
||||
@ -74,6 +81,51 @@ public class ClientState {
|
||||
*/
|
||||
public ClientBlockManager clientBlockManager = new ClientBlockManager();
|
||||
|
||||
/**
|
||||
* Terrain cell manager
|
||||
*/
|
||||
public ClientDrawCellManager clientDrawCellManager;
|
||||
|
||||
/**
|
||||
* Block cell manager
|
||||
*/
|
||||
public ClientBlockCellManager clientBlockCellManager;
|
||||
|
||||
/**
|
||||
* client level editor data management
|
||||
*/
|
||||
public ClientLevelEditorData clientLevelEditorData = new ClientLevelEditorData();
|
||||
|
||||
/**
|
||||
* client current selected voxel type
|
||||
*/
|
||||
public VoxelType clientSelectedVoxelType = null;
|
||||
|
||||
/**
|
||||
* the selected type of entity to spawn
|
||||
*/
|
||||
public CommonEntityType selectedSpawntype = null;
|
||||
|
||||
/**
|
||||
* Client player data
|
||||
*/
|
||||
public Player clientPlayer;
|
||||
|
||||
/**
|
||||
* Current auth username
|
||||
*/
|
||||
public String clientUsername;
|
||||
|
||||
/**
|
||||
* Current auth password
|
||||
*/
|
||||
public String clientPassword;
|
||||
|
||||
/**
|
||||
* client player data
|
||||
*/
|
||||
public ClientPlayerData clientPlayerData = new ClientPlayerData();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
@ -54,9 +54,9 @@ public class ScriptClientVoxelUtils {
|
||||
if(cursorPos == null){
|
||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||
}
|
||||
if(Globals.clientSelectedVoxelType != null){
|
||||
TerrainEditing.editTerrain(cursorPos, 1.1f, Globals.clientSelectedVoxelType.getId(), EDIT_INCREMENT);
|
||||
Globals.movementAudioService.getAudioPath(Globals.clientSelectedVoxelType.getId(), InteractionType.STEP_SHOE_REG);
|
||||
if(Globals.clientState.clientSelectedVoxelType != null){
|
||||
TerrainEditing.editTerrain(cursorPos, 1.1f, Globals.clientState.clientSelectedVoxelType.getId(), EDIT_INCREMENT);
|
||||
Globals.movementAudioService.getAudioPath(Globals.clientState.clientSelectedVoxelType.getId(), InteractionType.STEP_SHOE_REG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,9 +202,9 @@ public class ClientSimulation {
|
||||
///
|
||||
/// C L I E N T C E L L M A N A G E R
|
||||
///
|
||||
if(Globals.clientDrawCellManager != null && Globals.clientState.clientWorldData != null){
|
||||
if(Globals.clientState.clientDrawCellManager != null && Globals.clientState.clientWorldData != null){
|
||||
//Cell manager do your things
|
||||
Globals.clientDrawCellManager.update();
|
||||
Globals.clientState.clientDrawCellManager.update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,8 +222,8 @@ public class ClientSimulation {
|
||||
* Updates the block cell manager
|
||||
*/
|
||||
private void updateBlockCellManager(){
|
||||
if(Globals.clientBlockCellManager != null && Globals.clientState.clientWorldData != null){
|
||||
Globals.clientBlockCellManager.update();
|
||||
if(Globals.clientState.clientBlockCellManager != null && Globals.clientState.clientWorldData != null){
|
||||
Globals.clientState.clientBlockCellManager.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ public class SpawnSelectionPanel {
|
||||
newButton.setOnClick(new ClickEventCallback() {public boolean execute(ClickEvent event){
|
||||
//set voxel type to this type
|
||||
onSelectType.accept(type);
|
||||
Globals.selectedSpawntype = type;
|
||||
Globals.clientState.selectedSpawntype = type;
|
||||
return false;
|
||||
}});
|
||||
containerDiv.addChild(newButton);
|
||||
|
||||
@ -131,7 +131,7 @@ public class VoxelSelectionPanel {
|
||||
newButton.setMarginRight(MARGIN_EACH_SIDE);
|
||||
newButton.setMarginTop(MARGIN_EACH_SIDE);
|
||||
//set color if this is the selected voxel type
|
||||
if(type == Globals.clientSelectedVoxelType){
|
||||
if(type == Globals.clientState.clientSelectedVoxelType){
|
||||
newButton.setColor(ELEMENT_COLOR_SELECTED);
|
||||
}
|
||||
//label
|
||||
@ -158,7 +158,7 @@ public class VoxelSelectionPanel {
|
||||
newButton.setOnClick(new ClickEventCallback() {public boolean execute(ClickEvent event){
|
||||
//set voxel type to this type
|
||||
onSelectType.accept(type);
|
||||
Globals.clientSelectedVoxelType = type;
|
||||
Globals.clientState.clientSelectedVoxelType = type;
|
||||
VoxelSelectionPanel.fillInVoxelSelectors(scrollable, searchString, onSelectType);
|
||||
return false;
|
||||
}});
|
||||
|
||||
@ -32,13 +32,13 @@ public class ImGuiChunkMonitor {
|
||||
//ui framework text
|
||||
ImGui.text("Chunk Monitor");
|
||||
|
||||
if(Globals.clientDrawCellManager != null){
|
||||
Globals.clientDrawCellManager.updateStatus();
|
||||
ImGui.text("Full res chunks: " + Globals.clientDrawCellManager.getMaxResCount());
|
||||
ImGui.text("Terrain node count: " + Globals.clientDrawCellManager.getNodeCount());
|
||||
if(Globals.clientState.clientDrawCellManager != null){
|
||||
Globals.clientState.clientDrawCellManager.updateStatus();
|
||||
ImGui.text("Full res chunks: " + Globals.clientState.clientDrawCellManager.getMaxResCount());
|
||||
ImGui.text("Terrain node count: " + Globals.clientState.clientDrawCellManager.getNodeCount());
|
||||
}
|
||||
if(Globals.clientBlockCellManager != null){
|
||||
ImGui.text("Block node count: " + Globals.clientBlockCellManager.getNodeCount());
|
||||
if(Globals.clientState.clientBlockCellManager != null){
|
||||
ImGui.text("Block node count: " + Globals.clientState.clientBlockCellManager.getNodeCount());
|
||||
}
|
||||
if(Globals.clientState.foliageCellManager != null){
|
||||
ImGui.text("Foliage node count: " + Globals.clientState.foliageCellManager.getNodeCount());
|
||||
|
||||
@ -35,7 +35,7 @@ public class ImGuiClientServices {
|
||||
if(ImGui.collapsingHeader("Draw Cells")){
|
||||
if(ImGui.button("Debug DrawCell at camera position")){
|
||||
Vector3i cameraWorldPos = Globals.clientState.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
DrawCell cell = Globals.clientDrawCellManager.getDrawCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
|
||||
DrawCell cell = Globals.clientState.clientDrawCellManager.getDrawCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
|
||||
LoggerInterface.loggerEngine.WARNING("" + cell);
|
||||
|
||||
LoggerInterface.loggerEngine.WARNING("Chunk topology:");
|
||||
|
||||
@ -28,7 +28,7 @@ public class ImGuiFluidMonitor {
|
||||
@Override
|
||||
public void exec() {
|
||||
if(ImGui.collapsingHeader("Server Data")){
|
||||
ServerFluidManager fluidManager = Globals.playerManager.getPlayerRealm(Globals.clientPlayer).getServerWorldData().getServerFluidManager();
|
||||
ServerFluidManager fluidManager = Globals.playerManager.getPlayerRealm(Globals.clientState.clientPlayer).getServerWorldData().getServerFluidManager();
|
||||
//server engine details
|
||||
ImGui.text("Fluids Debug");
|
||||
ImGui.text("State: " + (fluidManager.getSimulate() ? "on" : "off"));
|
||||
@ -67,7 +67,7 @@ public class ImGuiFluidMonitor {
|
||||
* Prints debug data about the chunk at 0,0,1
|
||||
*/
|
||||
private static void printChunkDebugData(){
|
||||
ServerFluidManager fluidManager = Globals.playerManager.getPlayerRealm(Globals.clientPlayer).getServerWorldData().getServerFluidManager();
|
||||
ServerFluidManager fluidManager = Globals.playerManager.getPlayerRealm(Globals.clientState.clientPlayer).getServerWorldData().getServerFluidManager();
|
||||
ServerFluidChunk chunk = fluidManager.getChunk(0, 0, 1);
|
||||
ImGui.text("Pressure: " + chunk.getTotalPressure());
|
||||
ImGui.text("Velocity magnitude: " + chunk.getTotalVelocityMag());
|
||||
|
||||
@ -49,7 +49,7 @@ public class ImGuiTestGen {
|
||||
gridManager.evictAll();
|
||||
|
||||
//clear client
|
||||
Globals.clientDrawCellManager.evictAll();
|
||||
Globals.clientState.clientDrawCellManager.evictAll();
|
||||
Globals.clientState.clientTerrainManager.evictAll();
|
||||
});
|
||||
}
|
||||
@ -85,8 +85,8 @@ public class ImGuiTestGen {
|
||||
}
|
||||
|
||||
//Toggles whether the client draws cell manager should update or not
|
||||
if(ImGui.button("Toggle ClientDrawCellManager updates " + (Globals.clientDrawCellManager.getShouldUpdate() ? "off" : "on"))){
|
||||
Globals.clientDrawCellManager.setShouldUpdate(!Globals.clientDrawCellManager.getShouldUpdate());
|
||||
if(ImGui.button("Toggle ClientDrawCellManager updates " + (Globals.clientState.clientDrawCellManager.getShouldUpdate() ? "off" : "on"))){
|
||||
Globals.clientState.clientDrawCellManager.setShouldUpdate(!Globals.clientState.clientDrawCellManager.getShouldUpdate());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,19 +20,19 @@ public class ImGuiStructureTab {
|
||||
* Draws the contents of the structure tab
|
||||
*/
|
||||
protected static void draw(){
|
||||
if(Globals.clientLevelEditorData.getCurrentFab() == null){
|
||||
if(Globals.clientState.clientLevelEditorData.getCurrentFab() == null){
|
||||
ImGui.text("No structure currently being edited");
|
||||
if(ImGui.button("Discover structure")){
|
||||
ClientBlockSelection.selectAllBlocks();
|
||||
AreaSelection area = Globals.cursorState.getAreaSelection();
|
||||
if(area != null){
|
||||
BlockFab blockFab = ClientBlockSelection.convertSelectionToFab();
|
||||
Globals.clientLevelEditorData.setCurrentFab(blockFab);
|
||||
Globals.clientLevelEditorData.setCurrentFabOrigin(area.getRectStart());
|
||||
Globals.clientState.clientLevelEditorData.setCurrentFab(blockFab);
|
||||
Globals.clientState.clientLevelEditorData.setCurrentFabOrigin(area.getRectStart());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BlockFab currentFab = Globals.clientLevelEditorData.getCurrentFab();
|
||||
BlockFab currentFab = Globals.clientState.clientLevelEditorData.getCurrentFab();
|
||||
if(ImGui.button("Convert current selection to room")){
|
||||
AreaSelection currentSelection = Globals.cursorState.getAreaSelection();
|
||||
if(currentSelection != null){
|
||||
@ -50,11 +50,11 @@ public class ImGuiStructureTab {
|
||||
* Draws the details tab
|
||||
*/
|
||||
protected static void drawDetails(){
|
||||
if(Globals.clientLevelEditorData.getCurrentFab() == null){
|
||||
if(Globals.clientState.clientLevelEditorData.getCurrentFab() == null){
|
||||
ImGui.text("Select a fab to show details here");
|
||||
} else {
|
||||
BlockFab currentFab = Globals.clientLevelEditorData.getCurrentFab();
|
||||
ImGui.text("Origin: " + Globals.clientLevelEditorData.getCurrentFabOrigin());
|
||||
BlockFab currentFab = Globals.clientState.clientLevelEditorData.getCurrentFab();
|
||||
ImGui.text("Origin: " + Globals.clientState.clientLevelEditorData.getCurrentFabOrigin());
|
||||
ImGui.text("Dimensions: " + currentFab.getDimensions());
|
||||
BlockFabMetadata fabMetadata = currentFab.getFabMetadata();
|
||||
if(fabMetadata.getAreas() != null){
|
||||
|
||||
@ -52,7 +52,7 @@ public class MenuGeneratorsTerrainEditing {
|
||||
|
||||
//attach scrollable after search input for organzation purposes
|
||||
terrainEditingSidePanelWindow.addChild(VoxelSelectionPanel.createVoxelTypeSelectionPanel((VoxelType type) -> {
|
||||
Globals.clientSelectedVoxelType = type;
|
||||
Globals.clientState.clientSelectedVoxelType = type;
|
||||
}));
|
||||
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,terrainEditingSidePanelWindow);
|
||||
@ -85,7 +85,7 @@ public class MenuGeneratorsTerrainEditing {
|
||||
|
||||
//attach scrollable after search input for organzation purposes
|
||||
entitySelectionWindow.addChild(SpawnSelectionPanel.createEntityTypeSelectionPanel((CommonEntityType type) -> {
|
||||
Globals.selectedSpawntype = type;
|
||||
Globals.clientState.selectedSpawntype = type;
|
||||
}));
|
||||
|
||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,entitySelectionWindow);
|
||||
|
||||
@ -179,8 +179,8 @@ public class MenuGeneratorsMultiplayer {
|
||||
rVal.addChild(Button.createButton("Connect", () -> {
|
||||
NetUtils.setAddress(addressInput.getText());
|
||||
NetUtils.setPort(Integer.parseInt(portInput.getText()));
|
||||
Globals.clientUsername = usernameInput.getText();
|
||||
Globals.clientPassword = AuthenticationManager.getHashedString(passwordInput.getText());
|
||||
Globals.clientState.clientUsername = usernameInput.getText();
|
||||
Globals.clientState.clientPassword = AuthenticationManager.getHashedString(passwordInput.getText());
|
||||
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = false;
|
||||
|
||||
@ -55,9 +55,9 @@ public class MenuWorldSelect {
|
||||
spacer.addChild(Button.createButton(saveName.toUpperCase(), () -> {
|
||||
if(SaveUtils.saveHasWorldFile(saveName.toLowerCase())){
|
||||
//need to log client in
|
||||
Globals.clientUsername = "username";
|
||||
Globals.clientPassword = AuthenticationManager.getHashedString("password");
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME, saveName, Globals.clientUsername, Globals.clientPassword);
|
||||
Globals.clientState.clientUsername = "username";
|
||||
Globals.clientState.clientPassword = AuthenticationManager.getHashedString("password");
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME, saveName, Globals.clientState.clientUsername, Globals.clientState.clientPassword);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
Globals.threadManager.start(serverThread);
|
||||
|
||||
@ -31,9 +31,9 @@ public class ScriptLevelEditorUtils {
|
||||
*/
|
||||
@Export
|
||||
public static void spawnEntity(){
|
||||
if(Globals.selectedSpawntype != null){
|
||||
if(Globals.selectedSpawntype instanceof CreatureData){
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.selectedSpawntype.getId() + "!");
|
||||
if(Globals.clientState.selectedSpawntype != null){
|
||||
if(Globals.clientState.selectedSpawntype instanceof CreatureData){
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.clientState.selectedSpawntype.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
@ -43,9 +43,9 @@ public class ScriptLevelEditorUtils {
|
||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||
}
|
||||
cursorPos = cursorPos.add(cursorVerticalOffset);
|
||||
CreatureUtils.serverSpawnBasicCreature(realm, cursorPos, Globals.selectedSpawntype.getId(), null);
|
||||
} else if(Globals.selectedSpawntype instanceof Item){
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.selectedSpawntype.getId() + "!");
|
||||
CreatureUtils.serverSpawnBasicCreature(realm, cursorPos, Globals.clientState.selectedSpawntype.getId(), null);
|
||||
} else if(Globals.clientState.selectedSpawntype instanceof Item){
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.clientState.selectedSpawntype.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
@ -55,9 +55,9 @@ public class ScriptLevelEditorUtils {
|
||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||
}
|
||||
cursorPos = cursorPos.add(cursorVerticalOffset);
|
||||
ItemUtils.serverSpawnBasicItem(realm, cursorPos, Globals.selectedSpawntype.getId());
|
||||
} else if(Globals.selectedSpawntype instanceof FoliageType){
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.selectedSpawntype.getId() + "!");
|
||||
ItemUtils.serverSpawnBasicItem(realm, cursorPos, Globals.clientState.selectedSpawntype.getId());
|
||||
} else if(Globals.clientState.selectedSpawntype instanceof FoliageType){
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.clientState.selectedSpawntype.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
@ -67,9 +67,9 @@ public class ScriptLevelEditorUtils {
|
||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||
}
|
||||
cursorPos = cursorPos.add(cursorVerticalOffset);
|
||||
FoliageUtils.serverSpawnTreeFoliage(realm, cursorPos, Globals.selectedSpawntype.getId());
|
||||
FoliageUtils.serverSpawnTreeFoliage(realm, cursorPos, Globals.clientState.selectedSpawntype.getId());
|
||||
} else {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.selectedSpawntype.getId() + "!");
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.clientState.selectedSpawntype.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
@ -79,7 +79,7 @@ public class ScriptLevelEditorUtils {
|
||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||
}
|
||||
cursorPos = cursorPos.add(cursorVerticalOffset);
|
||||
CommonEntityUtils.serverSpawnBasicObject(realm, cursorPos, Globals.selectedSpawntype.getId());
|
||||
CommonEntityUtils.serverSpawnBasicObject(realm, cursorPos, Globals.clientState.selectedSpawntype.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,14 +14,10 @@ import electrosphere.audio.movement.MovementAudioService;
|
||||
import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.client.ClientState;
|
||||
import electrosphere.client.block.cells.BlockTextureAtlas;
|
||||
import electrosphere.client.block.cells.ClientBlockCellManager;
|
||||
import electrosphere.client.chemistry.ClientChemistryCollisionCallback;
|
||||
import electrosphere.client.entity.particle.ParticleService;
|
||||
import electrosphere.client.fluid.cells.FluidCellManager;
|
||||
import electrosphere.client.player.ClientPlayerData;
|
||||
import electrosphere.client.scene.ClientLevelEditorData;
|
||||
import electrosphere.client.scene.ClientSceneWrapper;
|
||||
import electrosphere.client.terrain.cells.ClientDrawCellManager;
|
||||
import electrosphere.client.terrain.cells.VoxelTextureAtlas;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.collision.CollisionEngine;
|
||||
@ -32,7 +28,6 @@ import electrosphere.controls.ControlHandler;
|
||||
import electrosphere.controls.MouseCallback;
|
||||
import electrosphere.controls.ScrollCallback;
|
||||
import electrosphere.controls.cursor.CursorState;
|
||||
import electrosphere.data.common.CommonEntityType;
|
||||
import electrosphere.data.particle.ParticleDefinition;
|
||||
import electrosphere.data.settings.UserSettings;
|
||||
import electrosphere.data.voxel.VoxelType;
|
||||
@ -52,9 +47,7 @@ import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.net.config.NetConfig;
|
||||
import electrosphere.net.monitor.NetMonitor;
|
||||
import electrosphere.net.server.Server;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.net.server.player.PlayerManager;
|
||||
import electrosphere.net.synchronization.client.ClientSynchronizationManager;
|
||||
import electrosphere.net.synchronization.server.EntityValueTrackingService;
|
||||
import electrosphere.net.synchronization.server.ServerSynchronizationManager;
|
||||
import electrosphere.renderer.RenderUtils;
|
||||
@ -236,9 +229,6 @@ public class Globals {
|
||||
//Player manager
|
||||
//
|
||||
public static PlayerManager playerManager;
|
||||
public static Player clientPlayer;
|
||||
public static String clientUsername;
|
||||
public static String clientPassword;
|
||||
|
||||
//
|
||||
//Generic OpenGL Statements
|
||||
@ -332,14 +322,8 @@ public class Globals {
|
||||
//instanced actor manager
|
||||
public static InstanceManager clientInstanceManager = new InstanceManager();
|
||||
|
||||
//client player data
|
||||
public static ClientPlayerData clientPlayerData = new ClientPlayerData();
|
||||
|
||||
//chunk stuff
|
||||
//draw cell manager
|
||||
public static ClientDrawCellManager clientDrawCellManager;
|
||||
public static VoxelTextureAtlas voxelTextureAtlas = new VoxelTextureAtlas();
|
||||
public static ClientBlockCellManager clientBlockCellManager;
|
||||
public static BlockTextureAtlas blockTextureAtlas = new BlockTextureAtlas();
|
||||
|
||||
//fluid cell manager
|
||||
@ -364,9 +348,6 @@ public class Globals {
|
||||
|
||||
//collision world data
|
||||
public static CollisionWorldData commonWorldData;
|
||||
|
||||
//client level editor data management
|
||||
public static ClientLevelEditorData clientLevelEditorData = new ClientLevelEditorData();
|
||||
|
||||
|
||||
//the player camera entity
|
||||
@ -386,11 +367,6 @@ public class Globals {
|
||||
* The target of the interaction
|
||||
*/
|
||||
public static Entity interactionTarget = null;
|
||||
|
||||
//client current selected voxel type
|
||||
public static VoxelType clientSelectedVoxelType = null;
|
||||
//the selected type of entity to spawn
|
||||
public static CommonEntityType selectedSpawntype = null;
|
||||
|
||||
//skybox entity
|
||||
public static Entity skybox;
|
||||
@ -495,7 +471,7 @@ public class Globals {
|
||||
|
||||
//
|
||||
//Values that depend on the loaded config
|
||||
Globals.clientSelectedVoxelType = (VoxelType)gameConfigCurrent.getVoxelData().getTypes().toArray()[1];
|
||||
Globals.clientState.clientSelectedVoxelType = (VoxelType)gameConfigCurrent.getVoxelData().getTypes().toArray()[1];
|
||||
//player manager
|
||||
playerManager = new PlayerManager();
|
||||
//behavior tree tracking service
|
||||
@ -504,8 +480,6 @@ public class Globals {
|
||||
if(Globals.userSettings.getNetRunNetMonitor()){
|
||||
netMonitor = new NetMonitor();
|
||||
}
|
||||
//client synchronization manager
|
||||
Globals.clientState.clientSynchronizationManager = new ClientSynchronizationManager();
|
||||
//profiler
|
||||
profiler = new Profiler();
|
||||
Globals.serverSynchronizationManager = new ServerSynchronizationManager();
|
||||
@ -689,12 +663,10 @@ public class Globals {
|
||||
Globals.playerEntity = null;
|
||||
Globals.playerCamera = null;
|
||||
Globals.firstPersonEntity = null;
|
||||
Globals.clientPlayer = null;
|
||||
Globals.playerManager = new PlayerManager();
|
||||
Globals.clientState.clientScene = new Scene();
|
||||
Globals.clientState.clientSceneWrapper = new ClientSceneWrapper(Globals.clientState.clientScene, new CollisionEngine(), CollisionEngine.create(new ClientChemistryCollisionCallback()), new CollisionEngine());
|
||||
Globals.clientState = new ClientState();
|
||||
Globals.clientState.clientSynchronizationManager = new ClientSynchronizationManager();
|
||||
Globals.server = null;
|
||||
Globals.serverSynchronizationManager = new ServerSynchronizationManager();
|
||||
if(Globals.aiManager != null){
|
||||
|
||||
@ -77,8 +77,8 @@ public class ChunkGenerationTestLoading {
|
||||
//init authentication
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
Globals.clientUsername = "leveleditor";
|
||||
Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor");
|
||||
Globals.clientState.clientUsername = "leveleditor";
|
||||
Globals.clientState.clientPassword = AuthenticationManager.getHashedString("leveleditor");
|
||||
ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true);
|
||||
//wait for player object creation
|
||||
while(Globals.playerManager.getPlayers().size() < 1 || !Globals.clientState.clientConnection.isInitialized()){
|
||||
|
||||
@ -336,14 +336,14 @@ public class ClientLoading {
|
||||
}
|
||||
//initialize draw cell manager
|
||||
// Globals.drawCellManager = new DrawCellManager(Globals.clientTerrainManager, 0, 0, 0);
|
||||
Globals.clientDrawCellManager = new ClientDrawCellManager(Globals.voxelTextureAtlas, Globals.clientState.clientWorldData.getWorldDiscreteSize());
|
||||
Globals.clientState.clientDrawCellManager = new ClientDrawCellManager(Globals.voxelTextureAtlas, Globals.clientState.clientWorldData.getWorldDiscreteSize());
|
||||
//Alerts the client simulation that it should start loading terrain
|
||||
Globals.clientState.clientSimulation.setLoadingTerrain(true);
|
||||
//wait for all the terrain data to arrive
|
||||
int i = 0;
|
||||
while(
|
||||
blockForInit &&
|
||||
!Globals.clientDrawCellManager.isInitialized() &&
|
||||
!Globals.clientState.clientDrawCellManager.isInitialized() &&
|
||||
Globals.threadManager.shouldKeepRunning()
|
||||
){
|
||||
i++;
|
||||
@ -420,14 +420,14 @@ public class ClientLoading {
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
}
|
||||
Globals.clientBlockCellManager = new ClientBlockCellManager(Globals.blockTextureAtlas, Globals.clientState.clientWorldData.getWorldDiscreteSize());
|
||||
Globals.clientState.clientBlockCellManager = new ClientBlockCellManager(Globals.blockTextureAtlas, Globals.clientState.clientWorldData.getWorldDiscreteSize());
|
||||
//Alerts the client simulation that it should start loading blocks
|
||||
Globals.clientState.clientSimulation.setLoadingTerrain(true);
|
||||
//wait for all the block data to arrive
|
||||
int i = 0;
|
||||
while(
|
||||
blockForInit &&
|
||||
!Globals.clientBlockCellManager.isInitialized() &&
|
||||
!Globals.clientState.clientBlockCellManager.isInitialized() &&
|
||||
Globals.threadManager.shouldKeepRunning()
|
||||
){
|
||||
i++;
|
||||
|
||||
@ -45,8 +45,8 @@ public class DebugSPWorldLoading {
|
||||
//init authentication
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
Globals.clientUsername = "testuser";
|
||||
Globals.clientPassword = AuthenticationManager.getHashedString("testpass");
|
||||
Globals.clientState.clientUsername = "testuser";
|
||||
Globals.clientState.clientPassword = AuthenticationManager.getHashedString("testpass");
|
||||
ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true);
|
||||
//wait for player object creation
|
||||
while(Globals.playerManager.getPlayers().size() < 1){
|
||||
|
||||
@ -73,8 +73,8 @@ public class LevelEditorLoading {
|
||||
//init authentication
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
Globals.clientUsername = "leveleditor";
|
||||
Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor");
|
||||
Globals.clientState.clientUsername = "leveleditor";
|
||||
Globals.clientState.clientPassword = AuthenticationManager.getHashedString("leveleditor");
|
||||
ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true);
|
||||
//wait for player object creation
|
||||
while(Globals.playerManager.getPlayers().size() < 1 || !Globals.clientState.clientConnection.isInitialized()){
|
||||
|
||||
@ -43,8 +43,8 @@ public class LevelLoading {
|
||||
//init authentication
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
Globals.clientUsername = "leveleditor";
|
||||
Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor");
|
||||
Globals.clientState.clientUsername = "leveleditor";
|
||||
Globals.clientState.clientPassword = AuthenticationManager.getHashedString("leveleditor");
|
||||
ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true);
|
||||
//wait for player object creation
|
||||
while(Globals.playerManager.getPlayers().size() < 1){
|
||||
|
||||
@ -49,8 +49,8 @@ public class ServerLoading {
|
||||
//init authentication
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
Globals.clientUsername = username;
|
||||
Globals.clientPassword = password;
|
||||
Globals.clientState.clientUsername = username;
|
||||
Globals.clientState.clientPassword = password;
|
||||
//initialize the "real" objects simulation
|
||||
LoadingUtils.initMicroSimulation();
|
||||
//init game specific stuff (ie different skybox colors)
|
||||
|
||||
@ -44,8 +44,8 @@ public class ViewportLoading {
|
||||
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT);
|
||||
ViewportLoading.initInMemoryDB();
|
||||
LoadingUtils.initAuthenticationManager(true);
|
||||
Globals.clientUsername = "leveleditor";
|
||||
Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor");
|
||||
Globals.clientState.clientUsername = "leveleditor";
|
||||
Globals.clientState.clientPassword = AuthenticationManager.getHashedString("leveleditor");
|
||||
LoadingUtils.initLocalConnection(true);
|
||||
//wait for player object creation
|
||||
while(Globals.playerManager.getPlayers().size() < 1){
|
||||
|
||||
@ -63,7 +63,7 @@ public class ClientPhysicsSyncTree implements BehaviorTree {
|
||||
//bust distance caches if this is the player's entity and we've traveled a long distance suddenly
|
||||
if(parent == Globals.playerEntity){
|
||||
if(position.distance(EntityUtils.getPosition(parent)) > FoliageCellManager.TELEPORT_DISTANCE){
|
||||
Globals.clientDrawCellManager.bustDistanceCache();
|
||||
Globals.clientState.clientDrawCellManager.bustDistanceCache();
|
||||
Globals.clientState.foliageCellManager.bustDistanceCache();
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,11 +18,11 @@ public class AuthProtocol implements ClientProtocolTemplate<AuthMessage> {
|
||||
case AUTHREQUEST:
|
||||
//Try login
|
||||
//TODO: actually get user/pass
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(AuthMessage.constructAuthDetailsMessage(Globals.clientUsername,Globals.clientPassword));
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(AuthMessage.constructAuthDetailsMessage(Globals.clientState.clientUsername,Globals.clientState.clientPassword));
|
||||
break;
|
||||
case AUTHSUCCESS:
|
||||
//clean password hash from memory
|
||||
Globals.clientPassword = "";
|
||||
Globals.clientState.clientPassword = "";
|
||||
//request playable races
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(LoreMessage.constructRequestRacesMessage());
|
||||
//request characters available to this player
|
||||
|
||||
@ -187,7 +187,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
|
||||
String creatureTypeRaw = CreatureUtils.getType(target);
|
||||
CreatureData creatureType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(creatureTypeRaw);
|
||||
ViewModelData viewModelData = creatureType.getViewModelData();
|
||||
if(Globals.clientPlayer != null && message.getpropertyValue() == Globals.clientPlayer.getId()){
|
||||
if(Globals.clientState.clientPlayer != null && message.getpropertyValue() == Globals.clientState.clientPlayer.getId()){
|
||||
LoggerInterface.loggerNetworking.DEBUG("Set this player's entity id!");
|
||||
Globals.clientCharacterID = message.getentityID();
|
||||
Globals.playerEntity = target;
|
||||
|
||||
@ -23,11 +23,11 @@ public class PlayerProtocol implements ClientProtocolTemplate<PlayerMessage> {
|
||||
Globals.profiler.beginCpuSample("PlayerProtocol.handlePlayerMessage");
|
||||
switch(message.getMessageSubtype()){
|
||||
case SET_ID:
|
||||
Globals.clientPlayer = new Player(message.getplayerID(), Player.CLIENT_DB_ID);
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Player ID is " + Globals.clientPlayer.getId());
|
||||
Globals.clientState.clientPlayer = new Player(message.getplayerID(), Player.CLIENT_DB_ID);
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Player ID is " + Globals.clientState.clientPlayer.getId());
|
||||
break;
|
||||
case SETINITIALDISCRETEPOSITION: {
|
||||
Globals.clientPlayerData.setWorldPos(new Vector3i(message.getinitialDiscretePositionX(), message.getinitialDiscretePositionY(), message.getinitialDiscretePositionZ()));
|
||||
Globals.clientState.clientPlayerData.setWorldPos(new Vector3i(message.getinitialDiscretePositionX(), message.getinitialDiscretePositionY(), message.getinitialDiscretePositionZ()));
|
||||
} break;
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
|
||||
@ -117,7 +117,7 @@ public class TerrainProtocol implements ClientProtocolTemplate<TerrainMessage> {
|
||||
){
|
||||
//
|
||||
//mark terrain chunk for update
|
||||
Globals.clientDrawCellManager.markUpdateable(worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z);
|
||||
Globals.clientState.clientDrawCellManager.markUpdateable(worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z);
|
||||
|
||||
//
|
||||
//update foliage manager
|
||||
@ -229,8 +229,8 @@ public class TerrainProtocol implements ClientProtocolTemplate<TerrainMessage> {
|
||||
){
|
||||
//
|
||||
//mark terrain chunk for update
|
||||
Globals.clientBlockCellManager.markUpdateable(worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z);
|
||||
Globals.clientBlockCellManager.markHomogenous(worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z, false);
|
||||
Globals.clientState.clientBlockCellManager.markUpdateable(worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z);
|
||||
Globals.clientState.clientBlockCellManager.markHomogenous(worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z, false);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
@ -155,7 +155,7 @@ public class Server implements Runnable {
|
||||
public void broadcastMessage(NetworkMessage message){
|
||||
connectListLock.acquireUninterruptibly();
|
||||
for(ServerConnectionHandler client : activeConnections){
|
||||
if(Globals.clientPlayer == null || client.playerID != Globals.clientPlayer.getId()){
|
||||
if(Globals.clientState.clientPlayer == null || client.playerID != Globals.clientState.clientPlayer.getId()){
|
||||
client.addMessagetoOutgoingQueue(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,8 +25,8 @@ public class AuthProtocol implements ServerProtocolTemplate<AuthMessage> {
|
||||
Player newPlayer = new Player(connectionHandler, loginId);
|
||||
Globals.playerManager.registerPlayer(newPlayer);
|
||||
//there is a race condition here where if a local non-server client connects first then it breaks
|
||||
if(connectionHandler.getIPAddress().contains("127.0.0.1") && Globals.RUN_CLIENT == true && Globals.clientPlayer == null){
|
||||
Globals.clientPlayer = newPlayer;
|
||||
if(connectionHandler.getIPAddress().contains("127.0.0.1") && Globals.RUN_CLIENT == true && Globals.clientState.clientPlayer == null){
|
||||
Globals.clientState.clientPlayer = newPlayer;
|
||||
}
|
||||
connectionHandler.addMessagetoOutgoingQueue(PlayerMessage.constructSet_IDMessage(connectionHandler.getPlayerId()));
|
||||
} else {
|
||||
|
||||
@ -127,7 +127,7 @@ public class ScriptEngine extends SignalServiceImpl {
|
||||
*/
|
||||
public static final Object[][] hostSingletops = new Object[][]{
|
||||
{"timekeeper",Globals.timekeeper},
|
||||
{"currentPlayer",Globals.clientPlayer},
|
||||
{"currentPlayer",Globals.clientState.clientPlayer},
|
||||
{"loggerScripts",LoggerInterface.loggerScripts},
|
||||
};
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ public class ServerDataCell {
|
||||
*/
|
||||
public void broadcastNetworkMessage(NetworkMessage message){
|
||||
for(Player player : activePlayers){
|
||||
if(player != Globals.clientPlayer){
|
||||
if(player != Globals.clientState.clientPlayer){
|
||||
player.addMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user