Package dev.prozilla.pine.core.scene
Class Scene
java.lang.Object
dev.prozilla.pine.core.scene.Scene
- All Implemented Interfaces:
Destructible,Initializable,InputHandler,Renderable,Updatable,Printable,ApplicationContext,ApplicationProvider,SceneContext
public class Scene
extends Object
implements Initializable, InputHandler, Updatable, Renderable, Destructible, Printable, SceneContext, ApplicationProvider
Responsible for loading objects into the world.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Applicationprotected CameraDataprotected PrefabPrefab that will be used during scene loading to create a camera entity.booleanbooleanprotected Loggerprotected World -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks whether the scene is ready.voiddestroy()Destroys this scene.booleanChecks if this scene is equal to another scene by comparing both ID's.static intGenerates a new unique scene ID.intgetId()getWorld()inthashCode()voidinit()Initializes the scene and its children.voidinput(float deltaTime) Handles input for the scene.booleanisActive()Checks whether this scene is the application's current scene.protected voidload()Loads this scene with the default camera prefab.protected voidFills this scene with a new world and camera.voidRenders the scene every frame.voidreset()Resets the state of this scene.voidsetApplication(Application application) toString()Returns a string representation of this object.voidupdate(float deltaTime) Updates the scene every frame.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.prozilla.pine.core.ApplicationProvider
getAudioDevice, getConfig, getInput, getLogger, getModManager, getRenderer, getTimer, getTracker, getWindow
-
Field Details
-
name
-
application
-
logger
-
world
-
cameraData
-
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 ofScene #followed by the scene ID. -
Scene
Creates a new scene with a given name.- Parameters:
name- Name of the scene
-
-
Method Details
-
setApplication
-
reset
public void reset()Resets the state of this scene. -
load
protected void load()Loads this scene with the default camera prefab. -
load
Fills this scene with a new world and camera.- Parameters:
cameraPrefab- Prefab for the camera entity.- Throws:
IllegalStateException
-
init
Initializes the scene and its children.- Specified by:
initin interfaceInitializable- Throws:
IllegalStateException
-
input
Handles input for the scene.- Specified by:
inputin interfaceInputHandler- Parameters:
deltaTime- Delta time in seconds- Throws:
IllegalStateException
-
update
Updates the scene every frame.- Specified by:
updatein interfaceUpdatable- Parameters:
deltaTime- Delta time in seconds- Throws:
IllegalStateException
-
render
Renders the scene every frame.- Specified by:
renderin interfaceRenderable- Throws:
IllegalStateException
-
destroy
Destroys this scene.- Specified by:
destroyin interfaceDestructible- Throws:
IllegalStateException
-
checkStatus
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() -
equals
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. -
getApplication
- Specified by:
getApplicationin interfaceApplicationProvider
-
getWorld
- Specified by:
getWorldin interfaceSceneContext
-
getCameraData
- Specified by:
getCameraDatain interfaceSceneContext
-
toString
Description copied from interface:PrintableReturns a string representation of this object.
-