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