Class EngineFacade
- java.lang.Object
-
- de.extio.spacecraft.shared.client.EngineFacade
-
public abstract class EngineFacade extends Object
Facade of the game engine. This is the main class you are using to interact with the game. With this facade you can access all managers of subsystems as well as business objects and general engine functions.
It can only be accessed when in the context of a game client thread.
Example how to use the facade: EngineFacade.instance().getWorldManager().doSomething()
-
-
Field Summary
Fields Modifier and Type Field Description protected static ThreadLocal<Boolean>
IN_CLIENT_CONTEXT
protected static EngineFacade
INSTANCE
protected static boolean
STARTED
-
Constructor Summary
Constructors Modifier Constructor Description protected
EngineFacade()
EngineFacade is a singleton, use .instance()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
abortFrameExecution()
Aborts execution of the current frame.abstract void
closeNetworkClient(boolean block)
Disconnects from a remote serverabstract void
connectToRemoteServer(String destination)
Connects to a remote game serverabstract Random
createRandomGenerator(long seed)
Creates a random number generator with a given seedabstract void
dispatchMessage(AbstractMessage message)
Sends a message.abstract void
externalLobbyInvite(String quickJoinCode)
abstract boolean
externalLobbyInviteAvailable()
abstract boolean
externalOverlayAvailable()
abstract AchievementsManager
getAchievementsManager()
The achievements managerabstract ActionsDefManager
getActionsDefManager()
The actions definitions managerabstract AudioControl
getAudioControl()
The audio controllerabstract <T> T
getBusinessObject(Class<? extends T> clazz)
Business objects implementing various game mechanics.abstract ClientState
getClientState()
Client side custom state.abstract Random
getEngineRng()
A random number generatorabstract EntityDefManager
getEntityDefManager()
The entity definitions managerabstract EventManager
getEventManager()
The event managerabstract long
getFrame()
Identifies the current frame being rendered.abstract Game
getGame()
The client side representation of the game sessionabstract KeycodeRegistry
getKeycodeRegistry()
The keycode registryabstract LocalizationManager
getLocalizationManager()
The localization managerabstract MenuLauncher
getMenuLauncher()
The menu launcherabstract MetaserverClient
getMetaserverClient()
Api client for the metaserverabstract ModManager
getModManager()
The mod managerabstract ClientModuleManager
getModuleManager()
The module managerabstract ObjectSerialization
getObjectSerialization()
The object de-/serializerabstract ClientOptions
getOptions()
Options configured in the options menuabstract PersistentClientState
getPersistentClientState()
Client side custom state that can be persisted to disk and will be loaded again next time the client starts.abstract RendererControl
getRendererControl()
Controls the rendererabstract RenderingBoPool
getRenderingBoPool()
A pool of RenderingBo.abstract ScriptingManager
getScriptingManager()
The scripting managerabstract SecurityFacade
getSecurityFacade()
The security facadeabstract ShipClassManager
getShipClassManager()
The ship class managerabstract StorageManager
getStorageManager()
The storage managerabstract TilesetManager<?>
getTilesetManager()
The tilesets managerabstract UiOptions
getUiOptions()
General options of the UIabstract VersionManager
getVersionManager()
The version managerabstract WorldManager
getWorldManager()
The world managerstatic EngineFacade
instance()
EngineFacade is a singleton, use this method to access the facadestatic EngineFacade
instance(boolean checkContext)
EngineFacade is a singleton, use this method to access the facadeabstract boolean
isEmbeddedServerRunning()
Checks whether an embedded game server is runningstatic boolean
isInClientContext()
Checks whether the current thread is running in context of the game client (i.e.abstract boolean
isLastConnectedNetworkRemote()
Checks whether the last connected server was a remote server or the embedded serverabstract boolean
isRemoteNetworkClientAlive()
Checks whether the remote network client is alive.abstract boolean
isRemoteNetworkClientConnected()
Checks whether connected to a remote serverabstract InputStream
loadDefaultModResource(String resourceName)
Loads a file resource from default mod directory.abstract InputStream
loadResource(String resourceName)
Loads a file resource cumulative, this means from the last mod that provides it.abstract InputStream
loadResource(String modName, String resourceName)
Loads a file resource from mod directory.abstract <T> T
loadXml(File file, Class<T> clazz)
abstract void
reconnectToRemoteServer()
Tries to reconnect to the last remote serverabstract void
relaunchEmbeddedServer()
Launches and connects to the embedded game serverabstract void
reportError(String module, String message)
Reports an error to the error reporterabstract void
shutdown()
Shuts down the game clientabstract void
stopEmbeddedServer()
Stops the embedded game serverabstract void
storePersistentClientState()
Saves the persistent client state.abstract void
storeXml(File file, Object obj)
abstract void
takeScreenshot()
Takes a screenshot.
-
-
-
Field Detail
-
INSTANCE
protected static EngineFacade INSTANCE
-
STARTED
protected static volatile boolean STARTED
-
IN_CLIENT_CONTEXT
protected static ThreadLocal<Boolean> IN_CLIENT_CONTEXT
-
-
Method Detail
-
instance
public static EngineFacade instance()
EngineFacade is a singleton, use this method to access the facade
-
instance
public static EngineFacade instance(boolean checkContext)
EngineFacade is a singleton, use this method to access the facade- Parameters:
checkContext
- Checks whether called in client context. This makes sure it is not accidently called from the game server, which will have undefined effects. Only bypass this check if you know what you are doing.
-
isInClientContext
public static boolean isInClientContext()
Checks whether the current thread is running in context of the game client (i.e. is not part of the game server).
-
getEventManager
public abstract EventManager getEventManager()
The event manager
-
getModuleManager
public abstract ClientModuleManager getModuleManager()
The module manager
-
getRendererControl
public abstract RendererControl getRendererControl()
Controls the renderer
-
getRenderingBoPool
public abstract RenderingBoPool getRenderingBoPool()
A pool of RenderingBo. It is important to acquire business objects for rendering from this pool instead of creating own instances
-
getUiOptions
public abstract UiOptions getUiOptions()
General options of the UI
-
getFrame
public abstract long getFrame()
Identifies the current frame being rendered. It's an increment
-
getGame
public abstract Game getGame()
The client side representation of the game session
-
getOptions
public abstract ClientOptions getOptions()
Options configured in the options menu
-
getClientState
public abstract ClientState getClientState()
Client side custom state. Can be used to exchange information (e.g. client settings data objects) between modules.
-
getPersistentClientState
public abstract PersistentClientState getPersistentClientState()
Client side custom state that can be persisted to disk and will be loaded again next time the client starts. Can be used to store simple settings without using the storage subsystem.
-
getMenuLauncher
public abstract MenuLauncher getMenuLauncher()
The menu launcher
-
getLocalizationManager
public abstract LocalizationManager getLocalizationManager()
The localization manager
-
getStorageManager
public abstract StorageManager getStorageManager()
The storage manager
-
getBusinessObject
public abstract <T> T getBusinessObject(Class<? extends T> clazz)
Business objects implementing various game mechanics. See .shared.bo package
-
getShipClassManager
public abstract ShipClassManager getShipClassManager()
The ship class manager
-
getWorldManager
public abstract WorldManager getWorldManager()
The world manager
-
getTilesetManager
public abstract TilesetManager<?> getTilesetManager()
The tilesets manager
-
getActionsDefManager
public abstract ActionsDefManager getActionsDefManager()
The actions definitions manager
-
getVersionManager
public abstract VersionManager getVersionManager()
The version manager
-
getEntityDefManager
public abstract EntityDefManager getEntityDefManager()
The entity definitions manager
-
getAchievementsManager
public abstract AchievementsManager getAchievementsManager()
The achievements manager
-
getMetaserverClient
public abstract MetaserverClient getMetaserverClient()
Api client for the metaserver
-
getAudioControl
public abstract AudioControl getAudioControl()
The audio controller
-
getModManager
public abstract ModManager getModManager()
The mod manager
-
getSecurityFacade
public abstract SecurityFacade getSecurityFacade()
The security facade
-
getObjectSerialization
public abstract ObjectSerialization getObjectSerialization()
The object de-/serializer
-
getScriptingManager
public abstract ScriptingManager getScriptingManager()
The scripting manager
-
getKeycodeRegistry
public abstract KeycodeRegistry getKeycodeRegistry()
The keycode registry
-
getEngineRng
public abstract Random getEngineRng()
A random number generator
-
createRandomGenerator
public abstract Random createRandomGenerator(long seed)
Creates a random number generator with a given seed
-
loadResource
public abstract InputStream loadResource(String resourceName)
Loads a file resource cumulative, this means from the last mod that provides it. This allows that mods can easily override resources like tilesets or audio files.- Parameters:
resourceName
- Relative path to resource from mod directory.- Returns:
- InputStream of file resource. Has to be closed by invoker.
-
loadResource
public abstract InputStream loadResource(String modName, String resourceName)
Loads a file resource from mod directory.- Parameters:
resourceName
- Relative path to resource from mod directory.- Returns:
- InputStream of file resource. Has to be closed by invoker.
-
loadDefaultModResource
public abstract InputStream loadDefaultModResource(String resourceName)
Loads a file resource from default mod directory.- Parameters:
resourceName
- Relative path to resource from default mod directory.- Returns:
- InputStream of file resource. Has to be closed by invoker.
-
storePersistentClientState
public abstract void storePersistentClientState()
Saves the persistent client state. Call this method after writing to the state.
-
dispatchMessage
public abstract void dispatchMessage(AbstractMessage message)
Sends a message. Depending on the message type it will be dispatched to the game server or stays in the client.
-
shutdown
public abstract void shutdown()
Shuts down the game client
-
stopEmbeddedServer
public abstract void stopEmbeddedServer()
Stops the embedded game server
-
relaunchEmbeddedServer
public abstract void relaunchEmbeddedServer()
Launches and connects to the embedded game server
-
isEmbeddedServerRunning
public abstract boolean isEmbeddedServerRunning()
Checks whether an embedded game server is running
-
takeScreenshot
public abstract void takeScreenshot()
Takes a screenshot. Screenshot will be delivered with TakeScreenshotEvent after the current frame has been rendered
-
connectToRemoteServer
public abstract void connectToRemoteServer(String destination)
Connects to a remote game server- Parameters:
destination
- IP, Hostname or FQDN
-
reconnectToRemoteServer
public abstract void reconnectToRemoteServer()
Tries to reconnect to the last remote server
-
closeNetworkClient
public abstract void closeNetworkClient(boolean block)
Disconnects from a remote server
-
isRemoteNetworkClientConnected
public abstract boolean isRemoteNetworkClientConnected()
Checks whether connected to a remote server
-
isRemoteNetworkClientAlive
public abstract boolean isRemoteNetworkClientAlive()
Checks whether the remote network client is alive. This checks the network client, not the connection. You may want to use isRemoteNetworkClientConnected() instead.
-
isLastConnectedNetworkRemote
public abstract boolean isLastConnectedNetworkRemote()
Checks whether the last connected server was a remote server or the embedded server
-
reportError
public abstract void reportError(String module, String message)
Reports an error to the error reporter
-
abortFrameExecution
public abstract void abortFrameExecution()
Aborts execution of the current frame. A EngineAbortFrameException will be thrown that will be understood by the engine busy loop. Don't catch this exception in your code. This functionality is useful for example after starting or stopping fundamental modules.
-
storeXml
@RestrictedMethod public abstract void storeXml(File file, Object obj)
-
loadXml
@RestrictedMethod public abstract <T> T loadXml(File file, Class<T> clazz)
-
externalLobbyInvite
@RestrictedMethod public abstract void externalLobbyInvite(String quickJoinCode)
-
externalLobbyInviteAvailable
@RestrictedMethod public abstract boolean externalLobbyInviteAvailable()
-
externalOverlayAvailable
@RestrictedMethod public abstract boolean externalOverlayAvailable()
-
-