Class Scene

java.lang.Object
dev.prozilla.pine.core.Scene
All Implemented Interfaces:
Lifecycle, Printable

public class Scene extends Object implements Lifecycle, Printable
  • Field Details

    • name

      public String name
    • application

      protected Application application
    • logger

      protected Logger logger
    • world

      protected World world
    • cameraData

      protected CameraData cameraData
    • cameraPrefab

      protected Prefab cameraPrefab
      Prefab that will be used during scene loading to create a camera entity.
    • loaded

      public boolean loaded
    • initialized

      public boolean initialized
  • Constructor Details

    • Scene

      public Scene()
      Creates a new scene with a generated name. The name consists of Scene # followed by the scene ID.
    • Scene

      public Scene(String name)
      Creates a new scene with a given name.
      Parameters:
      name - Name of the scene
  • Method Details

    • setApplication

      public void setApplication(Application application)
    • reset

      public void reset()
      Resets the state of this scene.
    • load

      protected void load()
    • load

      protected void load(Prefab cameraPrefab) throws IllegalStateException
      Fills the scene with a new world and camera.
      Parameters:
      cameraPrefab - Prefab for the camera entity.
      Throws:
      IllegalStateException
    • init

      public void init(long window) throws IllegalStateException
      Initializes the scene and its children.
      Specified by:
      init in interface Lifecycle
      Parameters:
      window - Window
      Throws:
      IllegalStateException
    • input

      public void input(float deltaTime) throws IllegalStateException
      Handles input for the scene.
      Specified by:
      input in interface Lifecycle
      Parameters:
      deltaTime - Delta time in seconds
      Throws:
      IllegalStateException
    • update

      public void update(float deltaTime) throws IllegalStateException
      Updates the scene every frame.
      Specified by:
      update in interface Lifecycle
      Parameters:
      deltaTime - Delta time in seconds
      Throws:
      IllegalStateException
    • render

      public void render(Renderer renderer) throws IllegalStateException
      Renders the scene every frame.
      Specified by:
      render in interface Lifecycle
      Parameters:
      renderer - Reference to the renderer
      Throws:
      IllegalStateException
    • destroy

      public void destroy() throws IllegalStateException
      Destroys the scene.
      Specified by:
      destroy in interface Lifecycle
      Throws:
      IllegalStateException
    • checkStatus

      protected void checkStatus() throws IllegalStateException
      Checks whether the scene is ready.
      Throws:
      IllegalStateException
    • generateId

      public static int generateId()
      Generates a new unique scene ID.
      Returns:
      Scene ID
    • getId

      public int getId()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Scene scene)
      Checks if this scene is equal to another scene by comparing both ID's.
      Parameters:
      scene - Other scene
      Returns:
      True if both scenes have the same ID.
    • isActive

      public boolean isActive()
      Checks whether this scene is the application's current scene.
    • getWorld

      public World getWorld()
    • getCameraData

      public CameraData getCameraData()
    • toString

      public String toString()
      Description copied from interface: Printable
      Returns a string representation of this object.
      Specified by:
      toString in interface Printable
      Overrides:
      toString in class Object
      Returns:
      String representation of this object.