Interface ExtensionContext


public interface ExtensionContext
What an extension may hook into. Each method says which thread its hook runs on. An exception thrown by a hook is printed once, naming the extension, and the hook is switched off; the game goes on.
  • Method Details

    • onStageCreated

      void onStageCreated(Consumer<Stage> hook)
      A stage was made (on the thread that made it, usually the game thread or main).
    • onStageDisposed

      void onStageDisposed(Consumer<Stage> hook)
      A stage stopped being shown. Game thread.
    • beforeTick

      void beforeTick(Consumer<Stage> hook)
      Every tick, after the tick's input and before timers and run(). Game thread.
    • onKey

      Every key press and release, before learner code sees it; observe only. Game thread.
    • onMouse

      Every mouse event, before learner code sees it; observe only. Game thread.
    • onExit

      void onExit(Runnable hook)
      At the end of the program, after whenExits(). Game thread.
    • onLearnerError

      void onLearnerError(Consumer<ExtensionContext.LearnerError> hook)
      A learner exception stopped the game. Game thread.
    • addLayerDrawer

      void addLayerDrawer(Layer layer, ExtensionContext.LayerDrawer drawer)
      Draws into a layer every frame, after the layer's canvas and before its sprites: map tiles, drawings. Game thread, when the draw list is made.
    • addOverlayDrawer

      void addOverlayDrawer(ExtensionContext.LayerDrawer drawer)
      Draws above everything (UI, texts and monitors included) in stage coordinates; captures leave it out (Studio's watch pins). Game thread.
    • dispatch

      <T> void dispatch(Stage stage, Class<T> listener, Consumer<? super T> call)
      Calls a listener interface on the stage and every sprite of it that implements it, at the point of the tick where key events arrive. Learner exceptions thrown there stop the game like any learner exception. Game thread.
      Type Parameters:
      T - the listener interface
    • input

      <T> T input(ExtensionContext.InputKey<T> key)
      This batch's copy of a slot of the input snapshot. Game thread.
    • getTickCount

      long getTickCount()
      Returns:
      ticks run so far
    • isLoading

      boolean isLoading()
      Returns:
      whether the loading screen is up
    • onInputPoll

      void onInputPoll(Consumer<ExtensionContext.InputSnapshot> hook)
      Once per batch of ticks, on the window thread (the one that started GLFW): poll devices into the snapshot. GLFW polling functions only; setting GLFW callbacks is not allowed.
    • afterFrame

      void afterFrame(BiConsumer<Stage, ExtensionContext.Frame> hook)
      After a frame was drawn, on the window thread.
    • runOnGameThread

      void runOnGameThread(Runnable task)
      Runs a task at the start of the next tick, before input.
    • registerImageFormat

      void registerImageFormat(String suffix, ExtensionContext.ImageDecoder decoder)
      Images whose name ends in suffix (e.g. ".ase") are decoded by decoder.