Class 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 Detail

      • STARTED

        protected static volatile boolean STARTED
    • Constructor Detail

      • EngineFacade

        protected EngineFacade()
        EngineFacade is a singleton, use .instance()
    • 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
      • 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.
      • externalLobbyInviteAvailable

        @RestrictedMethod
        public abstract boolean externalLobbyInviteAvailable()
      • externalOverlayAvailable

        @RestrictedMethod
        public abstract boolean externalOverlayAvailable()