Package org.ngengine.components.jme3
Class ComponentManagerAppState
java.lang.Object
com.jme3.app.state.BaseAppState
org.ngengine.components.jme3.ComponentManagerAppState
- All Implemented Interfaces:
AppState
,ComponentManager
A component manager that manages components in a JME3 application.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addComponent
(Component component, Object... deps) Adds a component to the manager with optional dependencies.void
addInitializer
(ComponentInitializer initializer) void
addLoader
(ComponentLoader loader) void
addUpdater
(ComponentUpdater updater) protected void
cleanup
(Application app) Called after the app state is detached or during application shutdown if the state is still attached.void
disableComponent
(Component component) Disables a component.<T> void
enableComponent
(Component component, T arg) Enables a component with the specified argument.Gets all registered components.<T extends Component>
TgetComponent
(Class<T> type) Retrieves a component by its type.Retrieves a component by its ID.getComponentBySlot
(Object slot) Retrieves all components assigned to a specific slot.protected void
initialize
(Application app) Called during initialization once the app state is attached and before onEnable() is called.boolean
isComponentEnabled
(Component fragment) Checks if a component is currently enabled.protected void
Called when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.protected void
onEnable()
Called when the state is fully enabled, ie: is attached and isEnabled() is true or when the setEnabled() status changes after the state is attached.void
removeComponent
(Component component) Removes a component from the manager.void
removeInitializer
(ComponentInitializer initializer) void
removeLoader
(ComponentLoader loader) void
removeUpdater
(ComponentUpdater updater) void
render
(RenderManager rm) Render the state.void
update
(float tpf) Called to update theAppState
.void
updateComponentDependencies
(Component fragment, Object... deps) Updates the dependencies of a component.Methods inherited from class com.jme3.app.state.BaseAppState
cleanup, getApplication, getId, getState, getState, getState, getState, getStateManager, initialize, isEnabled, isInitialized, postRender, setEnabled, setId, stateAttached, stateDetached
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ngengine.components.ComponentManager
addAndEnableComponent, addAndEnableComponent, disableComponent, disableComponent, enableComponent, enableComponent, enableComponent, enableComponent, enableComponent, getCurrentComponentInSlot, resolveDependency
-
Constructor Details
-
ComponentManagerAppState
-
-
Method Details
-
addInitializer
-
removeInitializer
-
addUpdater
-
addLoader
-
removeLoader
-
removeUpdater
-
getComponent
Description copied from interface:ComponentManager
Retrieves a component by its type.- Specified by:
getComponent
in interfaceComponentManager
- Type Parameters:
T
- The component type- Parameters:
type
- The class of the component to retrieve- Returns:
- The component of the specified type, or null if not found
-
getComponentById
Description copied from interface:ComponentManager
Retrieves a component by its ID.- Specified by:
getComponentById
in interfaceComponentManager
- Parameters:
id
- The ID of the component to retrieve- Returns:
- The component with the specified ID, or null if not found
-
getComponentBySlot
Description copied from interface:ComponentManager
Retrieves all components assigned to a specific slot.- Specified by:
getComponentBySlot
in interfaceComponentManager
- Parameters:
slot
- The slot to get components from- Returns:
- A list of components in the specified slot
-
getComponent
Description copied from interface:ComponentManager
Gets all registered components.- Specified by:
getComponent
in interfaceComponentManager
- Returns:
- A list of all components managed by this ComponentManager
-
addComponent
Description copied from interface:ComponentManager
Adds a component to the manager with optional dependencies.The component will be initialized but not enabled. Call
ComponentManager.enableComponent(Component)
to enable it after adding.- Specified by:
addComponent
in interfaceComponentManager
- Parameters:
component
- The component to adddeps
- Zero or more dependencies for the component
-
removeComponent
Description copied from interface:ComponentManager
Removes a component from the manager.If the component is enabled, it will be disabled before removal.
- Specified by:
removeComponent
in interfaceComponentManager
- Parameters:
component
- The component to remove
-
enableComponent
Description copied from interface:ComponentManager
Enables a component with the specified argument.The component will only be enabled if all its dependencies are already enabled.
- Specified by:
enableComponent
in interfaceComponentManager
- Type Parameters:
T
- The type of argument to pass to the component- Parameters:
component
- The component to enablearg
- The argument to pass to the component's onEnable method
-
disableComponent
Description copied from interface:ComponentManager
Disables a component.This will also disable any components that depend on this component.
- Specified by:
disableComponent
in interfaceComponentManager
- Parameters:
component
- The component to disable
-
isComponentEnabled
Description copied from interface:ComponentManager
Checks if a component is currently enabled.- Specified by:
isComponentEnabled
in interfaceComponentManager
- Parameters:
fragment
- The component to check- Returns:
- true if the component is enabled, false otherwise
-
initialize
Description copied from class:BaseAppState
Called during initialization once the app state is attached and before onEnable() is called.- Specified by:
initialize
in classBaseAppState
- Parameters:
app
- the application
-
cleanup
Description copied from class:BaseAppState
Called after the app state is detached or during application shutdown if the state is still attached. onDisable() is called before this cleanup() method if the state is enabled at the time of cleanup.- Specified by:
cleanup
in classBaseAppState
- Parameters:
app
- the application
-
onEnable
protected void onEnable()Description copied from class:BaseAppState
Called when the state is fully enabled, ie: is attached and isEnabled() is true or when the setEnabled() status changes after the state is attached.- Specified by:
onEnable
in classBaseAppState
-
onDisable
protected void onDisable()Description copied from class:BaseAppState
Called when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.- Specified by:
onDisable
in classBaseAppState
-
update
public void update(float tpf) Description copied from interface:AppState
Called to update theAppState
. This method will be called every render pass if theAppState
is both attached and enabled.- Specified by:
update
in interfaceAppState
- Overrides:
update
in classBaseAppState
- Parameters:
tpf
- Time since the last call to update(), in seconds.
-
render
Description copied from interface:AppState
Render the state. This method will be called every render pass if theAppState
is both attached and enabled.- Specified by:
render
in interfaceAppState
- Overrides:
render
in classBaseAppState
- Parameters:
rm
- RenderManager
-
updateComponentDependencies
Description copied from interface:ComponentManager
Updates the dependencies of a component.This allows changing what components a particular component depends on at runtime.
- Specified by:
updateComponentDependencies
in interfaceComponentManager
- Parameters:
fragment
- The component to update dependencies fordeps
- The new dependencies for the component
-