move engine flags under engine state
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
6fe1733d58
commit
3cc51c008c
@ -11,6 +11,7 @@ import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
|
||||
import electrosphere.client.terrain.sampling.ClientVoxelSampler;
|
||||
import electrosphere.data.audio.SurfaceAudioCollection;
|
||||
import electrosphere.data.audio.SurfaceAudioType;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
|
||||
@ -158,7 +159,7 @@ public class MovementAudioService {
|
||||
* @param type The interaction type
|
||||
*/
|
||||
public void playAudio(int voxelType, InteractionType type){
|
||||
if(Globals.RUN_AUDIO){
|
||||
if(EngineState.EngineFlags.RUN_AUDIO){
|
||||
String audioPath = this.getAudioPath(voxelType, type);
|
||||
if(audioPath != null){
|
||||
Globals.audioEngine.virtualAudioSourceManager.createVirtualAudioSource(audioPath, VirtualAudioSourceType.CREATURE, false);
|
||||
@ -173,7 +174,7 @@ public class MovementAudioService {
|
||||
* @param position The position of the audio
|
||||
*/
|
||||
public void playAudioPositional(int voxelType, InteractionType type, Vector3d position){
|
||||
if(Globals.RUN_AUDIO){
|
||||
if(EngineState.EngineFlags.RUN_AUDIO){
|
||||
String audioPath = this.getAudioPath(voxelType, type);
|
||||
if(audioPath != null){
|
||||
Globals.audioEngine.virtualAudioSourceManager.createVirtualAudioSource(audioPath, VirtualAudioSourceType.CREATURE, false, position);
|
||||
|
||||
@ -9,6 +9,7 @@ import electrosphere.client.fluid.manager.ClientFluidManager;
|
||||
import electrosphere.client.interact.ClientInteractionEngine;
|
||||
import electrosphere.client.terrain.manager.ClientTerrainManager;
|
||||
import electrosphere.client.ui.menu.ingame.ToolbarPreviewWindow;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityTags;
|
||||
@ -63,7 +64,7 @@ public class ClientSimulation {
|
||||
Globals.profiler.endCpuSample();
|
||||
//
|
||||
//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().updateDynamicObjectTransforms();
|
||||
}
|
||||
@ -184,7 +185,7 @@ public class ClientSimulation {
|
||||
Globals.clientState.clientTerrainManager.handleMessages();
|
||||
this.updateTerrainCellManager();
|
||||
}
|
||||
if(Globals.clientState.clientFluidManager != null && Globals.RUN_FLUIDS){
|
||||
if(Globals.clientState.clientFluidManager != null && EngineState.EngineFlags.RUN_FLUIDS){
|
||||
Globals.clientState.clientFluidManager.handleMessages();
|
||||
this.updateFluidCellManager();
|
||||
}
|
||||
@ -213,7 +214,7 @@ public class ClientSimulation {
|
||||
*/
|
||||
private void updateFluidCellManager(){
|
||||
//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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import electrosphere.client.ui.menu.ingame.MenuGeneratorsInventory;
|
||||
import electrosphere.client.ui.menu.ingame.InventoryMainWindow;
|
||||
import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsTitleMenu;
|
||||
import electrosphere.controls.ControlHandler.ControlsState;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
@ -192,7 +193,7 @@ public class WindowUtils {
|
||||
*/
|
||||
public static void attemptRedrawInventoryWindows(){
|
||||
//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.elementService.containsWindow(WindowStrings.WINDOW_CHARACTER)){
|
||||
//redraw if necessary
|
||||
|
||||
@ -8,6 +8,7 @@ import electrosphere.client.ui.components.VoxelSelectionPanel;
|
||||
import electrosphere.client.ui.menu.WindowStrings;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.data.voxel.VoxelType;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||
@ -132,8 +133,8 @@ public class MenuGeneratorsLevelEditor {
|
||||
Button launchButton = Button.createButton(saveName, () -> {
|
||||
//launch level
|
||||
LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LEVEL, saveName);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
EngineState.EngineFlags.RUN_CLIENT = true;
|
||||
EngineState.EngineFlags.RUN_SERVER = true;
|
||||
Globals.engineState.threadManager.start(loadingThread);
|
||||
}).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE);
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import electrosphere.client.ui.components.CharacterCustomizer;
|
||||
import electrosphere.client.ui.components.InputMacros;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.client.ui.menu.mainmenu.worldgen.MenuWorldSelect;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
|
||||
@ -89,8 +90,8 @@ public class MenuGeneratorsMultiplayer {
|
||||
rVal.addChild(Button.createButton("Host", () -> {
|
||||
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
EngineState.EngineFlags.RUN_CLIENT = true;
|
||||
EngineState.EngineFlags.RUN_SERVER = true;
|
||||
Globals.engineState.threadManager.start(serverThread);
|
||||
Globals.engineState.threadManager.start(clientThread);
|
||||
}));
|
||||
@ -126,8 +127,8 @@ public class MenuGeneratorsMultiplayer {
|
||||
//Address input
|
||||
//
|
||||
String ipAddress = "";
|
||||
if(Globals.netConfig != null && Globals.netConfig.getAddress() != null){
|
||||
ipAddress = Globals.netConfig.getAddress();
|
||||
if(Globals.gameConfigCurrent.getNetConfig() != null && Globals.gameConfigCurrent.getNetConfig().getAddress() != null){
|
||||
ipAddress = Globals.gameConfigCurrent.getNetConfig().getAddress();
|
||||
} else {
|
||||
ipAddress = NetUtils.getAddress();
|
||||
}
|
||||
@ -139,8 +140,8 @@ public class MenuGeneratorsMultiplayer {
|
||||
//Port input
|
||||
//
|
||||
String port = "";
|
||||
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
|
||||
port = Globals.netConfig.getPort();
|
||||
if(Globals.gameConfigCurrent.getNetConfig() != null && Globals.gameConfigCurrent.getNetConfig().getPort() != null){
|
||||
port = Globals.gameConfigCurrent.getNetConfig().getPort();
|
||||
} else {
|
||||
port = NetUtils.getPort() + "";
|
||||
}
|
||||
@ -152,8 +153,8 @@ public class MenuGeneratorsMultiplayer {
|
||||
//Username input
|
||||
//
|
||||
String username = "";
|
||||
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
|
||||
username = Globals.netConfig.getUsername();
|
||||
if(Globals.gameConfigCurrent.getNetConfig() != null && Globals.gameConfigCurrent.getNetConfig().getPort() != null){
|
||||
username = Globals.gameConfigCurrent.getNetConfig().getUsername();
|
||||
} else {
|
||||
username = "";
|
||||
}
|
||||
@ -166,8 +167,8 @@ public class MenuGeneratorsMultiplayer {
|
||||
//Password input
|
||||
//
|
||||
String password = "";
|
||||
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
|
||||
password = Globals.netConfig.getPassword();
|
||||
if(Globals.gameConfigCurrent.getNetConfig() != null && Globals.gameConfigCurrent.getNetConfig().getPort() != null){
|
||||
password = Globals.gameConfigCurrent.getNetConfig().getPassword();
|
||||
} else {
|
||||
password = "";
|
||||
}
|
||||
@ -182,8 +183,8 @@ public class MenuGeneratorsMultiplayer {
|
||||
Globals.clientState.clientUsername = usernameInput.getText();
|
||||
Globals.clientState.clientPassword = AuthenticationManager.getHashedString(passwordInput.getText());
|
||||
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = false;
|
||||
EngineState.EngineFlags.RUN_CLIENT = true;
|
||||
EngineState.EngineFlags.RUN_SERVER = false;
|
||||
Globals.engineState.threadManager.start(clientThread);
|
||||
}));
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import java.util.stream.Collectors;
|
||||
import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsTitleMenu;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
|
||||
@ -58,8 +59,8 @@ public class MenuWorldSelect {
|
||||
Globals.clientState.clientUsername = "username";
|
||||
Globals.clientState.clientPassword = AuthenticationManager.getHashedString("password");
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME, saveName, Globals.clientState.clientUsername, Globals.clientState.clientPassword);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
EngineState.EngineFlags.RUN_CLIENT = true;
|
||||
EngineState.EngineFlags.RUN_SERVER = true;
|
||||
Globals.engineState.threadManager.start(serverThread);
|
||||
} else {
|
||||
SaveUtils.loadSave(saveName.toLowerCase(), false);
|
||||
|
||||
@ -26,6 +26,7 @@ import electrosphere.controls.categories.ControlCategoryInventory;
|
||||
import electrosphere.controls.categories.ControlCategoryMainGame;
|
||||
import electrosphere.controls.categories.ControlCategoryMenuNav;
|
||||
import electrosphere.controls.categories.ControlCategoryTyping;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.renderer.ui.elements.Window;
|
||||
@ -396,7 +397,7 @@ public class ControlHandler {
|
||||
*/
|
||||
private void getMousePositionInBuffer(){
|
||||
//only if not headless, gather position
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
glfwGetCursorPos(Globals.renderingEngine.getWindowPtr(), this.mouseState.getMouseBufferX(), this.mouseState.getMouseBufferY());
|
||||
}
|
||||
}
|
||||
@ -406,7 +407,7 @@ public class ControlHandler {
|
||||
* @return true if pressed, false otherwise
|
||||
*/
|
||||
private boolean getButton1Raw(){
|
||||
if(Globals.HEADLESS){
|
||||
if(EngineState.EngineFlags.HEADLESS){
|
||||
return false;
|
||||
} else {
|
||||
return Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_1);
|
||||
@ -418,7 +419,7 @@ public class ControlHandler {
|
||||
* @return true if pressed, false otherwise
|
||||
*/
|
||||
private boolean getButton2Raw(){
|
||||
if(Globals.HEADLESS){
|
||||
if(EngineState.EngineFlags.HEADLESS){
|
||||
return false;
|
||||
} else {
|
||||
return Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_2);
|
||||
|
||||
@ -27,6 +27,7 @@ import electrosphere.data.units.UnitDefinitionFile;
|
||||
import electrosphere.data.units.UnitLoader;
|
||||
import electrosphere.data.voxel.VoxelData;
|
||||
import electrosphere.data.voxel.sampler.SamplerFile;
|
||||
import electrosphere.net.config.NetConfig;
|
||||
import electrosphere.server.macro.race.RaceMap;
|
||||
import electrosphere.server.macro.symbolism.SymbolMap;
|
||||
import electrosphere.util.FileUtils;
|
||||
@ -40,6 +41,11 @@ public class Config {
|
||||
* Top level user settings object
|
||||
*/
|
||||
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
|
||||
@ -115,6 +121,7 @@ public class Config {
|
||||
public static Config loadDefaultConfig(){
|
||||
Config config = new Config();
|
||||
config.userSettings = UserSettings.loadUserSettings();
|
||||
config.netConfig = NetConfig.readNetConfig();
|
||||
config.creatureTypeLoader = Config.loadCreatureTypes("Data/entity/creatures.json");
|
||||
config.itemMap = ItemDataMap.loadItemFiles("Data/entity/items.json");
|
||||
config.foliageMap = Config.loadFoliageTypes("Data/entity/foliage.json");
|
||||
@ -408,5 +415,13 @@ public class Config {
|
||||
public ItemSourcingMap getItemSourcingMap(){
|
||||
return this.itemSourcingMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the network config file if it exists
|
||||
* @return The config if it exists, null otherwise
|
||||
*/
|
||||
public NetConfig getNetConfig(){
|
||||
return netConfig;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -38,6 +38,11 @@ public class EngineState {
|
||||
*/
|
||||
public SignalSystem signalSystem;
|
||||
|
||||
/**
|
||||
* Engine-wide flags
|
||||
*/
|
||||
public EngineFlags flags = new EngineFlags();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -61,4 +66,80 @@ public class EngineState {
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -66,24 +66,15 @@ public class Globals {
|
||||
*/
|
||||
public static ServerState serverState;
|
||||
|
||||
//
|
||||
//Rendering Engine
|
||||
//
|
||||
/**
|
||||
* The rendering engine
|
||||
*/
|
||||
public static RenderingEngine renderingEngine;
|
||||
|
||||
//
|
||||
//Audio Engine
|
||||
//
|
||||
/**
|
||||
* The audio engine
|
||||
*/
|
||||
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;
|
||||
|
||||
//
|
||||
//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
|
||||
//
|
||||
@ -216,13 +173,6 @@ public class Globals {
|
||||
public static StructureScanningService structureScanningService;
|
||||
|
||||
|
||||
|
||||
//
|
||||
//Base engine creation flags
|
||||
//
|
||||
public static boolean HEADLESS = false;
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// Renderer flags
|
||||
|
||||
@ -43,6 +43,11 @@ public class Main {
|
||||
* Toggles automatic simulation
|
||||
*/
|
||||
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();
|
||||
|
||||
//init scripting engine
|
||||
if(Globals.RUN_SCRIPTS){
|
||||
if(EngineState.EngineFlags.RUN_SCRIPTS){
|
||||
Globals.engineState.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
|
||||
}
|
||||
|
||||
//controls
|
||||
if(Globals.RUN_CLIENT){
|
||||
if(EngineState.EngineFlags.RUN_CLIENT){
|
||||
Main.initControlHandler();
|
||||
}
|
||||
|
||||
@ -126,7 +131,7 @@ public class Main {
|
||||
}
|
||||
|
||||
//create the drawing context
|
||||
if(Globals.RUN_CLIENT && !Globals.HEADLESS){
|
||||
if(EngineState.EngineFlags.RUN_CLIENT && !EngineState.EngineFlags.HEADLESS){
|
||||
//create opengl context
|
||||
Globals.renderingEngine = new RenderingEngine();
|
||||
Globals.renderingEngine.createOpenglContext();
|
||||
@ -149,7 +154,7 @@ public class Main {
|
||||
|
||||
//create the audio context
|
||||
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.listAllDevices();
|
||||
Globals.initDefaultAudioResources();
|
||||
@ -161,10 +166,10 @@ public class Main {
|
||||
|
||||
//fire off a loading thread for the title menus/screen
|
||||
LoggerInterface.loggerStartup.INFO("Fire off loading thread");
|
||||
if(Globals.RUN_DEMO){
|
||||
if(EngineState.EngineFlags.RUN_DEMO){
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.DEMO_MENU);
|
||||
Globals.engineState.threadManager.start(serverThread);
|
||||
} else if(Globals.RUN_CLIENT){
|
||||
} else if(EngineState.EngineFlags.RUN_CLIENT){
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.TITLE_MENU);
|
||||
Globals.engineState.threadManager.start(serverThread);
|
||||
} else {
|
||||
@ -172,7 +177,7 @@ public class Main {
|
||||
}
|
||||
|
||||
//recapture the screen for rendering
|
||||
if(Globals.RUN_CLIENT && !Globals.HEADLESS){
|
||||
if(EngineState.EngineFlags.RUN_CLIENT && !EngineState.EngineFlags.HEADLESS){
|
||||
LoggerInterface.loggerStartup.INFO("Recapture screen");
|
||||
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
|
||||
///
|
||||
if(Globals.RUN_CLIENT){
|
||||
if(EngineState.EngineFlags.RUN_CLIENT){
|
||||
Globals.profiler.beginCpuSample("Load Assets");
|
||||
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin load assets");
|
||||
Globals.assetManager.loadAssetsInQueue();
|
||||
@ -242,7 +247,7 @@ public class Main {
|
||||
/// I N P U T C O N T R O L S
|
||||
///
|
||||
//Poll controls
|
||||
if(Globals.RUN_CLIENT){
|
||||
if(EngineState.EngineFlags.RUN_CLIENT){
|
||||
Globals.profiler.beginCpuSample("Poll Controls");
|
||||
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin recapture screen");
|
||||
Globals.controlHandler.pollControls();
|
||||
@ -262,7 +267,7 @@ public class Main {
|
||||
if(Globals.fileWatcherService != null){
|
||||
Globals.fileWatcherService.poll();
|
||||
}
|
||||
if(Globals.RUN_SCRIPTS && Globals.scriptEngine != null){
|
||||
if(EngineState.EngineFlags.RUN_SCRIPTS && Globals.scriptEngine != null){
|
||||
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
|
||||
///
|
||||
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.renderingEngine.drawScreen();
|
||||
Globals.profiler.endCpuSample();
|
||||
@ -348,7 +353,7 @@ public class Main {
|
||||
/// G A R B A G E C H E C K
|
||||
///
|
||||
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();
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
@ -360,12 +365,12 @@ public class Main {
|
||||
///
|
||||
/// S H U T D O W N C H E C K
|
||||
///
|
||||
if(Globals.HEADLESS){
|
||||
if(Globals.ENGINE_SHUTDOWN_FLAG){
|
||||
if(EngineState.EngineFlags.HEADLESS){
|
||||
if(EngineState.EngineFlags.ENGINE_SHUTDOWN_FLAG){
|
||||
running = false;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
///
|
||||
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");
|
||||
if(Globals.engineState.timekeeper.getMostRecentRawFrametime() < targetFramePeriod){
|
||||
Main.sleep((int)(1000.0 * (targetFramePeriod - Globals.engineState.timekeeper.getMostRecentRawFrametime())));
|
||||
|
||||
@ -3,7 +3,7 @@ package electrosphere.engine.cli;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.logger.Logger.LogLevel;
|
||||
|
||||
@ -15,9 +15,9 @@ public class CLIParser {
|
||||
String argCurrent = argList.get(i);
|
||||
switch(argCurrent){
|
||||
case "--headless": {
|
||||
Globals.RUN_CLIENT = false;
|
||||
Globals.RUN_SERVER = true;
|
||||
Globals.HEADLESS = true;
|
||||
EngineState.EngineFlags.RUN_CLIENT = false;
|
||||
EngineState.EngineFlags.RUN_SERVER = true;
|
||||
EngineState.EngineFlags.HEADLESS = true;
|
||||
} break;
|
||||
case "--maxLogs": {
|
||||
LoggerInterface.setInitLogLevel(LogLevel.LOOP_DEBUG);
|
||||
|
||||
@ -6,6 +6,7 @@ import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.client.ui.menu.MenuGenerators;
|
||||
import electrosphere.client.ui.menu.WindowStrings;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.entity.scene.SceneGenerator;
|
||||
@ -29,8 +30,8 @@ public class ChunkGenerationTestLoading {
|
||||
//
|
||||
//Set params we would expect to run with this thread
|
||||
//
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
EngineState.EngineFlags.RUN_CLIENT = true;
|
||||
EngineState.EngineFlags.RUN_SERVER = true;
|
||||
Globals.serverState.aiManager.setActive(false);
|
||||
|
||||
|
||||
@ -73,7 +74,7 @@ public class ChunkGenerationTestLoading {
|
||||
|
||||
//initialize the "virtual" objects simulation
|
||||
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
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
|
||||
@ -18,6 +18,7 @@ import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.client.ui.menu.mainmenu.MenuCharacterCreation;
|
||||
import electrosphere.controls.ControlHandler;
|
||||
import electrosphere.controls.cursor.CursorState;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
@ -203,7 +204,7 @@ public class ClientLoading {
|
||||
*/
|
||||
private static void initClientThread(){
|
||||
//start client networking
|
||||
if(Globals.RUN_CLIENT){
|
||||
if(EngineState.EngineFlags.RUN_CLIENT){
|
||||
Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
|
||||
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
|
||||
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 {
|
||||
TimeUnit.MILLISECONDS.sleep(10);
|
||||
} catch (InterruptedException ex) {
|
||||
|
||||
@ -6,6 +6,7 @@ import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.client.ui.menu.MenuGenerators;
|
||||
import electrosphere.client.ui.menu.WindowStrings;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.entity.scene.SceneGenerator;
|
||||
@ -41,7 +42,7 @@ public class DebugSPWorldLoading {
|
||||
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
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
|
||||
@ -7,6 +7,7 @@ import electrosphere.client.ui.menu.MenuGenerators;
|
||||
import electrosphere.client.ui.menu.WindowStrings;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsLevelEditor.LevelDescription;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.entity.scene.SceneFile;
|
||||
@ -49,8 +50,8 @@ public class LevelEditorLoading {
|
||||
//
|
||||
//Set params we would expect to run with this thread
|
||||
//
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
EngineState.EngineFlags.RUN_CLIENT = true;
|
||||
EngineState.EngineFlags.RUN_SERVER = true;
|
||||
Globals.serverState.aiManager.setActive(false);
|
||||
|
||||
|
||||
@ -69,7 +70,7 @@ public class LevelEditorLoading {
|
||||
//load just-created save
|
||||
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
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
|
||||
@ -6,6 +6,7 @@ import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.client.ui.menu.MenuGenerators;
|
||||
import electrosphere.client.ui.menu.WindowStrings;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
@ -39,7 +40,7 @@ public class LevelLoading {
|
||||
//load save
|
||||
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
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
|
||||
@ -13,6 +13,7 @@ import org.joml.Vector3i;
|
||||
import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.data.creature.CreatureData;
|
||||
import electrosphere.data.creature.visualattribute.VisualAttribute;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
@ -48,7 +49,7 @@ public class LoadingUtils {
|
||||
|
||||
static void initServerThread(){
|
||||
//start server networking
|
||||
if(Globals.RUN_SERVER){
|
||||
if(EngineState.EngineFlags.RUN_SERVER){
|
||||
Globals.serverState.server = new Server(NetUtils.getPort());
|
||||
Thread serverThread = new Thread(Globals.serverState.server);
|
||||
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
|
||||
*/
|
||||
static void initAuthenticationManager(boolean mock){
|
||||
if(Globals.RUN_SERVER){
|
||||
if(EngineState.EngineFlags.RUN_SERVER){
|
||||
Globals.authenticationManager = AuthenticationManager.create(mock);
|
||||
}
|
||||
}
|
||||
@ -69,7 +70,7 @@ public class LoadingUtils {
|
||||
|
||||
static void initClientThread(){
|
||||
//start client networking
|
||||
if(Globals.RUN_CLIENT){
|
||||
if(EngineState.EngineFlags.RUN_CLIENT){
|
||||
Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
|
||||
Globals.engineState.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package electrosphere.engine.loadingthreads;
|
||||
import electrosphere.client.ui.menu.MenuGenerators;
|
||||
import electrosphere.client.ui.menu.WindowStrings;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.entity.scene.SceneGenerator;
|
||||
@ -45,7 +46,7 @@ public class ServerLoading {
|
||||
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
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the local connection
|
||||
|
||||
@ -8,6 +8,7 @@ import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.client.ui.menu.MenuGenerators;
|
||||
import electrosphere.client.ui.menu.WindowStrings;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
@ -41,7 +42,7 @@ public class ViewportLoading {
|
||||
|
||||
//
|
||||
//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();
|
||||
LoadingUtils.initAuthenticationManager(true);
|
||||
Globals.clientState.clientUsername = "leveleditor";
|
||||
|
||||
@ -2,7 +2,7 @@ package electrosphere.engine.time;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.EngineState;
|
||||
|
||||
/**
|
||||
* Service that keeps track of time for main thread activities.
|
||||
@ -47,7 +47,7 @@ public class Timekeeper {
|
||||
* @return The time (in seconds)
|
||||
*/
|
||||
private double getTime(){
|
||||
if(Globals.HEADLESS){
|
||||
if(EngineState.EngineFlags.HEADLESS){
|
||||
return System.currentTimeMillis() - engineStartTime;
|
||||
} else {
|
||||
return GLFW.glfwGetTime();
|
||||
@ -60,7 +60,7 @@ public class Timekeeper {
|
||||
*/
|
||||
public void init(double simFrameTime){
|
||||
this.simFrameTime = simFrameTime;
|
||||
if(Globals.HEADLESS){
|
||||
if(EngineState.EngineFlags.HEADLESS){
|
||||
engineStartTime = System.currentTimeMillis();
|
||||
}
|
||||
currentTime = getTime();
|
||||
|
||||
@ -189,7 +189,6 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
|
||||
ViewModelData viewModelData = creatureType.getViewModelData();
|
||||
if(Globals.clientState.clientPlayer != null && message.getpropertyValue() == Globals.clientState.clientPlayer.getId()){
|
||||
LoggerInterface.loggerNetworking.DEBUG("Set this player's entity id!");
|
||||
Globals.clientCharacterID = message.getentityID();
|
||||
Globals.clientState.playerEntity = target;
|
||||
if(viewModelData != null && viewModelData.getFirstPersonModelPath() != null){
|
||||
Globals.clientState.firstPersonEntity = CreatureUtils.clientCreateViewModel(
|
||||
|
||||
@ -4,7 +4,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.util.Utilities;
|
||||
|
||||
@ -70,15 +69,17 @@ public class NetConfig {
|
||||
/**
|
||||
* Reads the net config file
|
||||
*/
|
||||
public static void readNetConfig(){
|
||||
public static NetConfig readNetConfig(){
|
||||
NetConfig rVal = null;
|
||||
File file = new File("./netconfig.json");
|
||||
if(file.exists()){
|
||||
try {
|
||||
Globals.netConfig = Utilities.deserialize(Files.readString(file.toPath()), NetConfig.class);
|
||||
rVal = Utilities.deserialize(Files.readString(file.toPath()), NetConfig.class);
|
||||
} catch (IOException e) {
|
||||
LoggerInterface.loggerFileIO.ERROR(e);
|
||||
}
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.net.server.protocol;
|
||||
|
||||
import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.net.parser.net.message.AuthMessage;
|
||||
import electrosphere.net.parser.net.message.PlayerMessage;
|
||||
@ -25,7 +26,7 @@ public class AuthProtocol implements ServerProtocolTemplate<AuthMessage> {
|
||||
Player newPlayer = new Player(connectionHandler, loginId);
|
||||
Globals.serverState.playerManager.registerPlayer(newPlayer);
|
||||
//there is a race condition here where if a local non-server client connects first then it breaks
|
||||
if(connectionHandler.getIPAddress().contains("127.0.0.1") && Globals.RUN_CLIENT == true && Globals.clientState.clientPlayer == null){
|
||||
if(connectionHandler.getIPAddress().contains("127.0.0.1") && EngineState.EngineFlags.RUN_CLIENT == true && Globals.clientState.clientPlayer == null){
|
||||
Globals.clientState.clientPlayer = newPlayer;
|
||||
}
|
||||
connectionHandler.addMessagetoOutgoingQueue(PlayerMessage.constructSet_IDMessage(connectionHandler.getPlayerId()));
|
||||
|
||||
@ -26,6 +26,7 @@ import org.lwjgl.opengl.GLDebugMessageCallback;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||
import electrosphere.engine.os.OSDragAndDrop;
|
||||
@ -221,13 +222,13 @@ public class RenderingEngine {
|
||||
glslVersion = "#version 450";
|
||||
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
|
||||
//headless option
|
||||
if(Globals.RUN_HIDDEN){
|
||||
if(EngineState.EngineFlags.RUN_HIDDEN){
|
||||
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
|
||||
}
|
||||
if(!Globals.WINDOW_DECORATED){
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ import org.lwjgl.assimp.AIMesh;
|
||||
import org.lwjgl.assimp.AIVector3D;
|
||||
import org.lwjgl.assimp.AIVertexWeight;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.loading.ModelPretransforms;
|
||||
import electrosphere.renderer.model.Bone;
|
||||
@ -38,7 +38,7 @@ public class MeshLoader {
|
||||
// VAO
|
||||
//
|
||||
//Check for headless to not call gl functions when not running with gpu
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
rVal.generateVAO();
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ public class MeshLoader {
|
||||
boneWeightDataBuffer.flip();
|
||||
}
|
||||
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
rVal.bufferBoneIndices(boneIndexDataBuffer);
|
||||
|
||||
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.setOITShader(VisualShader.smartAssembleOITProgram(has_bones, apply_lighting));
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.renderer.model;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
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)
|
||||
*/
|
||||
public void bufferVertices(FloatBuffer verticies, int vertexDimension){
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
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)
|
||||
*/
|
||||
public void bufferNormals(FloatBuffer normals, int normalDimension){
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
normalBuffer = bufferCustomFloatAttribArray(normals,normalDimension,1);
|
||||
}
|
||||
}
|
||||
@ -153,7 +154,7 @@ public class Mesh {
|
||||
* @param elementCount The number of faces
|
||||
*/
|
||||
public void bufferFaces(IntBuffer faces, int elementCount){
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
elementArrayBuffer = glGenBuffers();
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementArrayBuffer);
|
||||
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)
|
||||
*/
|
||||
public void bufferTextureCoords(FloatBuffer coords, int textureDimension){
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
textureCoordBuffer = bufferCustomFloatAttribArray(coords, textureDimension, 4);
|
||||
}
|
||||
}
|
||||
@ -213,7 +214,7 @@ public class Mesh {
|
||||
*/
|
||||
public int bufferCustomFloatAttribArray(FloatBuffer buffer, int bufferDimension, int attribIndex){
|
||||
int bufferPointer = 0;
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
bufferPointer = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, bufferPointer);
|
||||
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){
|
||||
int bufferPointer = 0;
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
bufferPointer = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, bufferPointer);
|
||||
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){
|
||||
int bufferPointer = 0;
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
bufferPointer = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, bufferPointer);
|
||||
GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package electrosphere.renderer.texture;
|
||||
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
@ -146,7 +147,7 @@ public class Texture {
|
||||
throw new Error("Path is empty");
|
||||
}
|
||||
this.path = path;
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
LoggerInterface.loggerRenderer.DEBUG("Setup texture object");
|
||||
//generate the texture object on gpu
|
||||
this.texturePointer = GL40.glGenTextures();
|
||||
@ -233,7 +234,7 @@ public class Texture {
|
||||
* @param height the 'height' of the 'texture'
|
||||
*/
|
||||
public Texture(OpenGLState openGlState, ByteBuffer buffer, int width, int height){
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
//generate the texture object on gpu
|
||||
this.texturePointer = GL40.glGenTextures();
|
||||
Globals.renderingEngine.checkError();
|
||||
@ -268,7 +269,7 @@ public class Texture {
|
||||
*/
|
||||
public static Texture createBitmap(OpenGLState openGlState, ByteBuffer buffer, int width, int height){
|
||||
Texture rVal = null;
|
||||
if(!Globals.HEADLESS){
|
||||
if(!EngineState.EngineFlags.HEADLESS){
|
||||
rVal = new Texture();
|
||||
//generate the texture object on gpu
|
||||
rVal.texturePointer = GL40.glGenTextures();
|
||||
|
||||
@ -3,6 +3,7 @@ package electrosphere.server.datacell;
|
||||
import electrosphere.collision.CollisionEngine;
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.collision.hitbox.HitboxManager;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.scene.Scene;
|
||||
@ -240,7 +241,7 @@ public class Realm {
|
||||
|
||||
//
|
||||
//simulate bullet physics engine step
|
||||
if(Globals.RUN_PHYSICS){
|
||||
if(EngineState.EngineFlags.RUN_PHYSICS){
|
||||
collisionEngine.simulatePhysics((float)Globals.engineState.timekeeper.getSimFrameTime());
|
||||
collisionEngine.updateDynamicObjectTransforms();
|
||||
PhysicsEntityUtils.serverRepositionEntities(this,collisionEngine);
|
||||
|
||||
@ -16,6 +16,7 @@ import org.joml.Vector3d;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
import electrosphere.client.block.BlockChunkData;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.threads.ThreadCounts;
|
||||
import electrosphere.entity.Entity;
|
||||
@ -711,7 +712,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
||||
}
|
||||
|
||||
//queue fluid simulation
|
||||
if(Globals.RUN_FLUIDS){
|
||||
if(EngineState.EngineFlags.RUN_FLUIDS){
|
||||
Vector3i cellPos = this.getCellWorldPosition(cell);
|
||||
if(cellPos != null){
|
||||
this.serverFluidManager.queue(cellPos.x, cellPos.y, cellPos.z);
|
||||
@ -720,7 +721,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
||||
}
|
||||
|
||||
//simulate fluids
|
||||
if(Globals.RUN_FLUIDS){
|
||||
if(EngineState.EngineFlags.RUN_FLUIDS){
|
||||
this.serverFluidManager.simulate((ServerFluidChunk fluidChunk) -> {
|
||||
ServerDataCell cell = getCellAtWorldPosition(fluidChunk.getWorldPosition());
|
||||
ServerFluidChunk chunk = getFluidChunkAtPosition(fluidChunk.getWorldPosition());
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.server.physics.fluid.manager;
|
||||
|
||||
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.server.datacell.ServerWorldData;
|
||||
import electrosphere.server.physics.fluid.diskmap.FluidDiskMap;
|
||||
@ -74,7 +75,7 @@ public class ServerFluidManager {
|
||||
ServerTerrainManager serverTerrainManager;
|
||||
|
||||
//controls whether fluid simulation should actually happen or not
|
||||
boolean simulate = Globals.RUN_FLUIDS;
|
||||
boolean simulate = EngineState.EngineFlags.RUN_FLUIDS;
|
||||
|
||||
@Exclude
|
||||
/**
|
||||
|
||||
@ -13,6 +13,7 @@ import electrosphere.data.foliage.FoliageType;
|
||||
import electrosphere.data.foliage.FoliageTypeLoader;
|
||||
import electrosphere.data.item.Item;
|
||||
import electrosphere.data.item.ItemDataMap;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
@ -32,7 +33,7 @@ public class SpawnAllEntitiesTests extends EntityTestTemplate {
|
||||
@Disabled
|
||||
@IntegrationTest
|
||||
public void spawnAllEntities(){
|
||||
Globals.ENGINE_DEBUG = false;
|
||||
EngineState.EngineFlags.ENGINE_DEBUG = false;
|
||||
assertDoesNotThrow(() -> {
|
||||
|
||||
CreatureTypeLoader creatureLoader = Globals.gameConfigCurrent.getCreatureTypeLoader();
|
||||
|
||||
@ -10,6 +10,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import static electrosphere.test.testutils.Assertions.*;
|
||||
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import electrosphere.renderer.ui.elements.Div;
|
||||
@ -30,8 +31,8 @@ public class UIExtensionTests {
|
||||
assertDoesNotThrow(() -> {
|
||||
Globals.WINDOW_DECORATED = false;
|
||||
Globals.WINDOW_FULLSCREEN = true;
|
||||
Globals.RUN_AUDIO = false;
|
||||
Globals.RUN_SCRIPTS = false;
|
||||
EngineState.EngineFlags.RUN_AUDIO = false;
|
||||
EngineState.EngineFlags.RUN_SCRIPTS = false;
|
||||
Globals.WINDOW_WIDTH = 1920;
|
||||
Globals.WINDOW_HEIGHT = 1080;
|
||||
EngineInit.initGraphicalEngine();
|
||||
@ -46,8 +47,8 @@ public class UIExtensionTests {
|
||||
public void test_Screencapture_Match(){
|
||||
Globals.WINDOW_DECORATED = false;
|
||||
Globals.WINDOW_FULLSCREEN = true;
|
||||
Globals.RUN_AUDIO = false;
|
||||
Globals.RUN_SCRIPTS = false;
|
||||
EngineState.EngineFlags.RUN_AUDIO = false;
|
||||
EngineState.EngineFlags.RUN_SCRIPTS = false;
|
||||
Globals.WINDOW_WIDTH = 1920;
|
||||
Globals.WINDOW_HEIGHT = 1080;
|
||||
EngineInit.initGraphicalEngine();
|
||||
@ -72,8 +73,8 @@ public class UIExtensionTests {
|
||||
public void test_Screencapture_Blank_Match(){
|
||||
Globals.WINDOW_DECORATED = false;
|
||||
Globals.WINDOW_FULLSCREEN = true;
|
||||
Globals.RUN_AUDIO = false;
|
||||
Globals.RUN_SCRIPTS = false;
|
||||
EngineState.EngineFlags.RUN_AUDIO = false;
|
||||
EngineState.EngineFlags.RUN_SCRIPTS = false;
|
||||
Globals.WINDOW_WIDTH = 1920;
|
||||
Globals.WINDOW_HEIGHT = 1080;
|
||||
EngineInit.initGraphicalEngine();
|
||||
|
||||
@ -2,7 +2,7 @@ package electrosphere.test.integration;
|
||||
|
||||
import electrosphere.test.annotations.IntegrationSetup;
|
||||
import electrosphere.test.annotations.IntegrationTest;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.profiler.Profiler;
|
||||
import electrosphere.net.NetUtils;
|
||||
|
||||
@ -10,9 +10,9 @@ public class StartupTest {
|
||||
|
||||
@IntegrationSetup
|
||||
public void testStartupHeadless(){
|
||||
Globals.RUN_CLIENT = false;
|
||||
Globals.RUN_SERVER = true;
|
||||
Globals.HEADLESS = true;
|
||||
EngineState.EngineFlags.RUN_CLIENT = false;
|
||||
EngineState.EngineFlags.RUN_SERVER = true;
|
||||
EngineState.EngineFlags.HEADLESS = true;
|
||||
Profiler.PROFILE = false;
|
||||
NetUtils.setPort(0);
|
||||
// Main.startUp();
|
||||
|
||||
@ -4,6 +4,7 @@ import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import electrosphere.test.testutils.EngineInit;
|
||||
@ -18,8 +19,8 @@ public class UIExtension implements BeforeEachCallback, AfterEachCallback {
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
Globals.WINDOW_DECORATED = false;
|
||||
Globals.WINDOW_FULLSCREEN = true;
|
||||
Globals.RUN_AUDIO = false;
|
||||
Globals.RUN_SCRIPTS = false;
|
||||
EngineState.EngineFlags.RUN_AUDIO = false;
|
||||
EngineState.EngineFlags.RUN_SCRIPTS = false;
|
||||
Globals.WINDOW_WIDTH = 1920;
|
||||
Globals.WINDOW_HEIGHT = 1080;
|
||||
EngineInit.initGraphicalEngine();
|
||||
|
||||
@ -4,6 +4,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
import electrosphere.engine.EngineState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||
@ -30,10 +31,10 @@ public class EngineInit {
|
||||
* Initializes the engine
|
||||
*/
|
||||
public static void initHeadlessEngine(){
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
Globals.RUN_AUDIO = false;
|
||||
Globals.HEADLESS = true;
|
||||
EngineState.EngineFlags.RUN_CLIENT = true;
|
||||
EngineState.EngineFlags.RUN_SERVER = true;
|
||||
EngineState.EngineFlags.RUN_AUDIO = false;
|
||||
EngineState.EngineFlags.HEADLESS = true;
|
||||
Profiler.PROFILE = false;
|
||||
NetUtils.setPort(0);
|
||||
Main.startUp();
|
||||
@ -43,11 +44,11 @@ public class EngineInit {
|
||||
* Initializes the engine
|
||||
*/
|
||||
public static void initGraphicalEngine(){
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
Globals.RUN_AUDIO = false;
|
||||
Globals.RUN_SCRIPTS = false;
|
||||
Globals.HEADLESS = false;
|
||||
EngineState.EngineFlags.RUN_CLIENT = true;
|
||||
EngineState.EngineFlags.RUN_SERVER = true;
|
||||
EngineState.EngineFlags.RUN_AUDIO = false;
|
||||
EngineState.EngineFlags.RUN_SCRIPTS = false;
|
||||
EngineState.EngineFlags.HEADLESS = false;
|
||||
Profiler.PROFILE = false;
|
||||
NetUtils.setPort(0);
|
||||
Main.startUp();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user