83 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package electrosphere.engine.loadingthreads;
 | |
| 
 | |
| import java.util.concurrent.TimeUnit;
 | |
| 
 | |
| import electrosphere.auth.AuthenticationManager;
 | |
| import electrosphere.engine.Globals;
 | |
| import electrosphere.entity.scene.SceneGenerator;
 | |
| import electrosphere.logger.LoggerInterface;
 | |
| import electrosphere.menu.MenuGenerators;
 | |
| import electrosphere.menu.WindowStrings;
 | |
| import electrosphere.menu.WindowUtils;
 | |
| import electrosphere.net.parser.net.message.TerrainMessage;
 | |
| import electrosphere.net.server.ServerConnectionHandler;
 | |
| import electrosphere.renderer.ui.elements.Window;
 | |
| import electrosphere.server.saves.SaveUtils;
 | |
| 
 | |
| public class DebugSPWorldLoading {
 | |
|     
 | |
| 
 | |
|     protected static void loadDebugSPWorld(Object[] params){
 | |
|         Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
 | |
|         //show loading
 | |
|         WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
 | |
|         WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
 | |
|         loadingWindow.setVisible(true);
 | |
| 
 | |
|         String saveName = "random_sp_world";
 | |
|         if(!SaveUtils.getSaves().contains(saveName)){
 | |
|             //
 | |
|             //the juicy server GENERATION part
 | |
|             //
 | |
|             //init save structure
 | |
|             SaveUtils.createOrOverwriteSave(saveName, SceneGenerator.createProceduralSceneFile(saveName));
 | |
|         }
 | |
|         //load just-created save
 | |
|         SaveUtils.loadSave(saveName, false);
 | |
|         //initialize the "virtual" objects simulation
 | |
|         LoadingUtils.initMacroSimulation();
 | |
| 
 | |
| 
 | |
|         LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT);
 | |
|         //init authentication
 | |
|         LoadingUtils.initAuthenticationManager();
 | |
|         //initialize the local connection
 | |
|         Globals.clientUsername = "testuser";
 | |
|         Globals.clientPassword = AuthenticationManager.getHashedString("testpass");
 | |
|         ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection();
 | |
|         //wait for player object creation
 | |
|         while(Globals.playerManager.getPlayers().size() < 1){
 | |
|             try {
 | |
|                 TimeUnit.MILLISECONDS.sleep(10);
 | |
|             } catch (InterruptedException e) {
 | |
|                 e.printStackTrace();
 | |
|             }
 | |
|         }
 | |
|         //initialize the "real" objects simulation
 | |
|         LoadingUtils.initMicroSimulation();
 | |
|         //init game specific stuff (ie different skybox colors)
 | |
|         LoadingUtils.initGameGraphicalEntities();
 | |
|         //set simulations to ready if they exist
 | |
|         LoadingUtils.setSimulationsToReady();
 | |
|         //log
 | |
|         LoggerInterface.loggerEngine.INFO("[Server]Finished loading main world");
 | |
| 
 | |
|         //the less juicy client setup part
 | |
|         while(Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces().size() == 0){
 | |
|             try {
 | |
|                 TimeUnit.MILLISECONDS.sleep(5);
 | |
|             } catch (InterruptedException ex) {}
 | |
|         }
 | |
|         
 | |
|         //spawn player character
 | |
|         LoadingUtils.spawnLocalPlayerTestEntity(serverPlayerConnection);
 | |
| 
 | |
|         //request terrain data
 | |
|         Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
 | |
| 
 | |
|         //Run client startup process
 | |
|         ClientLoading.loadClientWorld(params);
 | |
|     }
 | |
| 
 | |
| }
 |