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 TypeMethodDescriptionvoidaddComponent(Component component, Object... deps) Adds a component to the manager with optional dependencies.voidaddInitializer(ComponentInitializer initializer) voidaddLoader(ComponentLoader loader) voidaddUpdater(ComponentUpdater updater) protected voidcleanup(Application app) Called after the app state is detached or during application shutdown if the state is still attached.voiddisableComponent(Component component) Disables a component.<T> voidenableComponent(Component component, T arg) Enables a component with the specified argument.<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.Gets all registered components.<T> TgetGlobalInstance(Class<T> type) Retrieves a global object for the current application context.protected voidinitialize(Application app) Called during initialization once the app state is attached and before onEnable() is called.booleanisComponentEnabled(Component fragment) Checks if a component is currently enabled.protected voidCalled when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.protected voidonEnable()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.voidremoveComponent(Component component) Removes a component from the manager.voidremoveInitializer(ComponentInitializer initializer) voidremoveLoader(ComponentLoader loader) voidremoveUpdater(ComponentUpdater updater) voidrender(RenderManager rm) Render the state.voidupdate(float tpf) Called to update theAppState.voidupdateComponentDependencies(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, stateDetachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ngengine.components.ComponentManager
addAndEnableComponent, addAndEnableComponent, disableComponent, disableComponent, enableComponent, enableComponent, enableComponent, enableComponent, enableComponent, getCurrentComponentInSlot, resolveDependency
-
Constructor Details
-
ComponentManagerAppState
-
-
Method Details
-
getSettings
- Specified by:
getSettingsin interfaceComponentManager
-
addInitializer
-
removeInitializer
-
addUpdater
-
addLoader
-
removeLoader
-
removeUpdater
-
getDataStoreProvider
- Specified by:
getDataStoreProviderin interfaceComponentManager
-
getComponent
Description copied from interface:ComponentManagerRetrieves a component by its type.- Specified by:
getComponentin 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:ComponentManagerRetrieves a component by its ID.- Specified by:
getComponentByIdin 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:ComponentManagerRetrieves all components assigned to a specific slot.- Specified by:
getComponentBySlotin interfaceComponentManager- Parameters:
slot- The slot to get components from- Returns:
- A list of components in the specified slot
-
getComponents
Description copied from interface:ComponentManagerGets all registered components.- Specified by:
getComponentsin interfaceComponentManager- Returns:
- A list of all components managed by this ComponentManager
-
addComponent
Description copied from interface:ComponentManagerAdds 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:
addComponentin interfaceComponentManager- Parameters:
component- The component to adddeps- Zero or more dependencies for the component
-
removeComponent
Description copied from interface:ComponentManagerRemoves a component from the manager.If the component is enabled, it will be disabled before removal.
- Specified by:
removeComponentin interfaceComponentManager- Parameters:
component- The component to remove
-
enableComponent
Description copied from interface:ComponentManagerEnables a component with the specified argument.The component will only be enabled if all its dependencies are already enabled.
- Specified by:
enableComponentin 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:ComponentManagerDisables a component.This will also disable any components that depend on this component.
- Specified by:
disableComponentin interfaceComponentManager- Parameters:
component- The component to disable
-
isComponentEnabled
Description copied from interface:ComponentManagerChecks if a component is currently enabled.- Specified by:
isComponentEnabledin interfaceComponentManager- Parameters:
fragment- The component to check- Returns:
- true if the component is enabled, false otherwise
-
initialize
Description copied from class:BaseAppStateCalled during initialization once the app state is attached and before onEnable() is called.- Specified by:
initializein classBaseAppState- Parameters:
app- the application
-
cleanup
Description copied from class:BaseAppStateCalled 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:
cleanupin classBaseAppState- Parameters:
app- the application
-
onEnable
protected void onEnable()Description copied from class:BaseAppStateCalled 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:
onEnablein classBaseAppState
-
onDisable
protected void onDisable()Description copied from class:BaseAppStateCalled 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:
onDisablein classBaseAppState
-
update
public void update(float tpf) Description copied from interface:AppStateCalled to update theAppState. This method will be called every render pass if theAppStateis both attached and enabled.- Specified by:
updatein interfaceAppState- Overrides:
updatein classBaseAppState- Parameters:
tpf- Time since the last call to update(), in seconds.
-
render
Description copied from interface:AppStateRender the state. This method will be called every render pass if theAppStateis both attached and enabled.- Specified by:
renderin interfaceAppState- Overrides:
renderin classBaseAppState- Parameters:
rm- RenderManager
-
updateComponentDependencies
Description copied from interface:ComponentManagerUpdates the dependencies of a component.This allows changing what components a particular component depends on at runtime.
- Specified by:
updateComponentDependenciesin interfaceComponentManager- Parameters:
fragment- The component to update dependencies fordeps- The new dependencies for the component
-
getGlobalInstance
Description copied from interface:ComponentManagerRetrieves a global object for the current application context.- Specified by:
getGlobalInstancein interfaceComponentManager- Parameters:
type- The class of the global object to retrieve- Returns:
- The global object of the specified type, or null if not found
-