move engine flags under engine state
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-15 16:08:33 -04:00
parent 6fe1733d58
commit 3cc51c008c
36 changed files with 243 additions and 166 deletions

View File

@ -11,6 +11,7 @@ import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
import electrosphere.client.terrain.sampling.ClientVoxelSampler; import electrosphere.client.terrain.sampling.ClientVoxelSampler;
import electrosphere.data.audio.SurfaceAudioCollection; import electrosphere.data.audio.SurfaceAudioCollection;
import electrosphere.data.audio.SurfaceAudioType; import electrosphere.data.audio.SurfaceAudioType;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
@ -158,7 +159,7 @@ public class MovementAudioService {
* @param type The interaction type * @param type The interaction type
*/ */
public void playAudio(int voxelType, InteractionType type){ public void playAudio(int voxelType, InteractionType type){
if(Globals.RUN_AUDIO){ if(EngineState.EngineFlags.RUN_AUDIO){
String audioPath = this.getAudioPath(voxelType, type); String audioPath = this.getAudioPath(voxelType, type);
if(audioPath != null){ if(audioPath != null){
Globals.audioEngine.virtualAudioSourceManager.createVirtualAudioSource(audioPath, VirtualAudioSourceType.CREATURE, false); Globals.audioEngine.virtualAudioSourceManager.createVirtualAudioSource(audioPath, VirtualAudioSourceType.CREATURE, false);
@ -173,7 +174,7 @@ public class MovementAudioService {
* @param position The position of the audio * @param position The position of the audio
*/ */
public void playAudioPositional(int voxelType, InteractionType type, Vector3d position){ public void playAudioPositional(int voxelType, InteractionType type, Vector3d position){
if(Globals.RUN_AUDIO){ if(EngineState.EngineFlags.RUN_AUDIO){
String audioPath = this.getAudioPath(voxelType, type); String audioPath = this.getAudioPath(voxelType, type);
if(audioPath != null){ if(audioPath != null){
Globals.audioEngine.virtualAudioSourceManager.createVirtualAudioSource(audioPath, VirtualAudioSourceType.CREATURE, false, position); Globals.audioEngine.virtualAudioSourceManager.createVirtualAudioSource(audioPath, VirtualAudioSourceType.CREATURE, false, position);

View File

@ -9,6 +9,7 @@ import electrosphere.client.fluid.manager.ClientFluidManager;
import electrosphere.client.interact.ClientInteractionEngine; import electrosphere.client.interact.ClientInteractionEngine;
import electrosphere.client.terrain.manager.ClientTerrainManager; import electrosphere.client.terrain.manager.ClientTerrainManager;
import electrosphere.client.ui.menu.ingame.ToolbarPreviewWindow; import electrosphere.client.ui.menu.ingame.ToolbarPreviewWindow;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityTags; import electrosphere.entity.EntityTags;
@ -63,7 +64,7 @@ public class ClientSimulation {
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
// //
//simulate bullet physics engine step //simulate bullet physics engine step
if(Globals.RUN_PHYSICS){ if(EngineState.EngineFlags.RUN_PHYSICS){
Globals.clientState.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.engineState.timekeeper.getSimFrameTime()); Globals.clientState.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.engineState.timekeeper.getSimFrameTime());
Globals.clientState.clientSceneWrapper.getCollisionEngine().updateDynamicObjectTransforms(); Globals.clientState.clientSceneWrapper.getCollisionEngine().updateDynamicObjectTransforms();
} }
@ -184,7 +185,7 @@ public class ClientSimulation {
Globals.clientState.clientTerrainManager.handleMessages(); Globals.clientState.clientTerrainManager.handleMessages();
this.updateTerrainCellManager(); this.updateTerrainCellManager();
} }
if(Globals.clientState.clientFluidManager != null && Globals.RUN_FLUIDS){ if(Globals.clientState.clientFluidManager != null && EngineState.EngineFlags.RUN_FLUIDS){
Globals.clientState.clientFluidManager.handleMessages(); Globals.clientState.clientFluidManager.handleMessages();
this.updateFluidCellManager(); this.updateFluidCellManager();
} }
@ -213,7 +214,7 @@ public class ClientSimulation {
*/ */
private void updateFluidCellManager(){ private void updateFluidCellManager(){
//fluid work //fluid work
if(Globals.clientState.fluidCellManager != null && Globals.clientState.clientWorldData != null && Globals.RUN_FLUIDS){ if(Globals.clientState.fluidCellManager != null && Globals.clientState.clientWorldData != null && EngineState.EngineFlags.RUN_FLUIDS){
Globals.clientState.fluidCellManager.update(); Globals.clientState.fluidCellManager.update();
} }
} }

View File

@ -7,6 +7,7 @@ import electrosphere.client.ui.menu.ingame.MenuGeneratorsInventory;
import electrosphere.client.ui.menu.ingame.InventoryMainWindow; import electrosphere.client.ui.menu.ingame.InventoryMainWindow;
import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsTitleMenu; import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsTitleMenu;
import electrosphere.controls.ControlHandler.ControlsState; import electrosphere.controls.ControlHandler.ControlsState;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
@ -192,7 +193,7 @@ public class WindowUtils {
*/ */
public static void attemptRedrawInventoryWindows(){ public static void attemptRedrawInventoryWindows(){
//make sure we're client and the player entity exists //make sure we're client and the player entity exists
if(Globals.RUN_CLIENT){ if(EngineState.EngineFlags.RUN_CLIENT){
if(Globals.clientState.playerEntity != null){ if(Globals.clientState.playerEntity != null){
if(Globals.elementService.containsWindow(WindowStrings.WINDOW_CHARACTER)){ if(Globals.elementService.containsWindow(WindowStrings.WINDOW_CHARACTER)){
//redraw if necessary //redraw if necessary

View File

@ -8,6 +8,7 @@ import electrosphere.client.ui.components.VoxelSelectionPanel;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.data.voxel.VoxelType; import electrosphere.data.voxel.VoxelType;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.loadingthreads.LoadingThread; import electrosphere.engine.loadingthreads.LoadingThread;
@ -132,8 +133,8 @@ public class MenuGeneratorsLevelEditor {
Button launchButton = Button.createButton(saveName, () -> { Button launchButton = Button.createButton(saveName, () -> {
//launch level //launch level
LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LEVEL, saveName); LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LEVEL, saveName);
Globals.RUN_CLIENT = true; EngineState.EngineFlags.RUN_CLIENT = true;
Globals.RUN_SERVER = true; EngineState.EngineFlags.RUN_SERVER = true;
Globals.engineState.threadManager.start(loadingThread); Globals.engineState.threadManager.start(loadingThread);
}).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE); }).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE);

View File

@ -5,6 +5,7 @@ import electrosphere.client.ui.components.CharacterCustomizer;
import electrosphere.client.ui.components.InputMacros; import electrosphere.client.ui.components.InputMacros;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.client.ui.menu.mainmenu.worldgen.MenuWorldSelect; import electrosphere.client.ui.menu.mainmenu.worldgen.MenuWorldSelect;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.loadingthreads.LoadingThread; import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType; import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
@ -89,8 +90,8 @@ public class MenuGeneratorsMultiplayer {
rVal.addChild(Button.createButton("Host", () -> { rVal.addChild(Button.createButton("Host", () -> {
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER); LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME); LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME);
Globals.RUN_CLIENT = true; EngineState.EngineFlags.RUN_CLIENT = true;
Globals.RUN_SERVER = true; EngineState.EngineFlags.RUN_SERVER = true;
Globals.engineState.threadManager.start(serverThread); Globals.engineState.threadManager.start(serverThread);
Globals.engineState.threadManager.start(clientThread); Globals.engineState.threadManager.start(clientThread);
})); }));
@ -126,8 +127,8 @@ public class MenuGeneratorsMultiplayer {
//Address input //Address input
// //
String ipAddress = ""; String ipAddress = "";
if(Globals.netConfig != null && Globals.netConfig.getAddress() != null){ if(Globals.gameConfigCurrent.getNetConfig() != null && Globals.gameConfigCurrent.getNetConfig().getAddress() != null){
ipAddress = Globals.netConfig.getAddress(); ipAddress = Globals.gameConfigCurrent.getNetConfig().getAddress();
} else { } else {
ipAddress = NetUtils.getAddress(); ipAddress = NetUtils.getAddress();
} }
@ -139,8 +140,8 @@ public class MenuGeneratorsMultiplayer {
//Port input //Port input
// //
String port = ""; String port = "";
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){ if(Globals.gameConfigCurrent.getNetConfig() != null && Globals.gameConfigCurrent.getNetConfig().getPort() != null){
port = Globals.netConfig.getPort(); port = Globals.gameConfigCurrent.getNetConfig().getPort();
} else { } else {
port = NetUtils.getPort() + ""; port = NetUtils.getPort() + "";
} }
@ -152,8 +153,8 @@ public class MenuGeneratorsMultiplayer {
//Username input //Username input
// //
String username = ""; String username = "";
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){ if(Globals.gameConfigCurrent.getNetConfig() != null && Globals.gameConfigCurrent.getNetConfig().getPort() != null){
username = Globals.netConfig.getUsername(); username = Globals.gameConfigCurrent.getNetConfig().getUsername();
} else { } else {
username = ""; username = "";
} }
@ -166,8 +167,8 @@ public class MenuGeneratorsMultiplayer {
//Password input //Password input
// //
String password = ""; String password = "";
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){ if(Globals.gameConfigCurrent.getNetConfig() != null && Globals.gameConfigCurrent.getNetConfig().getPort() != null){
password = Globals.netConfig.getPassword(); password = Globals.gameConfigCurrent.getNetConfig().getPassword();
} else { } else {
password = ""; password = "";
} }
@ -182,8 +183,8 @@ public class MenuGeneratorsMultiplayer {
Globals.clientState.clientUsername = usernameInput.getText(); Globals.clientState.clientUsername = usernameInput.getText();
Globals.clientState.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; EngineState.EngineFlags.RUN_CLIENT = true;
Globals.RUN_SERVER = false; EngineState.EngineFlags.RUN_SERVER = false;
Globals.engineState.threadManager.start(clientThread); Globals.engineState.threadManager.start(clientThread);
})); }));

View File

@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import electrosphere.auth.AuthenticationManager; import electrosphere.auth.AuthenticationManager;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsTitleMenu; import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsTitleMenu;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.loadingthreads.LoadingThread; import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType; import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
@ -58,8 +59,8 @@ public class MenuWorldSelect {
Globals.clientState.clientUsername = "username"; Globals.clientState.clientUsername = "username";
Globals.clientState.clientPassword = AuthenticationManager.getHashedString("password"); Globals.clientState.clientPassword = AuthenticationManager.getHashedString("password");
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME, saveName, Globals.clientState.clientUsername, Globals.clientState.clientPassword); LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME, saveName, Globals.clientState.clientUsername, Globals.clientState.clientPassword);
Globals.RUN_CLIENT = true; EngineState.EngineFlags.RUN_CLIENT = true;
Globals.RUN_SERVER = true; EngineState.EngineFlags.RUN_SERVER = true;
Globals.engineState.threadManager.start(serverThread); Globals.engineState.threadManager.start(serverThread);
} else { } else {
SaveUtils.loadSave(saveName.toLowerCase(), false); SaveUtils.loadSave(saveName.toLowerCase(), false);

View File

@ -26,6 +26,7 @@ import electrosphere.controls.categories.ControlCategoryInventory;
import electrosphere.controls.categories.ControlCategoryMainGame; import electrosphere.controls.categories.ControlCategoryMainGame;
import electrosphere.controls.categories.ControlCategoryMenuNav; import electrosphere.controls.categories.ControlCategoryMenuNav;
import electrosphere.controls.categories.ControlCategoryTyping; import electrosphere.controls.categories.ControlCategoryTyping;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.renderer.ui.elements.Window; import electrosphere.renderer.ui.elements.Window;
@ -396,7 +397,7 @@ public class ControlHandler {
*/ */
private void getMousePositionInBuffer(){ private void getMousePositionInBuffer(){
//only if not headless, gather position //only if not headless, gather position
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
glfwGetCursorPos(Globals.renderingEngine.getWindowPtr(), this.mouseState.getMouseBufferX(), this.mouseState.getMouseBufferY()); glfwGetCursorPos(Globals.renderingEngine.getWindowPtr(), this.mouseState.getMouseBufferX(), this.mouseState.getMouseBufferY());
} }
} }
@ -406,7 +407,7 @@ public class ControlHandler {
* @return true if pressed, false otherwise * @return true if pressed, false otherwise
*/ */
private boolean getButton1Raw(){ private boolean getButton1Raw(){
if(Globals.HEADLESS){ if(EngineState.EngineFlags.HEADLESS){
return false; return false;
} else { } else {
return Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_1); return Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_1);
@ -418,7 +419,7 @@ public class ControlHandler {
* @return true if pressed, false otherwise * @return true if pressed, false otherwise
*/ */
private boolean getButton2Raw(){ private boolean getButton2Raw(){
if(Globals.HEADLESS){ if(EngineState.EngineFlags.HEADLESS){
return false; return false;
} else { } else {
return Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_2); return Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_2);

View File

@ -27,6 +27,7 @@ import electrosphere.data.units.UnitDefinitionFile;
import electrosphere.data.units.UnitLoader; import electrosphere.data.units.UnitLoader;
import electrosphere.data.voxel.VoxelData; import electrosphere.data.voxel.VoxelData;
import electrosphere.data.voxel.sampler.SamplerFile; import electrosphere.data.voxel.sampler.SamplerFile;
import electrosphere.net.config.NetConfig;
import electrosphere.server.macro.race.RaceMap; import electrosphere.server.macro.race.RaceMap;
import electrosphere.server.macro.symbolism.SymbolMap; import electrosphere.server.macro.symbolism.SymbolMap;
import electrosphere.util.FileUtils; import electrosphere.util.FileUtils;
@ -40,6 +41,11 @@ public class Config {
* Top level user settings object * Top level user settings object
*/ */
UserSettings userSettings; UserSettings userSettings;
/**
* Optional config that can be included alongside engine to inject a default network to populate on the multiplayer screens
*/
NetConfig netConfig;
/** /**
* The container for all creature definitions * The container for all creature definitions
@ -115,6 +121,7 @@ public class Config {
public static Config loadDefaultConfig(){ public static Config loadDefaultConfig(){
Config config = new Config(); Config config = new Config();
config.userSettings = UserSettings.loadUserSettings(); config.userSettings = UserSettings.loadUserSettings();
config.netConfig = NetConfig.readNetConfig();
config.creatureTypeLoader = Config.loadCreatureTypes("Data/entity/creatures.json"); config.creatureTypeLoader = Config.loadCreatureTypes("Data/entity/creatures.json");
config.itemMap = ItemDataMap.loadItemFiles("Data/entity/items.json"); config.itemMap = ItemDataMap.loadItemFiles("Data/entity/items.json");
config.foliageMap = Config.loadFoliageTypes("Data/entity/foliage.json"); config.foliageMap = Config.loadFoliageTypes("Data/entity/foliage.json");
@ -408,5 +415,13 @@ public class Config {
public ItemSourcingMap getItemSourcingMap(){ public ItemSourcingMap getItemSourcingMap(){
return this.itemSourcingMap; return this.itemSourcingMap;
} }
/**
* Gets the network config file if it exists
* @return The config if it exists, null otherwise
*/
public NetConfig getNetConfig(){
return netConfig;
}
} }

View File

@ -38,6 +38,11 @@ public class EngineState {
*/ */
public SignalSystem signalSystem; public SignalSystem signalSystem;
/**
* Engine-wide flags
*/
public EngineFlags flags = new EngineFlags();
/** /**
* Constructor * Constructor
*/ */
@ -61,4 +66,80 @@ public class EngineState {
this.serviceManager.destroy(); this.serviceManager.destroy();
} }
/**
* Engine-wide flags
*/
public static class EngineFlags {
/**
* Run engine in demo mode
*/
public static boolean RUN_DEMO = false;
/**
* Run client
*/
public static boolean RUN_CLIENT = true;
/**
* Run server
*/
public static boolean RUN_SERVER = true;
/**
* glfw session will be created with hidden window
*/
public static boolean RUN_HIDDEN = false;
/**
* Run the audio engine
*/
public static boolean RUN_AUDIO = true;
/**
* Run the script engine
*/
public static boolean RUN_SCRIPTS = true;
/**
* toggles whether physics is run or not
*/
public static boolean RUN_PHYSICS = true;
/**
* toggles whether fluid physics is run or not
*/
public static boolean RUN_FLUIDS = false;
/**
* Garbage Collection
*
* set to true to trigger full GC every frame
* a full GC includes collecting old generations as well -- likely very laggy!!
*/
public static boolean EXPLICIT_GC = false;
/**
* Engine timing
*/
public static boolean EXPLICIT_SLEEP = true;
/**
* Triggers the engine to shut down
*/
public static boolean ENGINE_SHUTDOWN_FLAG = false;
/**
* main debug flag
* current enables imgui debug menu or not
*/
public static boolean ENGINE_DEBUG = true;
/**
* Controls whether the engine is headless or not
*/
public static boolean HEADLESS = false;
}
} }

View File

@ -66,24 +66,15 @@ public class Globals {
*/ */
public static ServerState serverState; public static ServerState serverState;
// /**
//Rendering Engine * The rendering engine
// */
public static RenderingEngine renderingEngine; public static RenderingEngine renderingEngine;
// /**
//Audio Engine * The audio engine
// */
public static AudioEngine audioEngine; public static AudioEngine audioEngine;
//
//Core Engine signals
//
public static boolean ENGINE_SHUTDOWN_FLAG = false;
//main debug flag
//current enables imgui debug menu or not
public static boolean ENGINE_DEBUG = true;
// //
@ -91,40 +82,6 @@ public class Globals {
// //
public static Profiler profiler; public static Profiler profiler;
//
//Garbage Collection
//
//set to true to trigger full GC every frame
//a full GC includes collecting old generations as well -- likely very laggy!!
public static boolean EXPLICIT_GC = false;
/**
* Number of frames to wait before triggering gc again
*/
public static final int GC_FRAME_FREQUENCY = 15;
//
//Engine timing
//
public static boolean EXPLICIT_SLEEP = true;
//
//Signals for running various parts of the engine
//
public static boolean RUN_DEMO = false;
public static boolean RUN_CLIENT = true;
public static boolean RUN_HIDDEN = false; //glfw session will be created with hidden window
public static boolean RUN_AUDIO = true;
public static boolean RUN_SCRIPTS = true;
public static boolean RUN_PHYSICS = true; //toggles whether physics is run or not
public static boolean RUN_FLUIDS = false; //toggles whether fluid physics is run or not
public static int clientCharacterID;
public static NetConfig netConfig = null;
//
//Server manager thing
//
public static boolean RUN_SERVER = true;
// //
//Authentication manager //Authentication manager
// //
@ -216,13 +173,6 @@ public class Globals {
public static StructureScanningService structureScanningService; public static StructureScanningService structureScanningService;
//
//Base engine creation flags
//
public static boolean HEADLESS = false;
// //
// //
// Renderer flags // Renderer flags

View File

@ -43,6 +43,11 @@ public class Main {
* Toggles automatic simulation * Toggles automatic simulation
*/ */
public static final int FRAMESTEP_AUTO = 2; public static final int FRAMESTEP_AUTO = 2;
/**
* Number of frames to wait before triggering gc again
*/
public static final int GC_FRAME_FREQUENCY = 15;
@ -110,12 +115,12 @@ public class Main {
Globals.initGlobals(); Globals.initGlobals();
//init scripting engine //init scripting engine
if(Globals.RUN_SCRIPTS){ if(EngineState.EngineFlags.RUN_SCRIPTS){
Globals.engineState.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE)); Globals.engineState.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
} }
//controls //controls
if(Globals.RUN_CLIENT){ if(EngineState.EngineFlags.RUN_CLIENT){
Main.initControlHandler(); Main.initControlHandler();
} }
@ -126,7 +131,7 @@ public class Main {
} }
//create the drawing context //create the drawing context
if(Globals.RUN_CLIENT && !Globals.HEADLESS){ if(EngineState.EngineFlags.RUN_CLIENT && !EngineState.EngineFlags.HEADLESS){
//create opengl context //create opengl context
Globals.renderingEngine = new RenderingEngine(); Globals.renderingEngine = new RenderingEngine();
Globals.renderingEngine.createOpenglContext(); Globals.renderingEngine.createOpenglContext();
@ -149,7 +154,7 @@ public class Main {
//create the audio context //create the audio context
Globals.audioEngine = new AudioEngine(); Globals.audioEngine = new AudioEngine();
if(Globals.RUN_CLIENT && !Globals.HEADLESS && Globals.RUN_AUDIO){ if(EngineState.EngineFlags.RUN_CLIENT && !EngineState.EngineFlags.HEADLESS && EngineState.EngineFlags.RUN_AUDIO){
Globals.audioEngine.init(); Globals.audioEngine.init();
Globals.audioEngine.listAllDevices(); Globals.audioEngine.listAllDevices();
Globals.initDefaultAudioResources(); Globals.initDefaultAudioResources();
@ -161,10 +166,10 @@ public class Main {
//fire off a loading thread for the title menus/screen //fire off a loading thread for the title menus/screen
LoggerInterface.loggerStartup.INFO("Fire off loading thread"); LoggerInterface.loggerStartup.INFO("Fire off loading thread");
if(Globals.RUN_DEMO){ if(EngineState.EngineFlags.RUN_DEMO){
LoadingThread serverThread = new LoadingThread(LoadingThreadType.DEMO_MENU); LoadingThread serverThread = new LoadingThread(LoadingThreadType.DEMO_MENU);
Globals.engineState.threadManager.start(serverThread); Globals.engineState.threadManager.start(serverThread);
} else if(Globals.RUN_CLIENT){ } else if(EngineState.EngineFlags.RUN_CLIENT){
LoadingThread serverThread = new LoadingThread(LoadingThreadType.TITLE_MENU); LoadingThread serverThread = new LoadingThread(LoadingThreadType.TITLE_MENU);
Globals.engineState.threadManager.start(serverThread); Globals.engineState.threadManager.start(serverThread);
} else { } else {
@ -172,7 +177,7 @@ public class Main {
} }
//recapture the screen for rendering //recapture the screen for rendering
if(Globals.RUN_CLIENT && !Globals.HEADLESS){ if(EngineState.EngineFlags.RUN_CLIENT && !EngineState.EngineFlags.HEADLESS){
LoggerInterface.loggerStartup.INFO("Recapture screen"); LoggerInterface.loggerStartup.INFO("Recapture screen");
Globals.controlHandler.setRecapture(true); Globals.controlHandler.setRecapture(true);
} }
@ -213,7 +218,7 @@ public class Main {
/// ///
/// A S S E T M A N A G E R S T U F F /// A S S E T M A N A G E R S T U F F
/// ///
if(Globals.RUN_CLIENT){ if(EngineState.EngineFlags.RUN_CLIENT){
Globals.profiler.beginCpuSample("Load Assets"); Globals.profiler.beginCpuSample("Load Assets");
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin load assets"); LoggerInterface.loggerEngine.DEBUG_LOOP("Begin load assets");
Globals.assetManager.loadAssetsInQueue(); Globals.assetManager.loadAssetsInQueue();
@ -242,7 +247,7 @@ public class Main {
/// I N P U T C O N T R O L S /// I N P U T C O N T R O L S
/// ///
//Poll controls //Poll controls
if(Globals.RUN_CLIENT){ if(EngineState.EngineFlags.RUN_CLIENT){
Globals.profiler.beginCpuSample("Poll Controls"); Globals.profiler.beginCpuSample("Poll Controls");
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin recapture screen"); LoggerInterface.loggerEngine.DEBUG_LOOP("Begin recapture screen");
Globals.controlHandler.pollControls(); Globals.controlHandler.pollControls();
@ -262,7 +267,7 @@ public class Main {
if(Globals.fileWatcherService != null){ if(Globals.fileWatcherService != null){
Globals.fileWatcherService.poll(); Globals.fileWatcherService.poll();
} }
if(Globals.RUN_SCRIPTS && Globals.scriptEngine != null){ if(EngineState.EngineFlags.RUN_SCRIPTS && Globals.scriptEngine != null){
Globals.scriptEngine.scanScriptDir(); Globals.scriptEngine.scanScriptDir();
} }
@ -335,7 +340,7 @@ public class Main {
/// M A I N R E N D E R F U N C T I O N /// M A I N R E N D E R F U N C T I O N
/// ///
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin rendering call"); LoggerInterface.loggerEngine.DEBUG_LOOP("Begin rendering call");
if(Globals.RUN_CLIENT && !Globals.HEADLESS){ if(EngineState.EngineFlags.RUN_CLIENT && !EngineState.EngineFlags.HEADLESS){
Globals.profiler.beginCpuSample("render"); Globals.profiler.beginCpuSample("render");
Globals.renderingEngine.drawScreen(); Globals.renderingEngine.drawScreen();
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
@ -348,7 +353,7 @@ public class Main {
/// G A R B A G E C H E C K /// G A R B A G E C H E C K
/// ///
Globals.profiler.beginCpuSample("gc"); Globals.profiler.beginCpuSample("gc");
if(Globals.EXPLICIT_GC && Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed() % Globals.GC_FRAME_FREQUENCY == 0){ if(EngineState.EngineFlags.EXPLICIT_GC && Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed() % Main.GC_FRAME_FREQUENCY == 0){
System.gc(); System.gc();
} }
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
@ -360,12 +365,12 @@ public class Main {
/// ///
/// S H U T D O W N C H E C K /// S H U T D O W N C H E C K
/// ///
if(Globals.HEADLESS){ if(EngineState.EngineFlags.HEADLESS){
if(Globals.ENGINE_SHUTDOWN_FLAG){ if(EngineState.EngineFlags.ENGINE_SHUTDOWN_FLAG){
running = false; running = false;
} }
} else { } else {
if(Globals.ENGINE_SHUTDOWN_FLAG || (Globals.RUN_CLIENT && GLFW.glfwWindowShouldClose(Globals.renderingEngine.getWindowPtr()))){ if(EngineState.EngineFlags.ENGINE_SHUTDOWN_FLAG || (EngineState.EngineFlags.RUN_CLIENT && GLFW.glfwWindowShouldClose(Globals.renderingEngine.getWindowPtr()))){
running = false; running = false;
} }
} }
@ -378,7 +383,7 @@ public class Main {
/// ///
/// C L E A N U P T I M E V A R I A B L E S /// C L E A N U P T I M E V A R I A B L E S
/// ///
if(Globals.EXPLICIT_SLEEP && Globals.engineState.timekeeper.getMostRecentRawFrametime() < 0.01f){ if(EngineState.EngineFlags.EXPLICIT_SLEEP && Globals.engineState.timekeeper.getMostRecentRawFrametime() < 0.01f){
Globals.profiler.beginCpuSample("sleep"); Globals.profiler.beginCpuSample("sleep");
if(Globals.engineState.timekeeper.getMostRecentRawFrametime() < targetFramePeriod){ if(Globals.engineState.timekeeper.getMostRecentRawFrametime() < targetFramePeriod){
Main.sleep((int)(1000.0 * (targetFramePeriod - Globals.engineState.timekeeper.getMostRecentRawFrametime()))); Main.sleep((int)(1000.0 * (targetFramePeriod - Globals.engineState.timekeeper.getMostRecentRawFrametime())));

View File

@ -3,7 +3,7 @@ package electrosphere.engine.cli;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import electrosphere.engine.Globals; import electrosphere.engine.EngineState;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.logger.Logger.LogLevel; import electrosphere.logger.Logger.LogLevel;
@ -15,9 +15,9 @@ public class CLIParser {
String argCurrent = argList.get(i); String argCurrent = argList.get(i);
switch(argCurrent){ switch(argCurrent){
case "--headless": { case "--headless": {
Globals.RUN_CLIENT = false; EngineState.EngineFlags.RUN_CLIENT = false;
Globals.RUN_SERVER = true; EngineState.EngineFlags.RUN_SERVER = true;
Globals.HEADLESS = true; EngineState.EngineFlags.HEADLESS = true;
} break; } break;
case "--maxLogs": { case "--maxLogs": {
LoggerInterface.setInitLogLevel(LogLevel.LOOP_DEBUG); LoggerInterface.setInitLogLevel(LogLevel.LOOP_DEBUG);

View File

@ -6,6 +6,7 @@ import electrosphere.auth.AuthenticationManager;
import electrosphere.client.ui.menu.MenuGenerators; import electrosphere.client.ui.menu.MenuGenerators;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.entity.scene.SceneGenerator; import electrosphere.entity.scene.SceneGenerator;
@ -29,8 +30,8 @@ public class ChunkGenerationTestLoading {
// //
//Set params we would expect to run with this thread //Set params we would expect to run with this thread
// //
Globals.RUN_CLIENT = true; EngineState.EngineFlags.RUN_CLIENT = true;
Globals.RUN_SERVER = true; EngineState.EngineFlags.RUN_SERVER = true;
Globals.serverState.aiManager.setActive(false); Globals.serverState.aiManager.setActive(false);
@ -73,7 +74,7 @@ public class ChunkGenerationTestLoading {
//initialize the "virtual" objects simulation //initialize the "virtual" objects simulation
LoadingUtils.initMacroSimulation(); LoadingUtils.initMacroSimulation();
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT); LoggerInterface.loggerEngine.INFO("run server: " + EngineState.EngineFlags.RUN_SERVER + " run client: " + EngineState.EngineFlags.RUN_CLIENT);
//init authentication //init authentication
LoadingUtils.initAuthenticationManager(false); LoadingUtils.initAuthenticationManager(false);
//initialize the local connection //initialize the local connection

View File

@ -18,6 +18,7 @@ import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.client.ui.menu.mainmenu.MenuCharacterCreation; import electrosphere.client.ui.menu.mainmenu.MenuCharacterCreation;
import electrosphere.controls.ControlHandler; import electrosphere.controls.ControlHandler;
import electrosphere.controls.cursor.CursorState; import electrosphere.controls.cursor.CursorState;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.engine.threads.LabeledThread.ThreadLabel; import electrosphere.engine.threads.LabeledThread.ThreadLabel;
@ -203,7 +204,7 @@ public class ClientLoading {
*/ */
private static void initClientThread(){ private static void initClientThread(){
//start client networking //start client networking
if(Globals.RUN_CLIENT){ if(EngineState.EngineFlags.RUN_CLIENT){
Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort()); Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection)); Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
} }
@ -380,7 +381,7 @@ public class ClientLoading {
//wait for all the terrain data to arrive //wait for all the terrain data to arrive
WindowUtils.updateLoadingWindow("REQUESTING FLUID CHUNKS FROM SERVER (" + Globals.clientState.fluidCellManager.getUnrequestedSize() + ")"); WindowUtils.updateLoadingWindow("REQUESTING FLUID CHUNKS FROM SERVER (" + Globals.clientState.fluidCellManager.getUnrequestedSize() + ")");
while(blockForInit && Globals.clientState.fluidCellManager.containsUnrequestedCell() && Globals.engineState.threadManager.shouldKeepRunning() && Globals.RUN_FLUIDS){ while(blockForInit && Globals.clientState.fluidCellManager.containsUnrequestedCell() && Globals.engineState.threadManager.shouldKeepRunning() && EngineState.EngineFlags.RUN_FLUIDS){
try { try {
TimeUnit.MILLISECONDS.sleep(10); TimeUnit.MILLISECONDS.sleep(10);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {

View File

@ -6,6 +6,7 @@ import electrosphere.auth.AuthenticationManager;
import electrosphere.client.ui.menu.MenuGenerators; import electrosphere.client.ui.menu.MenuGenerators;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.entity.scene.SceneGenerator; import electrosphere.entity.scene.SceneGenerator;
@ -41,7 +42,7 @@ public class DebugSPWorldLoading {
LoadingUtils.initMacroSimulation(); LoadingUtils.initMacroSimulation();
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT); LoggerInterface.loggerEngine.INFO("run server: " + EngineState.EngineFlags.RUN_SERVER + " run client: " + EngineState.EngineFlags.RUN_CLIENT);
//init authentication //init authentication
LoadingUtils.initAuthenticationManager(false); LoadingUtils.initAuthenticationManager(false);
//initialize the local connection //initialize the local connection

View File

@ -7,6 +7,7 @@ import electrosphere.client.ui.menu.MenuGenerators;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsLevelEditor.LevelDescription; import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsLevelEditor.LevelDescription;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.entity.scene.SceneFile; import electrosphere.entity.scene.SceneFile;
@ -49,8 +50,8 @@ public class LevelEditorLoading {
// //
//Set params we would expect to run with this thread //Set params we would expect to run with this thread
// //
Globals.RUN_CLIENT = true; EngineState.EngineFlags.RUN_CLIENT = true;
Globals.RUN_SERVER = true; EngineState.EngineFlags.RUN_SERVER = true;
Globals.serverState.aiManager.setActive(false); Globals.serverState.aiManager.setActive(false);
@ -69,7 +70,7 @@ public class LevelEditorLoading {
//load just-created save //load just-created save
SaveUtils.loadSave(saveName, true); SaveUtils.loadSave(saveName, true);
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT); LoggerInterface.loggerEngine.INFO("run server: " + EngineState.EngineFlags.RUN_SERVER + " run client: " + EngineState.EngineFlags.RUN_CLIENT);
//init authentication //init authentication
LoadingUtils.initAuthenticationManager(false); LoadingUtils.initAuthenticationManager(false);
//initialize the local connection //initialize the local connection

View File

@ -6,6 +6,7 @@ import electrosphere.auth.AuthenticationManager;
import electrosphere.client.ui.menu.MenuGenerators; import electrosphere.client.ui.menu.MenuGenerators;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
@ -39,7 +40,7 @@ public class LevelLoading {
//load save //load save
SaveUtils.loadSave(saveName, false); SaveUtils.loadSave(saveName, false);
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT); LoggerInterface.loggerEngine.INFO("run server: " + EngineState.EngineFlags.RUN_SERVER + " run client: " + EngineState.EngineFlags.RUN_CLIENT);
//init authentication //init authentication
LoadingUtils.initAuthenticationManager(false); LoadingUtils.initAuthenticationManager(false);
//initialize the local connection //initialize the local connection

View File

@ -13,6 +13,7 @@ import org.joml.Vector3i;
import electrosphere.auth.AuthenticationManager; import electrosphere.auth.AuthenticationManager;
import electrosphere.data.creature.CreatureData; import electrosphere.data.creature.CreatureData;
import electrosphere.data.creature.visualattribute.VisualAttribute; import electrosphere.data.creature.visualattribute.VisualAttribute;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.threads.LabeledThread.ThreadLabel; import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.entity.types.EntityTypes.EntityType; import electrosphere.entity.types.EntityTypes.EntityType;
@ -48,7 +49,7 @@ public class LoadingUtils {
static void initServerThread(){ static void initServerThread(){
//start server networking //start server networking
if(Globals.RUN_SERVER){ if(EngineState.EngineFlags.RUN_SERVER){
Globals.serverState.server = new Server(NetUtils.getPort()); Globals.serverState.server = new Server(NetUtils.getPort());
Thread serverThread = new Thread(Globals.serverState.server); Thread serverThread = new Thread(Globals.serverState.server);
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_SERVER, serverThread); Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_SERVER, serverThread);
@ -60,7 +61,7 @@ public class LoadingUtils {
* @param mock true if it should make a mock authentication manager, false for a real auth manager * @param mock true if it should make a mock authentication manager, false for a real auth manager
*/ */
static void initAuthenticationManager(boolean mock){ static void initAuthenticationManager(boolean mock){
if(Globals.RUN_SERVER){ if(EngineState.EngineFlags.RUN_SERVER){
Globals.authenticationManager = AuthenticationManager.create(mock); Globals.authenticationManager = AuthenticationManager.create(mock);
} }
} }
@ -69,7 +70,7 @@ public class LoadingUtils {
static void initClientThread(){ static void initClientThread(){
//start client networking //start client networking
if(Globals.RUN_CLIENT){ if(EngineState.EngineFlags.RUN_CLIENT){
Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort()); Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection)); Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
} }

View File

@ -3,6 +3,7 @@ package electrosphere.engine.loadingthreads;
import electrosphere.client.ui.menu.MenuGenerators; import electrosphere.client.ui.menu.MenuGenerators;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.entity.scene.SceneGenerator; import electrosphere.entity.scene.SceneGenerator;
@ -45,7 +46,7 @@ public class ServerLoading {
LoadingUtils.initMacroSimulation(); LoadingUtils.initMacroSimulation();
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT); LoggerInterface.loggerEngine.INFO("run server: " + EngineState.EngineFlags.RUN_SERVER + " run client: " + EngineState.EngineFlags.RUN_CLIENT);
//init authentication //init authentication
LoadingUtils.initAuthenticationManager(false); LoadingUtils.initAuthenticationManager(false);
//initialize the local connection //initialize the local connection

View File

@ -8,6 +8,7 @@ import electrosphere.auth.AuthenticationManager;
import electrosphere.client.ui.menu.MenuGenerators; import electrosphere.client.ui.menu.MenuGenerators;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
@ -41,7 +42,7 @@ public class ViewportLoading {
// //
//connect client to server //connect client to server
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT); LoggerInterface.loggerEngine.INFO("run server: " + EngineState.EngineFlags.RUN_SERVER + " run client: " + EngineState.EngineFlags.RUN_CLIENT);
ViewportLoading.initInMemoryDB(); ViewportLoading.initInMemoryDB();
LoadingUtils.initAuthenticationManager(true); LoadingUtils.initAuthenticationManager(true);
Globals.clientState.clientUsername = "leveleditor"; Globals.clientState.clientUsername = "leveleditor";

View File

@ -2,7 +2,7 @@ package electrosphere.engine.time;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import electrosphere.engine.Globals; import electrosphere.engine.EngineState;
/** /**
* Service that keeps track of time for main thread activities. * Service that keeps track of time for main thread activities.
@ -47,7 +47,7 @@ public class Timekeeper {
* @return The time (in seconds) * @return The time (in seconds)
*/ */
private double getTime(){ private double getTime(){
if(Globals.HEADLESS){ if(EngineState.EngineFlags.HEADLESS){
return System.currentTimeMillis() - engineStartTime; return System.currentTimeMillis() - engineStartTime;
} else { } else {
return GLFW.glfwGetTime(); return GLFW.glfwGetTime();
@ -60,7 +60,7 @@ public class Timekeeper {
*/ */
public void init(double simFrameTime){ public void init(double simFrameTime){
this.simFrameTime = simFrameTime; this.simFrameTime = simFrameTime;
if(Globals.HEADLESS){ if(EngineState.EngineFlags.HEADLESS){
engineStartTime = System.currentTimeMillis(); engineStartTime = System.currentTimeMillis();
} }
currentTime = getTime(); currentTime = getTime();

View File

@ -189,7 +189,6 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
ViewModelData viewModelData = creatureType.getViewModelData(); ViewModelData viewModelData = creatureType.getViewModelData();
if(Globals.clientState.clientPlayer != null && message.getpropertyValue() == Globals.clientState.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.clientState.playerEntity = target; Globals.clientState.playerEntity = target;
if(viewModelData != null && viewModelData.getFirstPersonModelPath() != null){ if(viewModelData != null && viewModelData.getFirstPersonModelPath() != null){
Globals.clientState.firstPersonEntity = CreatureUtils.clientCreateViewModel( Globals.clientState.firstPersonEntity = CreatureUtils.clientCreateViewModel(

View File

@ -4,7 +4,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.util.Utilities; import electrosphere.util.Utilities;
@ -70,15 +69,17 @@ public class NetConfig {
/** /**
* Reads the net config file * Reads the net config file
*/ */
public static void readNetConfig(){ public static NetConfig readNetConfig(){
NetConfig rVal = null;
File file = new File("./netconfig.json"); File file = new File("./netconfig.json");
if(file.exists()){ if(file.exists()){
try { try {
Globals.netConfig = Utilities.deserialize(Files.readString(file.toPath()), NetConfig.class); rVal = Utilities.deserialize(Files.readString(file.toPath()), NetConfig.class);
} catch (IOException e) { } catch (IOException e) {
LoggerInterface.loggerFileIO.ERROR(e); LoggerInterface.loggerFileIO.ERROR(e);
} }
} }
return rVal;
} }
} }

View File

@ -1,6 +1,7 @@
package electrosphere.net.server.protocol; package electrosphere.net.server.protocol;
import electrosphere.auth.AuthenticationManager; import electrosphere.auth.AuthenticationManager;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.net.parser.net.message.AuthMessage; import electrosphere.net.parser.net.message.AuthMessage;
import electrosphere.net.parser.net.message.PlayerMessage; import electrosphere.net.parser.net.message.PlayerMessage;
@ -25,7 +26,7 @@ public class AuthProtocol implements ServerProtocolTemplate<AuthMessage> {
Player newPlayer = new Player(connectionHandler, loginId); Player newPlayer = new Player(connectionHandler, loginId);
Globals.serverState.playerManager.registerPlayer(newPlayer); Globals.serverState.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.clientState.clientPlayer == null){ if(connectionHandler.getIPAddress().contains("127.0.0.1") && EngineState.EngineFlags.RUN_CLIENT == true && Globals.clientState.clientPlayer == null){
Globals.clientState.clientPlayer = newPlayer; Globals.clientState.clientPlayer = newPlayer;
} }
connectionHandler.addMessagetoOutgoingQueue(PlayerMessage.constructSet_IDMessage(connectionHandler.getPlayerId())); connectionHandler.addMessagetoOutgoingQueue(PlayerMessage.constructSet_IDMessage(connectionHandler.getPlayerId()));

View File

@ -26,6 +26,7 @@ import org.lwjgl.opengl.GLDebugMessageCallback;
import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.os.OSDragAndDrop; import electrosphere.engine.os.OSDragAndDrop;
@ -221,13 +222,13 @@ public class RenderingEngine {
glslVersion = "#version 450"; glslVersion = "#version 450";
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE); GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
//headless option //headless option
if(Globals.RUN_HIDDEN){ if(EngineState.EngineFlags.RUN_HIDDEN){
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE); GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
} }
if(!Globals.WINDOW_DECORATED){ if(!Globals.WINDOW_DECORATED){
GLFW.glfwWindowHint(GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); GLFW.glfwWindowHint(GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE);
} }
if(Globals.ENGINE_DEBUG){ if(EngineState.EngineFlags.ENGINE_DEBUG){
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GLFW.GLFW_TRUE); GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GLFW.GLFW_TRUE);
} }

View File

@ -16,7 +16,7 @@ import org.lwjgl.assimp.AIMesh;
import org.lwjgl.assimp.AIVector3D; import org.lwjgl.assimp.AIVector3D;
import org.lwjgl.assimp.AIVertexWeight; import org.lwjgl.assimp.AIVertexWeight;
import electrosphere.engine.Globals; import electrosphere.engine.EngineState;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.loading.ModelPretransforms; import electrosphere.renderer.loading.ModelPretransforms;
import electrosphere.renderer.model.Bone; import electrosphere.renderer.model.Bone;
@ -38,7 +38,7 @@ public class MeshLoader {
// VAO // VAO
// //
//Check for headless to not call gl functions when not running with gpu //Check for headless to not call gl functions when not running with gpu
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
rVal.generateVAO(); rVal.generateVAO();
} }
@ -310,7 +310,7 @@ public class MeshLoader {
boneWeightDataBuffer.flip(); boneWeightDataBuffer.flip();
} }
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
rVal.bufferBoneIndices(boneIndexDataBuffer); rVal.bufferBoneIndices(boneIndexDataBuffer);
rVal.bufferBoneWeights(boneWeightDataBuffer); rVal.bufferBoneWeights(boneWeightDataBuffer);
@ -334,7 +334,7 @@ public class MeshLoader {
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
rVal.setShader(VisualShader.smartAssembleShader(has_bones, apply_lighting)); rVal.setShader(VisualShader.smartAssembleShader(has_bones, apply_lighting));
rVal.setShader(VisualShader.smartAssembleShader(has_bones, apply_lighting)); rVal.setShader(VisualShader.smartAssembleShader(has_bones, apply_lighting));
rVal.setOITShader(VisualShader.smartAssembleOITProgram(has_bones, apply_lighting)); rVal.setOITShader(VisualShader.smartAssembleOITProgram(has_bones, apply_lighting));

View File

@ -1,6 +1,7 @@
package electrosphere.renderer.model; package electrosphere.renderer.model;
import electrosphere.client.entity.camera.CameraEntityUtils; import electrosphere.client.entity.camera.CameraEntityUtils;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.renderer.OpenGLState; import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState; import electrosphere.renderer.RenderPipelineState;
@ -131,7 +132,7 @@ public class Mesh {
* @param vertexDimension the dimensionality of the data (2d vectors, 3d vectors, 4d vectors, etc) * @param vertexDimension the dimensionality of the data (2d vectors, 3d vectors, 4d vectors, etc)
*/ */
public void bufferVertices(FloatBuffer verticies, int vertexDimension){ public void bufferVertices(FloatBuffer verticies, int vertexDimension){
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
vertexBuffer = bufferCustomFloatAttribArray(verticies,vertexDimension,0); vertexBuffer = bufferCustomFloatAttribArray(verticies,vertexDimension,0);
} }
} }
@ -142,7 +143,7 @@ public class Mesh {
* @param normalDimension the dimensionality of the data (2d vector, 3d vector, 4d vector) * @param normalDimension the dimensionality of the data (2d vector, 3d vector, 4d vector)
*/ */
public void bufferNormals(FloatBuffer normals, int normalDimension){ public void bufferNormals(FloatBuffer normals, int normalDimension){
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
normalBuffer = bufferCustomFloatAttribArray(normals,normalDimension,1); normalBuffer = bufferCustomFloatAttribArray(normals,normalDimension,1);
} }
} }
@ -153,7 +154,7 @@ public class Mesh {
* @param elementCount The number of faces * @param elementCount The number of faces
*/ */
public void bufferFaces(IntBuffer faces, int elementCount){ public void bufferFaces(IntBuffer faces, int elementCount){
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
elementArrayBuffer = glGenBuffers(); elementArrayBuffer = glGenBuffers();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementArrayBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementArrayBuffer);
GL15.glBufferData(GL_ELEMENT_ARRAY_BUFFER, faces, GL_STATIC_DRAW); GL15.glBufferData(GL_ELEMENT_ARRAY_BUFFER, faces, GL_STATIC_DRAW);
@ -175,7 +176,7 @@ public class Mesh {
* @param textureDimension The dimensionality of the texture coordinate data (3d vec, 4d vec, etc) * @param textureDimension The dimensionality of the texture coordinate data (3d vec, 4d vec, etc)
*/ */
public void bufferTextureCoords(FloatBuffer coords, int textureDimension){ public void bufferTextureCoords(FloatBuffer coords, int textureDimension){
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
textureCoordBuffer = bufferCustomFloatAttribArray(coords, textureDimension, 4); textureCoordBuffer = bufferCustomFloatAttribArray(coords, textureDimension, 4);
} }
} }
@ -213,7 +214,7 @@ public class Mesh {
*/ */
public int bufferCustomFloatAttribArray(FloatBuffer buffer, int bufferDimension, int attribIndex){ public int bufferCustomFloatAttribArray(FloatBuffer buffer, int bufferDimension, int attribIndex){
int bufferPointer = 0; int bufferPointer = 0;
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
bufferPointer = glGenBuffers(); bufferPointer = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, bufferPointer); glBindBuffer(GL_ARRAY_BUFFER, bufferPointer);
GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW); GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
@ -232,7 +233,7 @@ public class Mesh {
*/ */
public int bufferCustomIntAttribArray(IntBuffer buffer, int bufferDimension, int attribIndex){ public int bufferCustomIntAttribArray(IntBuffer buffer, int bufferDimension, int attribIndex){
int bufferPointer = 0; int bufferPointer = 0;
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
bufferPointer = glGenBuffers(); bufferPointer = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, bufferPointer); glBindBuffer(GL_ARRAY_BUFFER, bufferPointer);
GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW); GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
@ -252,7 +253,7 @@ public class Mesh {
*/ */
public int bufferCustomUIntAttribArray(IntBuffer buffer, int bufferDimension, int attribIndex){ public int bufferCustomUIntAttribArray(IntBuffer buffer, int bufferDimension, int attribIndex){
int bufferPointer = 0; int bufferPointer = 0;
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
bufferPointer = glGenBuffers(); bufferPointer = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, bufferPointer); glBindBuffer(GL_ARRAY_BUFFER, bufferPointer);
GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW); GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);

View File

@ -1,5 +1,6 @@
package electrosphere.renderer.texture; package electrosphere.renderer.texture;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.OpenGLState; import electrosphere.renderer.OpenGLState;
@ -146,7 +147,7 @@ public class Texture {
throw new Error("Path is empty"); throw new Error("Path is empty");
} }
this.path = path; this.path = path;
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
LoggerInterface.loggerRenderer.DEBUG("Setup texture object"); LoggerInterface.loggerRenderer.DEBUG("Setup texture object");
//generate the texture object on gpu //generate the texture object on gpu
this.texturePointer = GL40.glGenTextures(); this.texturePointer = GL40.glGenTextures();
@ -233,7 +234,7 @@ public class Texture {
* @param height the 'height' of the 'texture' * @param height the 'height' of the 'texture'
*/ */
public Texture(OpenGLState openGlState, ByteBuffer buffer, int width, int height){ public Texture(OpenGLState openGlState, ByteBuffer buffer, int width, int height){
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
//generate the texture object on gpu //generate the texture object on gpu
this.texturePointer = GL40.glGenTextures(); this.texturePointer = GL40.glGenTextures();
Globals.renderingEngine.checkError(); Globals.renderingEngine.checkError();
@ -268,7 +269,7 @@ public class Texture {
*/ */
public static Texture createBitmap(OpenGLState openGlState, ByteBuffer buffer, int width, int height){ public static Texture createBitmap(OpenGLState openGlState, ByteBuffer buffer, int width, int height){
Texture rVal = null; Texture rVal = null;
if(!Globals.HEADLESS){ if(!EngineState.EngineFlags.HEADLESS){
rVal = new Texture(); rVal = new Texture();
//generate the texture object on gpu //generate the texture object on gpu
rVal.texturePointer = GL40.glGenTextures(); rVal.texturePointer = GL40.glGenTextures();

View File

@ -3,6 +3,7 @@ package electrosphere.server.datacell;
import electrosphere.collision.CollisionEngine; import electrosphere.collision.CollisionEngine;
import electrosphere.collision.PhysicsEntityUtils; import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.collision.hitbox.HitboxManager; import electrosphere.collision.hitbox.HitboxManager;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.scene.Scene; import electrosphere.entity.scene.Scene;
@ -240,7 +241,7 @@ public class Realm {
// //
//simulate bullet physics engine step //simulate bullet physics engine step
if(Globals.RUN_PHYSICS){ if(EngineState.EngineFlags.RUN_PHYSICS){
collisionEngine.simulatePhysics((float)Globals.engineState.timekeeper.getSimFrameTime()); collisionEngine.simulatePhysics((float)Globals.engineState.timekeeper.getSimFrameTime());
collisionEngine.updateDynamicObjectTransforms(); collisionEngine.updateDynamicObjectTransforms();
PhysicsEntityUtils.serverRepositionEntities(this,collisionEngine); PhysicsEntityUtils.serverRepositionEntities(this,collisionEngine);

View File

@ -16,6 +16,7 @@ import org.joml.Vector3d;
import org.joml.Vector3i; import org.joml.Vector3i;
import electrosphere.client.block.BlockChunkData; import electrosphere.client.block.BlockChunkData;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.threads.ThreadCounts; import electrosphere.engine.threads.ThreadCounts;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
@ -711,7 +712,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
} }
//queue fluid simulation //queue fluid simulation
if(Globals.RUN_FLUIDS){ if(EngineState.EngineFlags.RUN_FLUIDS){
Vector3i cellPos = this.getCellWorldPosition(cell); Vector3i cellPos = this.getCellWorldPosition(cell);
if(cellPos != null){ if(cellPos != null){
this.serverFluidManager.queue(cellPos.x, cellPos.y, cellPos.z); this.serverFluidManager.queue(cellPos.x, cellPos.y, cellPos.z);
@ -720,7 +721,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
} }
//simulate fluids //simulate fluids
if(Globals.RUN_FLUIDS){ if(EngineState.EngineFlags.RUN_FLUIDS){
this.serverFluidManager.simulate((ServerFluidChunk fluidChunk) -> { this.serverFluidManager.simulate((ServerFluidChunk fluidChunk) -> {
ServerDataCell cell = getCellAtWorldPosition(fluidChunk.getWorldPosition()); ServerDataCell cell = getCellAtWorldPosition(fluidChunk.getWorldPosition());
ServerFluidChunk chunk = getFluidChunkAtPosition(fluidChunk.getWorldPosition()); ServerFluidChunk chunk = getFluidChunkAtPosition(fluidChunk.getWorldPosition());

View File

@ -1,6 +1,7 @@
package electrosphere.server.physics.fluid.manager; package electrosphere.server.physics.fluid.manager;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.server.datacell.ServerWorldData; import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.physics.fluid.diskmap.FluidDiskMap; import electrosphere.server.physics.fluid.diskmap.FluidDiskMap;
@ -74,7 +75,7 @@ public class ServerFluidManager {
ServerTerrainManager serverTerrainManager; ServerTerrainManager serverTerrainManager;
//controls whether fluid simulation should actually happen or not //controls whether fluid simulation should actually happen or not
boolean simulate = Globals.RUN_FLUIDS; boolean simulate = EngineState.EngineFlags.RUN_FLUIDS;
@Exclude @Exclude
/** /**

View File

@ -13,6 +13,7 @@ import electrosphere.data.foliage.FoliageType;
import electrosphere.data.foliage.FoliageTypeLoader; import electrosphere.data.foliage.FoliageTypeLoader;
import electrosphere.data.item.Item; import electrosphere.data.item.Item;
import electrosphere.data.item.ItemDataMap; import electrosphere.data.item.ItemDataMap;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.types.EntityTypes.EntityType; import electrosphere.entity.types.EntityTypes.EntityType;
import electrosphere.entity.types.common.CommonEntityUtils; import electrosphere.entity.types.common.CommonEntityUtils;
@ -32,7 +33,7 @@ public class SpawnAllEntitiesTests extends EntityTestTemplate {
@Disabled @Disabled
@IntegrationTest @IntegrationTest
public void spawnAllEntities(){ public void spawnAllEntities(){
Globals.ENGINE_DEBUG = false; EngineState.EngineFlags.ENGINE_DEBUG = false;
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
CreatureTypeLoader creatureLoader = Globals.gameConfigCurrent.getCreatureTypeLoader(); CreatureTypeLoader creatureLoader = Globals.gameConfigCurrent.getCreatureTypeLoader();

View File

@ -10,6 +10,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import static electrosphere.test.testutils.Assertions.*; import static electrosphere.test.testutils.Assertions.*;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.Main; import electrosphere.engine.Main;
import electrosphere.renderer.ui.elements.Div; import electrosphere.renderer.ui.elements.Div;
@ -30,8 +31,8 @@ public class UIExtensionTests {
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
Globals.WINDOW_DECORATED = false; Globals.WINDOW_DECORATED = false;
Globals.WINDOW_FULLSCREEN = true; Globals.WINDOW_FULLSCREEN = true;
Globals.RUN_AUDIO = false; EngineState.EngineFlags.RUN_AUDIO = false;
Globals.RUN_SCRIPTS = false; EngineState.EngineFlags.RUN_SCRIPTS = false;
Globals.WINDOW_WIDTH = 1920; Globals.WINDOW_WIDTH = 1920;
Globals.WINDOW_HEIGHT = 1080; Globals.WINDOW_HEIGHT = 1080;
EngineInit.initGraphicalEngine(); EngineInit.initGraphicalEngine();
@ -46,8 +47,8 @@ public class UIExtensionTests {
public void test_Screencapture_Match(){ public void test_Screencapture_Match(){
Globals.WINDOW_DECORATED = false; Globals.WINDOW_DECORATED = false;
Globals.WINDOW_FULLSCREEN = true; Globals.WINDOW_FULLSCREEN = true;
Globals.RUN_AUDIO = false; EngineState.EngineFlags.RUN_AUDIO = false;
Globals.RUN_SCRIPTS = false; EngineState.EngineFlags.RUN_SCRIPTS = false;
Globals.WINDOW_WIDTH = 1920; Globals.WINDOW_WIDTH = 1920;
Globals.WINDOW_HEIGHT = 1080; Globals.WINDOW_HEIGHT = 1080;
EngineInit.initGraphicalEngine(); EngineInit.initGraphicalEngine();
@ -72,8 +73,8 @@ public class UIExtensionTests {
public void test_Screencapture_Blank_Match(){ public void test_Screencapture_Blank_Match(){
Globals.WINDOW_DECORATED = false; Globals.WINDOW_DECORATED = false;
Globals.WINDOW_FULLSCREEN = true; Globals.WINDOW_FULLSCREEN = true;
Globals.RUN_AUDIO = false; EngineState.EngineFlags.RUN_AUDIO = false;
Globals.RUN_SCRIPTS = false; EngineState.EngineFlags.RUN_SCRIPTS = false;
Globals.WINDOW_WIDTH = 1920; Globals.WINDOW_WIDTH = 1920;
Globals.WINDOW_HEIGHT = 1080; Globals.WINDOW_HEIGHT = 1080;
EngineInit.initGraphicalEngine(); EngineInit.initGraphicalEngine();

View File

@ -2,7 +2,7 @@ package electrosphere.test.integration;
import electrosphere.test.annotations.IntegrationSetup; import electrosphere.test.annotations.IntegrationSetup;
import electrosphere.test.annotations.IntegrationTest; import electrosphere.test.annotations.IntegrationTest;
import electrosphere.engine.Globals; import electrosphere.engine.EngineState;
import electrosphere.engine.profiler.Profiler; import electrosphere.engine.profiler.Profiler;
import electrosphere.net.NetUtils; import electrosphere.net.NetUtils;
@ -10,9 +10,9 @@ public class StartupTest {
@IntegrationSetup @IntegrationSetup
public void testStartupHeadless(){ public void testStartupHeadless(){
Globals.RUN_CLIENT = false; EngineState.EngineFlags.RUN_CLIENT = false;
Globals.RUN_SERVER = true; EngineState.EngineFlags.RUN_SERVER = true;
Globals.HEADLESS = true; EngineState.EngineFlags.HEADLESS = true;
Profiler.PROFILE = false; Profiler.PROFILE = false;
NetUtils.setPort(0); NetUtils.setPort(0);
// Main.startUp(); // Main.startUp();

View File

@ -4,6 +4,7 @@ import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ExtensionContext;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.Main; import electrosphere.engine.Main;
import electrosphere.test.testutils.EngineInit; import electrosphere.test.testutils.EngineInit;
@ -18,8 +19,8 @@ public class UIExtension implements BeforeEachCallback, AfterEachCallback {
public void beforeEach(ExtensionContext context) throws Exception { public void beforeEach(ExtensionContext context) throws Exception {
Globals.WINDOW_DECORATED = false; Globals.WINDOW_DECORATED = false;
Globals.WINDOW_FULLSCREEN = true; Globals.WINDOW_FULLSCREEN = true;
Globals.RUN_AUDIO = false; EngineState.EngineFlags.RUN_AUDIO = false;
Globals.RUN_SCRIPTS = false; EngineState.EngineFlags.RUN_SCRIPTS = false;
Globals.WINDOW_WIDTH = 1920; Globals.WINDOW_WIDTH = 1920;
Globals.WINDOW_HEIGHT = 1080; Globals.WINDOW_HEIGHT = 1080;
EngineInit.initGraphicalEngine(); EngineInit.initGraphicalEngine();

View File

@ -4,6 +4,7 @@ import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import electrosphere.engine.EngineState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.Main; import electrosphere.engine.Main;
import electrosphere.engine.loadingthreads.LoadingThread; import electrosphere.engine.loadingthreads.LoadingThread;
@ -30,10 +31,10 @@ public class EngineInit {
* Initializes the engine * Initializes the engine
*/ */
public static void initHeadlessEngine(){ public static void initHeadlessEngine(){
Globals.RUN_CLIENT = true; EngineState.EngineFlags.RUN_CLIENT = true;
Globals.RUN_SERVER = true; EngineState.EngineFlags.RUN_SERVER = true;
Globals.RUN_AUDIO = false; EngineState.EngineFlags.RUN_AUDIO = false;
Globals.HEADLESS = true; EngineState.EngineFlags.HEADLESS = true;
Profiler.PROFILE = false; Profiler.PROFILE = false;
NetUtils.setPort(0); NetUtils.setPort(0);
Main.startUp(); Main.startUp();
@ -43,11 +44,11 @@ public class EngineInit {
* Initializes the engine * Initializes the engine
*/ */
public static void initGraphicalEngine(){ public static void initGraphicalEngine(){
Globals.RUN_CLIENT = true; EngineState.EngineFlags.RUN_CLIENT = true;
Globals.RUN_SERVER = true; EngineState.EngineFlags.RUN_SERVER = true;
Globals.RUN_AUDIO = false; EngineState.EngineFlags.RUN_AUDIO = false;
Globals.RUN_SCRIPTS = false; EngineState.EngineFlags.RUN_SCRIPTS = false;
Globals.HEADLESS = false; EngineState.EngineFlags.HEADLESS = false;
Profiler.PROFILE = false; Profiler.PROFILE = false;
NetUtils.setPort(0); NetUtils.setPort(0);
Main.startUp(); Main.startUp();