Interface ScriptInstance

All Known Implementing Classes:
AbstractScript, CreatureScript, EntityScript, EnvironmentScript, GameScript

public interface ScriptInstance

One configured runtime instance of a script.

Instances are created by a CompiledScript and owned by ScriptManager. Implementations should acquire host-specific resources in attach(ScriptContext) and release them in detach().

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    attach(ScriptContext<?> context)
    Attaches this instance to a host context.
    void
    Releases resources acquired by this attachment.
    default void
    Renders script-owned content.
    default void
    Processes one game-loop update.
  • Method Details

    • attach

      void attach(ScriptContext<?> context) throws Exception
      Attaches this instance to a host context.
      Parameters:
      context - The context for this attachment.
      Throws:
      Exception - if initialization fails.
    • update

      default void update() throws Exception
      Processes one game-loop update.
      Throws:
      Exception - if script execution fails.
    • render

      default void render(Graphics2D g) throws Exception
      Renders script-owned content.
      Parameters:
      g - The current graphics context.
      Throws:
      Exception - if script rendering fails.
    • detach

      void detach() throws Exception
      Releases resources acquired by this attachment.
      Throws:
      Exception - if cleanup fails.