public abstract class GameScriptingEngine
extends java.lang.Object
implements java.lang.Runnable
| Modifier and Type | Field and Description |
|---|---|
static GameScriptingEngine |
MOST_RECENT_INSTANCE
Returns the most recently created
GameScriptingEngine |
| Constructor and Description |
|---|
GameScriptingEngine()
Constructs a scripting engine backed by a thread pool with the maximum
amount of concurrent scripts set to the amount of processors + 1.
|
GameScriptingEngine(boolean sandboxed)
Constructs a scripting engine backed by a thread pool with the maximum
amount of concurrent scripts set to the amount of processors + 1.
|
GameScriptingEngine(int maxConcurrentScripts)
Constructs a scripting engine backed by a thread pool.
|
GameScriptingEngine(int maxConcurrentScripts,
boolean sandboxed)
Constructs a scripting engine backed by a thread pool.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compileScript(java.io.InputStream inputStream)
Compiles a script for execution.
|
int |
compileScript(java.lang.String scriptContent)
Compiles a script for execution.
|
protected abstract ScriptExecutorPool<?> |
createScriptExecutorPool(int poolSize,
boolean sandboxing) |
void |
dispose()
Shuts down the thread pool and cleans up resources
|
void |
invokeCompiledScript(int scriptId,
ScriptBindings scriptBindings)
Queues a compiled script for execution in the engine's thread pool
|
void |
invokeCompiledScript(int scriptId,
ScriptBindings scriptBindings,
ScriptInvocationListener invocationListener)
Queues a compiled script for execution in the engine's thread pool
|
void |
invokeCompiledScriptLocally(int scriptId,
ScriptBindings scriptBindings)
Executes a compiled script immediately on the thread calling this method.
|
void |
invokeCompiledScriptLocally(int scriptId,
ScriptBindings scriptBindings,
ScriptInvocationListener invocationListener)
Executes a compiled script immediately on the thread calling this method.
|
int |
invokeScript(java.lang.String scriptContent,
ScriptBindings scriptBindings)
Compiles and queues a script for execution in the engine's thread pool
|
int |
invokeScript(java.lang.String scriptContent,
ScriptBindings scriptBindings,
ScriptInvocationListener invocationListener)
Compiles and queues a script for execution in the engine's thread pool
|
abstract boolean |
isSandboxingSupported()
Checks if sandboxing is supported by the
GameScriptingEngine
implementation |
void |
run()
This should not be invoked by the developer.
|
void |
setCancelReallocatedFutures(boolean cancelReallocatedFutures)
Sets if newly
GameFutures should cancel a previously scheduled
GameFuture with the same ID. |
void |
skipAllGameFutures()
Skips all currently running
GameFutures |
void |
skipAllScripts()
Skips all currently running scripts
|
void |
skipScript(int scriptId)
Skips a currently running script
|
void |
update(float delta)
Updates all
GameFutures |
public static GameScriptingEngine MOST_RECENT_INSTANCE
GameScriptingEnginepublic GameScriptingEngine()
public GameScriptingEngine(int maxConcurrentScripts)
maxConcurrentScripts - The maximum amount of concurrently running scripts. WARNING:
this is a 'requested' amount and may be less due to the amount
of available processors on the player's machine.public GameScriptingEngine(boolean sandboxed)
sandboxed - True if script sandboxing should be enabledpublic GameScriptingEngine(int maxConcurrentScripts,
boolean sandboxed)
maxConcurrentScripts - The maximum amount of concurrently running scripts. WARNING:
this is a 'requested' amount and may be less due to the amount
of available processors on the player's machine.sandboxed - True if script sandboxing should be enabledpublic void dispose()
public abstract boolean isSandboxingSupported()
GameScriptingEngine
implementationprotected abstract ScriptExecutorPool<?> createScriptExecutorPool(int poolSize, boolean sandboxing)
public void update(float delta)
GameFuturesdelta - The time (in seconds) since the last frame updatepublic void run()
update(float)
instead.run in interface java.lang.Runnablepublic void skipAllScripts()
public void skipScript(int scriptId)
scriptId - The ID of the script to skippublic void skipAllGameFutures()
GameFuturespublic int compileScript(java.lang.String scriptContent)
throws InsufficientCompilersException
InsufficientCompilersExceptionscriptContent - The text contents of the scriptInsufficientCompilersException - Thrown if there are no script compilers availableInsufficientCompilersException - Thrown if there are no script compilers availablepublic int compileScript(java.io.InputStream inputStream)
throws InsufficientCompilersException,
java.io.IOException
InsufficientCompilersExceptioninputStream - The InputStream to read the script contents fromInsufficientCompilersException - Thrown if there are no script compilers availablejava.io.IOException - Throw if the InputStream could not be read or closedpublic void invokeCompiledScript(int scriptId,
ScriptBindings scriptBindings)
scriptId - The id of the script to runscriptBindings - The variable bindings for the scriptpublic void invokeCompiledScript(int scriptId,
ScriptBindings scriptBindings,
ScriptInvocationListener invocationListener)
scriptId - The id of the script to runscriptBindings - The variable bindings for the scriptinvocationListener - A ScriptInvocationListener to list for invocation
resultspublic int invokeScript(java.lang.String scriptContent,
ScriptBindings scriptBindings)
throws InsufficientCompilersException
scriptContent - The text content of the scriptscriptBindings - The variable bindings for the scriptInsufficientCompilersException - Thrown if there are no script compilers availablepublic int invokeScript(java.lang.String scriptContent,
ScriptBindings scriptBindings,
ScriptInvocationListener invocationListener)
throws InsufficientCompilersException
scriptContent - The text content of the scriptscriptBindings - The variable bindings for the scriptinvocationListener - A ScriptInvocationListener to list for invocation
resultsInsufficientCompilersException - Thrown if there are no script compilers availablepublic void invokeCompiledScriptLocally(int scriptId,
ScriptBindings scriptBindings)
ScriptExecutors are available this will block
until one is availablescriptId - The script idscriptBindings - The variable bindings for the scriptpublic void invokeCompiledScriptLocally(int scriptId,
ScriptBindings scriptBindings,
ScriptInvocationListener invocationListener)
ScriptExecutors are available this will block
until one is availablescriptId - The script idscriptBindings - The variable bindings for the scriptinvocationListener - A ScriptInvocationListener to list for invocation
resultspublic void setCancelReallocatedFutures(boolean cancelReallocatedFutures)
GameFutures should cancel a previously scheduled
GameFuture with the same ID. IDs attempt be unique but if there
are GameFutures that never complete IDs may come into conflict
after millions of generated GameFutures. Defaults to true.cancelReallocatedFutures - True if existing GameFutures with same ID should be
cancelled