make script engine optional for startup
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-09-10 18:13:08 -04:00
parent 211389812d
commit f70844c74b
6 changed files with 29 additions and 7 deletions

3
.gitignore vendored
View File

@ -58,3 +58,6 @@
#spreadsheet stuff
*/~$*.xlsx
#General cache for the engine
/.cache

View File

@ -160,6 +160,7 @@ public class Globals {
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 = false;
public static int clientCharacterID;
public static NetConfig netConfig = null;
@ -545,7 +546,6 @@ public class Globals {
for(String path : audioToInit){
Globals.assetManager.addAudioPathToQueue(path);
}
Globals.assetManager.loadAssetsInQueue();
Globals.movementAudioService.init();
}

View File

@ -86,8 +86,9 @@ public class Main {
Globals.initGlobals();
//init scripting engine
Globals.scriptEngine.init();
// Globals.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
if(Globals.RUN_SCRIPTS){
Globals.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
}
//controls
if(Globals.RUN_CLIENT){

View File

@ -59,6 +59,11 @@ public class ScriptEngine {
*/
Value hookManager;
/**
* Tracks the initialization status of the script engine
*/
boolean initialized = false;
//The files that are loaded on init to bootstrap the script engine
static final String[] filesToLoadOnInit = new String[]{
//polyfills
@ -102,6 +107,7 @@ public class ScriptEngine {
public void init(){
//init datastructures
sourceMap = new HashMap<String,Source>();
initialized = false;
//create engine with flag to disable warning
Engine engine = Engine.newBuilder()
@ -166,6 +172,7 @@ public class ScriptEngine {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
initialized = true;
}
/**
@ -409,6 +416,14 @@ public class ScriptEngine {
Value fireSignal = this.hookManager.getMember("fireSignal");
fireSignal.execute(sceneInstanceId,signal,args);
}
/**
* Gets the initialization status of the script engine
* @return true if initialized, false otherwise
*/
public boolean isInitialized(){
return this.initialized;
}
}

View File

@ -272,10 +272,12 @@ public class Realm {
* @param args The arguments provided alongside the signal
*/
public void fireSignal(String signalName, Object ... args){
if(this.sceneInstanceId != NO_SCENE_INSTANCE){
Globals.scriptEngine.fireSignal(signalName, sceneInstanceId, args);
} else {
Globals.scriptEngine.fireSignal(signalName, ScriptEngine.GLOBAL_SCENE, args);
if(Globals.scriptEngine != null && Globals.scriptEngine.isInitialized()){
if(this.sceneInstanceId != NO_SCENE_INSTANCE){
Globals.scriptEngine.fireSignal(signalName, sceneInstanceId, args);
} else {
Globals.scriptEngine.fireSignal(signalName, ScriptEngine.GLOBAL_SCENE, args);
}
}
}

View File

@ -36,6 +36,7 @@ public class EngineInit {
Globals.RUN_CLIENT = true;
Globals.RUN_SERVER = true;
Globals.RUN_AUDIO = false;
Globals.RUN_SCRIPTS = false;
Globals.HEADLESS = false;
Profiler.PROFILE = false;
NetUtils.setPort(0);