make script engine optional for startup
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
211389812d
commit
f70844c74b
3
.gitignore
vendored
3
.gitignore
vendored
@ -58,3 +58,6 @@
|
|||||||
|
|
||||||
#spreadsheet stuff
|
#spreadsheet stuff
|
||||||
*/~$*.xlsx
|
*/~$*.xlsx
|
||||||
|
|
||||||
|
#General cache for the engine
|
||||||
|
/.cache
|
||||||
@ -160,6 +160,7 @@ public class Globals {
|
|||||||
public static boolean RUN_CLIENT = true;
|
public static boolean RUN_CLIENT = true;
|
||||||
public static boolean RUN_HIDDEN = false; //glfw session will be created with hidden window
|
public static boolean RUN_HIDDEN = false; //glfw session will be created with hidden window
|
||||||
public static boolean RUN_AUDIO = true;
|
public static boolean RUN_AUDIO = true;
|
||||||
|
public static boolean RUN_SCRIPTS = false;
|
||||||
public static int clientCharacterID;
|
public static int clientCharacterID;
|
||||||
public static NetConfig netConfig = null;
|
public static NetConfig netConfig = null;
|
||||||
|
|
||||||
@ -545,7 +546,6 @@ public class Globals {
|
|||||||
for(String path : audioToInit){
|
for(String path : audioToInit){
|
||||||
Globals.assetManager.addAudioPathToQueue(path);
|
Globals.assetManager.addAudioPathToQueue(path);
|
||||||
}
|
}
|
||||||
Globals.assetManager.loadAssetsInQueue();
|
|
||||||
Globals.movementAudioService.init();
|
Globals.movementAudioService.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,8 +86,9 @@ public class Main {
|
|||||||
Globals.initGlobals();
|
Globals.initGlobals();
|
||||||
|
|
||||||
//init scripting engine
|
//init scripting engine
|
||||||
Globals.scriptEngine.init();
|
if(Globals.RUN_SCRIPTS){
|
||||||
// Globals.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
|
Globals.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
|
||||||
|
}
|
||||||
|
|
||||||
//controls
|
//controls
|
||||||
if(Globals.RUN_CLIENT){
|
if(Globals.RUN_CLIENT){
|
||||||
|
|||||||
@ -59,6 +59,11 @@ public class ScriptEngine {
|
|||||||
*/
|
*/
|
||||||
Value hookManager;
|
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
|
//The files that are loaded on init to bootstrap the script engine
|
||||||
static final String[] filesToLoadOnInit = new String[]{
|
static final String[] filesToLoadOnInit = new String[]{
|
||||||
//polyfills
|
//polyfills
|
||||||
@ -102,6 +107,7 @@ public class ScriptEngine {
|
|||||||
public void init(){
|
public void init(){
|
||||||
//init datastructures
|
//init datastructures
|
||||||
sourceMap = new HashMap<String,Source>();
|
sourceMap = new HashMap<String,Source>();
|
||||||
|
initialized = false;
|
||||||
|
|
||||||
//create engine with flag to disable warning
|
//create engine with flag to disable warning
|
||||||
Engine engine = Engine.newBuilder()
|
Engine engine = Engine.newBuilder()
|
||||||
@ -166,6 +172,7 @@ public class ScriptEngine {
|
|||||||
// // TODO Auto-generated catch block
|
// // TODO Auto-generated catch block
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -409,6 +416,14 @@ public class ScriptEngine {
|
|||||||
Value fireSignal = this.hookManager.getMember("fireSignal");
|
Value fireSignal = this.hookManager.getMember("fireSignal");
|
||||||
fireSignal.execute(sceneInstanceId,signal,args);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -272,10 +272,12 @@ public class Realm {
|
|||||||
* @param args The arguments provided alongside the signal
|
* @param args The arguments provided alongside the signal
|
||||||
*/
|
*/
|
||||||
public void fireSignal(String signalName, Object ... args){
|
public void fireSignal(String signalName, Object ... args){
|
||||||
if(this.sceneInstanceId != NO_SCENE_INSTANCE){
|
if(Globals.scriptEngine != null && Globals.scriptEngine.isInitialized()){
|
||||||
Globals.scriptEngine.fireSignal(signalName, sceneInstanceId, args);
|
if(this.sceneInstanceId != NO_SCENE_INSTANCE){
|
||||||
} else {
|
Globals.scriptEngine.fireSignal(signalName, sceneInstanceId, args);
|
||||||
Globals.scriptEngine.fireSignal(signalName, ScriptEngine.GLOBAL_SCENE, args);
|
} else {
|
||||||
|
Globals.scriptEngine.fireSignal(signalName, ScriptEngine.GLOBAL_SCENE, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,7 @@ public class EngineInit {
|
|||||||
Globals.RUN_CLIENT = true;
|
Globals.RUN_CLIENT = true;
|
||||||
Globals.RUN_SERVER = true;
|
Globals.RUN_SERVER = true;
|
||||||
Globals.RUN_AUDIO = false;
|
Globals.RUN_AUDIO = false;
|
||||||
|
Globals.RUN_SCRIPTS = false;
|
||||||
Globals.HEADLESS = false;
|
Globals.HEADLESS = false;
|
||||||
Profiler.PROFILE = false;
|
Profiler.PROFILE = false;
|
||||||
NetUtils.setPort(0);
|
NetUtils.setPort(0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user