move thread manager into engineState
This commit is contained in:
parent
70f76202b1
commit
038da702e7
@ -1816,6 +1816,8 @@ Move realmManager to serverState
|
||||
Move characterService to serverState
|
||||
Move entityValueTrackingService to serverState
|
||||
Move playerManager to serverState
|
||||
Create EngineState global
|
||||
Move threadManager into engineState
|
||||
|
||||
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ public class MenuCharacterCreation {
|
||||
Div charNameContainer = Div.createRow(Button.createButton(buttonTitle, () -> {
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage(description.getId()));
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
|
||||
Globals.threadManager.start(new LoadingThread(LoadingThreadType.CLIENT_WORLD));
|
||||
Globals.engineState.threadManager.start(new LoadingThread(LoadingThreadType.CLIENT_WORLD));
|
||||
}));
|
||||
selectContainer.addChild(charNameContainer);
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LEVEL, saveName);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
Globals.threadManager.start(loadingThread);
|
||||
Globals.engineState.threadManager.start(loadingThread);
|
||||
}).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE);
|
||||
|
||||
//
|
||||
@ -143,7 +143,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
Button editButton = Button.createButton("Edit", () -> {
|
||||
//launch level editor
|
||||
LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LEVEL_EDITOR, saveName);
|
||||
Globals.threadManager.start(loadingThread);
|
||||
Globals.engineState.threadManager.start(loadingThread);
|
||||
}).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE);
|
||||
|
||||
//create row
|
||||
@ -282,7 +282,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
Button createButton = Button.createButton("Create Level", () -> {
|
||||
//launch level editor
|
||||
LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LEVEL_EDITOR, inFlightLevel);
|
||||
Globals.threadManager.start(loadingThread);
|
||||
Globals.engineState.threadManager.start(loadingThread);
|
||||
}).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE);
|
||||
createButton.setAlignSelf(YogaAlignment.Center);
|
||||
rVal.addChild(createButton);
|
||||
|
||||
@ -91,8 +91,8 @@ public class MenuGeneratorsMultiplayer {
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
Globals.threadManager.start(serverThread);
|
||||
Globals.threadManager.start(clientThread);
|
||||
Globals.engineState.threadManager.start(serverThread);
|
||||
Globals.engineState.threadManager.start(clientThread);
|
||||
}));
|
||||
|
||||
//button (join)
|
||||
@ -184,7 +184,7 @@ public class MenuGeneratorsMultiplayer {
|
||||
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = false;
|
||||
Globals.threadManager.start(clientThread);
|
||||
Globals.engineState.threadManager.start(clientThread);
|
||||
}));
|
||||
|
||||
//button (back)
|
||||
|
||||
@ -106,7 +106,7 @@ public class MenuGeneratorsTitleMenu {
|
||||
//button (Viewport Test)
|
||||
{
|
||||
Button button = Button.createButtonCentered("Viewport Test", 1.0f, () -> {
|
||||
Globals.threadManager.start(new LoadingThread(LoadingThreadType.LOAD_VIEWPORT));
|
||||
Globals.engineState.threadManager.start(new LoadingThread(LoadingThreadType.LOAD_VIEWPORT));
|
||||
}).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE);
|
||||
button.setMarginTop(BUTTON_SPACING);
|
||||
optionPanel.addChild(button);
|
||||
|
||||
@ -60,7 +60,7 @@ public class MenuWorldSelect {
|
||||
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);
|
||||
Globals.engineState.threadManager.start(serverThread);
|
||||
} else {
|
||||
SaveUtils.loadSave(saveName.toLowerCase(), false);
|
||||
WindowUtils.replaceMainMenuContents(MenuWorldSelect.createSaveCreationMenu());
|
||||
|
||||
15
src/main/java/electrosphere/engine/EngineState.java
Normal file
15
src/main/java/electrosphere/engine/EngineState.java
Normal file
@ -0,0 +1,15 @@
|
||||
package electrosphere.engine;
|
||||
|
||||
import electrosphere.engine.threads.ThreadManager;
|
||||
|
||||
/**
|
||||
* State of the engine
|
||||
*/
|
||||
public class EngineState {
|
||||
|
||||
/**
|
||||
* The thread manager
|
||||
*/
|
||||
public final ThreadManager threadManager = new ThreadManager();
|
||||
|
||||
}
|
||||
@ -36,7 +36,6 @@ import electrosphere.engine.profiler.Profiler;
|
||||
import electrosphere.engine.service.ServiceManager;
|
||||
import electrosphere.engine.signal.SignalSystem;
|
||||
import electrosphere.engine.signal.sync.MainThreadSignalService;
|
||||
import electrosphere.engine.threads.ThreadManager;
|
||||
import electrosphere.engine.time.Timekeeper;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.net.config.NetConfig;
|
||||
@ -74,11 +73,6 @@ public class Globals {
|
||||
//
|
||||
public static String javaPID;
|
||||
|
||||
//
|
||||
//Thread manager
|
||||
//
|
||||
public static ThreadManager threadManager;
|
||||
|
||||
//
|
||||
//Service manager
|
||||
//
|
||||
@ -98,6 +92,21 @@ public class Globals {
|
||||
//Timekeeper
|
||||
//
|
||||
public static Timekeeper timekeeper;
|
||||
|
||||
/**
|
||||
* State for the engine
|
||||
*/
|
||||
public static EngineState engineState;
|
||||
|
||||
/**
|
||||
* State for the client
|
||||
*/
|
||||
public static ClientState clientState;
|
||||
|
||||
/**
|
||||
* State for the server
|
||||
*/
|
||||
public static ServerState serverState;
|
||||
|
||||
//
|
||||
//Rendering Engine
|
||||
@ -311,16 +320,6 @@ public class Globals {
|
||||
|
||||
//collision world data
|
||||
public static CollisionWorldData commonWorldData;
|
||||
|
||||
/**
|
||||
* State for the client
|
||||
*/
|
||||
public static ClientState clientState = new ClientState();
|
||||
|
||||
/**
|
||||
* State for the server
|
||||
*/
|
||||
public static ServerState serverState = new ServerState();
|
||||
|
||||
|
||||
|
||||
@ -368,8 +367,8 @@ public class Globals {
|
||||
UserSettings.loadUserSettings();
|
||||
//timekeeper
|
||||
timekeeper = new Timekeeper();
|
||||
Globals.threadManager = new ThreadManager();
|
||||
Globals.threadManager.init();
|
||||
Globals.engineState = new EngineState();
|
||||
Globals.engineState.threadManager.init();
|
||||
|
||||
//render flags
|
||||
RENDER_FLAG_RENDER_SHADOW_MAP = false;
|
||||
@ -590,26 +589,29 @@ public class Globals {
|
||||
* Unloads scene
|
||||
*/
|
||||
public static void unloadScene(){
|
||||
Globals.serverState.aiManager.shutdown();
|
||||
Globals.serverState.realmManager.reset();
|
||||
if(Globals.serverState != null){
|
||||
Globals.serverState.aiManager.shutdown();
|
||||
Globals.serverState.realmManager.reset();
|
||||
}
|
||||
Globals.dbController.disconnect();
|
||||
Globals.serviceManager.unloadScene();
|
||||
|
||||
Globals.clientState = new ClientState();
|
||||
Globals.serverState = new ServerState();
|
||||
if(Globals.serviceManager != null){
|
||||
Globals.serverState.characterService = (CharacterService)Globals.serviceManager.registerService(new CharacterService());
|
||||
}
|
||||
Globals.dbController.disconnect();
|
||||
Globals.serviceManager.unloadScene();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets global values
|
||||
*/
|
||||
public static void resetGlobals(){
|
||||
Globals.unloadScene();
|
||||
if(Globals.serverState != null && Globals.serverState.aiManager != null){
|
||||
if(Globals.serverState != null){
|
||||
Globals.serverState.aiManager.shutdown();
|
||||
Globals.serverState.realmManager.reset();
|
||||
}
|
||||
Globals.dbController.disconnect();
|
||||
//
|
||||
//Actual globals to destroy
|
||||
Globals.assetManager = null;
|
||||
@ -617,8 +619,8 @@ public class Globals {
|
||||
Globals.clientState = null;
|
||||
Globals.serverState = null;
|
||||
Globals.audioEngine = null;
|
||||
Globals.engineState = null;
|
||||
Globals.renderingEngine = null;
|
||||
Globals.threadManager = null;
|
||||
Globals.signalSystem = null;
|
||||
Globals.serviceManager = null;
|
||||
Globals.fileWatcherService = null;
|
||||
|
||||
@ -112,7 +112,7 @@ public class Main {
|
||||
|
||||
//init scripting engine
|
||||
if(Globals.RUN_SCRIPTS){
|
||||
Globals.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
|
||||
Globals.engineState.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
|
||||
}
|
||||
|
||||
//controls
|
||||
@ -138,7 +138,7 @@ public class Main {
|
||||
Globals.controlHandler.hintUpdateControlState(ControlsState.TITLE_MENU);
|
||||
|
||||
//start initial asset loading
|
||||
Globals.threadManager.start(new LoadingThread(LoadingThreadType.INIT_ASSETS));
|
||||
Globals.engineState.threadManager.start(new LoadingThread(LoadingThreadType.INIT_ASSETS));
|
||||
}
|
||||
|
||||
//Sets a hook that fires when the engine process stops
|
||||
@ -165,10 +165,10 @@ public class Main {
|
||||
LoggerInterface.loggerStartup.INFO("Fire off loading thread");
|
||||
if(Globals.RUN_DEMO){
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.DEMO_MENU);
|
||||
Globals.threadManager.start(serverThread);
|
||||
Globals.engineState.threadManager.start(serverThread);
|
||||
} else if(Globals.RUN_CLIENT){
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.TITLE_MENU);
|
||||
Globals.threadManager.start(serverThread);
|
||||
Globals.engineState.threadManager.start(serverThread);
|
||||
} else {
|
||||
throw new IllegalStateException("Need to add handling for only running server again");
|
||||
}
|
||||
@ -208,7 +208,7 @@ public class Main {
|
||||
//Update timekeeper, thread manager, and process all main thread signals
|
||||
//
|
||||
Globals.timekeeper.update();
|
||||
Globals.threadManager.update();
|
||||
Globals.engineState.threadManager.update();
|
||||
|
||||
|
||||
|
||||
@ -431,8 +431,8 @@ public class Main {
|
||||
Globals.renderingEngine.destroy();
|
||||
}
|
||||
//used to signal threads to stop
|
||||
if(Globals.threadManager != null){
|
||||
Globals.threadManager.close();
|
||||
if(Globals.engineState != null && Globals.engineState.threadManager != null){
|
||||
Globals.engineState.threadManager.close();
|
||||
}
|
||||
//shut down audio engine
|
||||
if(Globals.audioEngine != null && Globals.audioEngine.initialized()){
|
||||
|
||||
@ -205,7 +205,7 @@ public class ClientLoading {
|
||||
//start client networking
|
||||
if(Globals.RUN_CLIENT){
|
||||
Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
|
||||
Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
|
||||
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ public class ClientLoading {
|
||||
static void initDrawCellManager(boolean blockForInit){
|
||||
int iterations = 0;
|
||||
WindowUtils.updateLoadingWindow("WAITING ON WORLD DATA");
|
||||
while(blockForInit && (Globals.clientState.clientWorldData == null || InitialAssetLoading.atlasQueuedTexture == null || !InitialAssetLoading.atlasQueuedTexture.hasLoaded()) && Globals.threadManager.shouldKeepRunning()){
|
||||
while(blockForInit && (Globals.clientState.clientWorldData == null || InitialAssetLoading.atlasQueuedTexture == null || !InitialAssetLoading.atlasQueuedTexture.hasLoaded()) && Globals.engineState.threadManager.shouldKeepRunning()){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10);
|
||||
iterations++;
|
||||
@ -344,7 +344,7 @@ public class ClientLoading {
|
||||
while(
|
||||
blockForInit &&
|
||||
!Globals.clientState.clientDrawCellManager.isInitialized() &&
|
||||
Globals.threadManager.shouldKeepRunning()
|
||||
Globals.engineState.threadManager.shouldKeepRunning()
|
||||
){
|
||||
i++;
|
||||
if(i % DRAW_CELL_UPDATE_RATE == 0){
|
||||
@ -366,7 +366,7 @@ public class ClientLoading {
|
||||
|
||||
//wait for world data
|
||||
WindowUtils.updateLoadingWindow("WAITING ON WORLD DATA");
|
||||
while(blockForInit && Globals.clientState.clientWorldData == null && Globals.threadManager.shouldKeepRunning()){
|
||||
while(blockForInit && Globals.clientState.clientWorldData == null && Globals.engineState.threadManager.shouldKeepRunning()){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10);
|
||||
} catch (InterruptedException ex) {
|
||||
@ -380,7 +380,7 @@ public class ClientLoading {
|
||||
|
||||
//wait for all the terrain data to arrive
|
||||
WindowUtils.updateLoadingWindow("REQUESTING FLUID CHUNKS FROM SERVER (" + Globals.fluidCellManager.getUnrequestedSize() + ")");
|
||||
while(blockForInit && Globals.fluidCellManager.containsUnrequestedCell() && Globals.threadManager.shouldKeepRunning() && Globals.RUN_FLUIDS){
|
||||
while(blockForInit && Globals.fluidCellManager.containsUnrequestedCell() && Globals.engineState.threadManager.shouldKeepRunning() && Globals.RUN_FLUIDS){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10);
|
||||
} catch (InterruptedException ex) {
|
||||
@ -406,7 +406,7 @@ public class ClientLoading {
|
||||
static void initBlockCellManager(boolean blockForInit){
|
||||
int iterations = 0;
|
||||
WindowUtils.updateLoadingWindow("WAITING ON WORLD DATA");
|
||||
while(blockForInit && (Globals.clientState.clientWorldData == null || InitialAssetLoading.atlasQueuedTexture == null || !InitialAssetLoading.atlasQueuedTexture.hasLoaded()) && Globals.threadManager.shouldKeepRunning()){
|
||||
while(blockForInit && (Globals.clientState.clientWorldData == null || InitialAssetLoading.atlasQueuedTexture == null || !InitialAssetLoading.atlasQueuedTexture.hasLoaded()) && Globals.engineState.threadManager.shouldKeepRunning()){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10);
|
||||
iterations++;
|
||||
@ -428,7 +428,7 @@ public class ClientLoading {
|
||||
while(
|
||||
blockForInit &&
|
||||
!Globals.clientState.clientBlockCellManager.isInitialized() &&
|
||||
Globals.threadManager.shouldKeepRunning()
|
||||
Globals.engineState.threadManager.shouldKeepRunning()
|
||||
){
|
||||
i++;
|
||||
if(i % DRAW_CELL_UPDATE_RATE == 0){
|
||||
|
||||
@ -52,7 +52,7 @@ public class LoadingUtils {
|
||||
if(Globals.RUN_SERVER){
|
||||
Globals.serverState.server = new Server(NetUtils.getPort());
|
||||
Thread serverThread = new Thread(Globals.serverState.server);
|
||||
Globals.threadManager.start(ThreadLabel.NETWORKING_SERVER, serverThread);
|
||||
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_SERVER, serverThread);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class LoadingUtils {
|
||||
//start client networking
|
||||
if(Globals.RUN_CLIENT){
|
||||
Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
|
||||
Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
|
||||
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public class LoadingUtils {
|
||||
rVal = Globals.serverState.server.addLocalPlayer(serverInput, serverOutput);
|
||||
//start client communication thread
|
||||
Globals.clientState.clientConnection = new ClientNetworking(clientInput,clientOutput);
|
||||
Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
|
||||
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
|
||||
} catch (IOException e) {
|
||||
LoggerInterface.loggerNetworking.ERROR(e);
|
||||
}
|
||||
|
||||
@ -35,10 +35,10 @@ public class MainMenuLoading {
|
||||
MainMenuLoading.resetClientState();
|
||||
MainMenuLoading.resetServerState();
|
||||
Globals.unloadScene();
|
||||
Globals.threadManager.interruptLabel(ThreadLabel.NETWORKING_CLIENT);
|
||||
Globals.threadManager.interruptLabel(ThreadLabel.NETWORKING_SERVER);
|
||||
Globals.threadManager.awaitThreadClose(ThreadLabel.NETWORKING_CLIENT);
|
||||
Globals.threadManager.awaitThreadClose(ThreadLabel.NETWORKING_SERVER);
|
||||
Globals.engineState.threadManager.interruptLabel(ThreadLabel.NETWORKING_CLIENT);
|
||||
Globals.engineState.threadManager.interruptLabel(ThreadLabel.NETWORKING_SERVER);
|
||||
Globals.engineState.threadManager.awaitThreadClose(ThreadLabel.NETWORKING_CLIENT);
|
||||
Globals.engineState.threadManager.awaitThreadClose(ThreadLabel.NETWORKING_SERVER);
|
||||
|
||||
//
|
||||
//reveal in game main menu
|
||||
|
||||
@ -178,7 +178,7 @@ public class ClientNetworking implements Runnable {
|
||||
|
||||
//start parsing messages
|
||||
initialized = true;
|
||||
while(Globals.threadManager.shouldKeepRunning() && !this.shouldDisconnect){
|
||||
while(Globals.engineState.threadManager.shouldKeepRunning() && !this.shouldDisconnect){
|
||||
|
||||
//
|
||||
//attempt poll incoming messages
|
||||
|
||||
@ -31,7 +31,7 @@ public class CharacterProtocol implements ClientProtocolTemplate<CharacterMessag
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage(electrosphere.net.server.protocol.CharacterProtocol.SPAWN_EXISTING_TEMPLATE + ""));
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
|
||||
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CLIENT_WORLD);
|
||||
Globals.threadManager.start(clientThread);
|
||||
Globals.engineState.threadManager.start(clientThread);
|
||||
} break;
|
||||
case RESPONSECHARACTERLIST: {
|
||||
Globals.clientState.clientCharacterManager.setCharacterList(new Gson().fromJson(message.getdata(), ClientCharacterListDTO.class));
|
||||
|
||||
@ -95,7 +95,7 @@ public class Server implements Runnable {
|
||||
} catch (IOException ex) {
|
||||
LoggerInterface.loggerNetworking.ERROR("Failed to start server socket!",ex);
|
||||
}
|
||||
while(Globals.threadManager.shouldKeepRunning() && !serverSocket.isClosed()){
|
||||
while(Globals.engineState.threadManager.shouldKeepRunning() && !serverSocket.isClosed()){
|
||||
Socket newSocket;
|
||||
try {
|
||||
newSocket = serverSocket.accept();
|
||||
@ -104,7 +104,7 @@ public class Server implements Runnable {
|
||||
// clientMap.put(newSocket.getInetAddress().getHostAddress(), newClient);
|
||||
socketConnectionMap.put(newSocket, newClient);
|
||||
activeConnections.add(newClient);
|
||||
Globals.threadManager.start(ThreadLabel.NETWORKING_SERVER, new Thread(newClient));
|
||||
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_SERVER, new Thread(newClient));
|
||||
connectListLock.release();
|
||||
} catch (SocketException ex){
|
||||
LoggerInterface.loggerNetworking.DEBUG("Server Socket closed!",ex);
|
||||
@ -172,7 +172,7 @@ public class Server implements Runnable {
|
||||
connectListLock.acquireUninterruptibly();
|
||||
ServerConnectionHandler newClient = new ServerConnectionHandler(serverInputStream,serverOutputStream);
|
||||
activeConnections.add(newClient);
|
||||
Globals.threadManager.start(ThreadLabel.NETWORKING_SERVER, new Thread(newClient));
|
||||
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_SERVER, new Thread(newClient));
|
||||
connectListLock.release();
|
||||
return newClient;
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ public class ServerConnectionHandler implements Runnable {
|
||||
|
||||
|
||||
initialized = true;
|
||||
while(Globals.threadManager.shouldKeepRunning() && this.isConnected == true && Globals.serverState.server != null && Globals.serverState.server.isOpen()){
|
||||
while(Globals.engineState.threadManager.shouldKeepRunning() && this.isConnected == true && Globals.serverState.server != null && Globals.serverState.server.isOpen()){
|
||||
|
||||
boolean receivedMessageThisLoop = false;
|
||||
//
|
||||
|
||||
@ -40,7 +40,7 @@ public class GriddedDataCellLoaderService {
|
||||
* Constructor
|
||||
*/
|
||||
public GriddedDataCellLoaderService(){
|
||||
this.ioThreadService = Globals.threadManager.requestFixedThreadPool(ThreadCounts.GRIDDED_DATACELL_LOADING_THREADS);
|
||||
this.ioThreadService = Globals.engineState.threadManager.requestFixedThreadPool(ThreadCounts.GRIDDED_DATACELL_LOADING_THREADS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -206,7 +206,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
||||
}
|
||||
this.pathfinder = new VoxelPathfinder();
|
||||
this.loaderService = new GriddedDataCellLoaderService();
|
||||
this.generationService = Globals.threadManager.requestFixedThreadPool(ThreadCounts.GRIDDED_DATACELL_PHYSICS_GEN_THREADS);
|
||||
this.generationService = Globals.engineState.threadManager.requestFixedThreadPool(ThreadCounts.GRIDDED_DATACELL_PHYSICS_GEN_THREADS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -107,7 +107,7 @@ public class ServerBlockChunkGenerationThread implements Runnable {
|
||||
BlockChunkData chunk = null;
|
||||
int i = 0;
|
||||
try {
|
||||
while(chunk == null && i < MAX_TIME_TO_WAIT && Globals.threadManager.shouldKeepRunning()){
|
||||
while(chunk == null && i < MAX_TIME_TO_WAIT && Globals.engineState.threadManager.shouldKeepRunning()){
|
||||
if(chunkCache.containsChunk(worldX, worldY, worldZ, stride)){
|
||||
chunk = chunkCache.get(worldX, worldY, worldZ, stride);
|
||||
} else {
|
||||
|
||||
@ -45,7 +45,7 @@ public class ServerBlockManager {
|
||||
* The threadpool for chunk generation
|
||||
*/
|
||||
@Exclude
|
||||
ExecutorService chunkExecutorService = Globals.threadManager.requestFixedThreadPool(ThreadCounts.SERVER_BLOCK_GENERATION_THREADS);
|
||||
ExecutorService chunkExecutorService = Globals.engineState.threadManager.requestFixedThreadPool(ThreadCounts.SERVER_BLOCK_GENERATION_THREADS);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@ -97,7 +97,7 @@ public class ChunkGenerationThread implements Runnable {
|
||||
try {
|
||||
int i = 0;
|
||||
ServerTerrainChunk chunk = null;
|
||||
while(chunk == null && i < MAX_TIME_TO_WAIT && Globals.threadManager.shouldKeepRunning()){
|
||||
while(chunk == null && i < MAX_TIME_TO_WAIT && Globals.engineState.threadManager.shouldKeepRunning()){
|
||||
if(chunkCache.containsChunk(worldX, worldY, worldZ, stride)){
|
||||
chunk = chunkCache.get(worldX, worldY, worldZ, stride);
|
||||
} else {
|
||||
|
||||
@ -77,7 +77,7 @@ public class ServerTerrainManager {
|
||||
* The threadpool for chunk generation
|
||||
*/
|
||||
@Exclude
|
||||
ExecutorService chunkExecutorService = Globals.threadManager.requestFixedThreadPool(ThreadCounts.SERVER_TERRAIN_GENERATION_THREADS);
|
||||
ExecutorService chunkExecutorService = Globals.engineState.threadManager.requestFixedThreadPool(ThreadCounts.SERVER_TERRAIN_GENERATION_THREADS);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@ -6,6 +6,7 @@ import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import electrosphere.client.ClientState;
|
||||
import electrosphere.client.scene.ClientWorldData;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
@ -35,6 +36,7 @@ public class ClientDrawCellManagerTests {
|
||||
public void testJoinCase(){
|
||||
|
||||
int worldDiscreteSize = 64;
|
||||
Globals.clientState = new ClientState();
|
||||
Globals.clientState.clientWorldData = new ClientWorldData(new Vector3f(0), new Vector3f(worldDiscreteSize * ServerTerrainChunk.CHUNK_DIMENSION), worldDiscreteSize);
|
||||
ClientDrawCellManager manager = new ClientDrawCellManager(null, 64);
|
||||
Vector3i playerPos = new Vector3i(0,0,0);
|
||||
|
||||
@ -6,7 +6,6 @@ import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.test.annotations.UnitTest;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.server.ServerState;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.service.CharacterService;
|
||||
|
||||
@ -18,7 +17,7 @@ public class ServerEntityUtilsUnitTests {
|
||||
@UnitTest
|
||||
public void destroyEntity_ValidEntity_NoRealm(){
|
||||
//setup
|
||||
Globals.serverState = new ServerState();
|
||||
Globals.initGlobals();
|
||||
Globals.serverState.characterService = (CharacterService)Globals.serviceManager.registerService(new CharacterService());
|
||||
Realm realm = Globals.serverState.realmManager.createViewportRealm(new Vector3d(0,0,0), new Vector3d(1,1,1));
|
||||
Entity entity = EntityCreationUtils.createServerEntity(realm, new Vector3d());
|
||||
|
||||
@ -16,12 +16,12 @@ public class StateCleanupCheckerExtension implements AfterEachCallback {
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
Object[] objectsToCheck = new Object[]{
|
||||
Globals.signalSystem,
|
||||
Globals.threadManager,
|
||||
Globals.renderingEngine,
|
||||
Globals.audioEngine,
|
||||
Globals.javaPID,
|
||||
LoggerInterface.loggerEngine,
|
||||
RenderingEngine.screenFramebuffer,
|
||||
Globals.engineState,
|
||||
Globals.clientState,
|
||||
Globals.serverState,
|
||||
};
|
||||
|
||||
@ -60,12 +60,12 @@ public class EngineInit {
|
||||
//
|
||||
//load the scene
|
||||
LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LEVEL,"testscene1");
|
||||
Globals.threadManager.start(loadingThread);
|
||||
Globals.engineState.threadManager.start(loadingThread);
|
||||
|
||||
//
|
||||
//wait for client to be fully init'd
|
||||
int frames = 0;
|
||||
while(Globals.threadManager.isLoading()){
|
||||
while(Globals.engineState.threadManager.isLoading()){
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(1);
|
||||
@ -77,7 +77,7 @@ public class EngineInit {
|
||||
String errorMessage = "Failed to setup connected test scene!\n" +
|
||||
"Still running threads are:\n"
|
||||
;
|
||||
for(LoadingThread thread : Globals.threadManager.getLoadingThreads()){
|
||||
for(LoadingThread thread : Globals.engineState.threadManager.getLoadingThreads()){
|
||||
errorMessage = errorMessage + thread.getType() + "\n";
|
||||
}
|
||||
Assertions.fail("Failed to startup");
|
||||
@ -92,7 +92,7 @@ public class EngineInit {
|
||||
//
|
||||
//load the scene
|
||||
LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LOAD_VIEWPORT);
|
||||
Globals.threadManager.start(loadingThread);
|
||||
Globals.engineState.threadManager.start(loadingThread);
|
||||
|
||||
TestEngineUtils.flush();
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ public class TestEngineUtils {
|
||||
//wait for client to be fully init'd
|
||||
int frames = 0;
|
||||
long startTime = System.currentTimeMillis();
|
||||
while(Globals.threadManager.isLoading()){
|
||||
while(Globals.engineState.threadManager.isLoading()){
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(1);
|
||||
@ -137,7 +137,7 @@ public class TestEngineUtils {
|
||||
String errorMessage = "Failed to setup connected test scene!\n" +
|
||||
"Still running threads are:\n"
|
||||
;
|
||||
for(LoadingThread thread : Globals.threadManager.getLoadingThreads()){
|
||||
for(LoadingThread thread : Globals.engineState.threadManager.getLoadingThreads()){
|
||||
errorMessage = errorMessage + thread.getType() + "\n";
|
||||
}
|
||||
errorMessage = errorMessage + "frames: " + frames + "\n";
|
||||
|
||||
@ -57,7 +57,7 @@ public class TestViewportUtils {
|
||||
String errorMessage = "Failed to spawn player character!\n" +
|
||||
"Still running threads are:\n"
|
||||
;
|
||||
for(LoadingThread thread : Globals.threadManager.getLoadingThreads()){
|
||||
for(LoadingThread thread : Globals.engineState.threadManager.getLoadingThreads()){
|
||||
errorMessage = errorMessage + thread.getType() + "\n";
|
||||
}
|
||||
throw new IllegalStateException(errorMessage);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user