Class ComponentManagerAppState

java.lang.Object
com.jme3.app.state.BaseAppState
org.ngengine.components.jme3.ComponentManagerAppState
All Implemented Interfaces:
AppState, ComponentManager

public class ComponentManagerAppState extends BaseAppState implements ComponentManager
A component manager that manages components in a JME3 application.
  • Constructor Details

    • ComponentManagerAppState

      public ComponentManagerAppState(Application app)
  • Method Details

    • addInitializer

      public void addInitializer(ComponentInitializer initializer)
    • removeInitializer

      public void removeInitializer(ComponentInitializer initializer)
    • addUpdater

      public void addUpdater(ComponentUpdater updater)
    • addLoader

      public void addLoader(ComponentLoader loader)
    • removeLoader

      public void removeLoader(ComponentLoader loader)
    • removeUpdater

      public void removeUpdater(ComponentUpdater updater)
    • getComponent

      public <T extends Component> T getComponent(Class<T> type)
      Description copied from interface: ComponentManager
      Retrieves a component by its type.
      Specified by:
      getComponent in interface ComponentManager
      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

      public Component getComponentById(String id)
      Description copied from interface: ComponentManager
      Retrieves a component by its ID.
      Specified by:
      getComponentById in interface ComponentManager
      Parameters:
      id - The ID of the component to retrieve
      Returns:
      The component with the specified ID, or null if not found
    • getComponentBySlot

      public List<Component> getComponentBySlot(Object slot)
      Description copied from interface: ComponentManager
      Retrieves all components assigned to a specific slot.
      Specified by:
      getComponentBySlot in interface ComponentManager
      Parameters:
      slot - The slot to get components from
      Returns:
      A list of components in the specified slot
    • getComponent

      public List<Component> getComponent()
      Description copied from interface: ComponentManager
      Gets all registered components.
      Specified by:
      getComponent in interface ComponentManager
      Returns:
      A list of all components managed by this ComponentManager
    • addComponent

      public void addComponent(Component component, Object... deps)
      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 interface ComponentManager
      Parameters:
      component - The component to add
      deps - Zero or more dependencies for the component
    • removeComponent

      public void removeComponent(Component component)
      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 interface ComponentManager
      Parameters:
      component - The component to remove
    • enableComponent

      public <T> void enableComponent(Component component, T arg)
      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 interface ComponentManager
      Type Parameters:
      T - The type of argument to pass to the component
      Parameters:
      component - The component to enable
      arg - The argument to pass to the component's onEnable method
    • disableComponent

      public void disableComponent(Component component)
      Description copied from interface: ComponentManager
      Disables a component.

      This will also disable any components that depend on this component.

      Specified by:
      disableComponent in interface ComponentManager
      Parameters:
      component - The component to disable
    • isComponentEnabled

      public boolean isComponentEnabled(Component fragment)
      Description copied from interface: ComponentManager
      Checks if a component is currently enabled.
      Specified by:
      isComponentEnabled in interface ComponentManager
      Parameters:
      fragment - The component to check
      Returns:
      true if the component is enabled, false otherwise
    • initialize

      protected void initialize(Application app)
      Description copied from class: BaseAppState
      Called during initialization once the app state is attached and before onEnable() is called.
      Specified by:
      initialize in class BaseAppState
      Parameters:
      app - the application
    • cleanup

      protected void cleanup(Application app)
      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 class BaseAppState
      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 class BaseAppState
    • 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 class BaseAppState
    • update

      public void update(float tpf)
      Description copied from interface: AppState
      Called to update the AppState. This method will be called every render pass if the AppState is both attached and enabled.
      Specified by:
      update in interface AppState
      Overrides:
      update in class BaseAppState
      Parameters:
      tpf - Time since the last call to update(), in seconds.
    • render

      public void render(RenderManager rm)
      Description copied from interface: AppState
      Render the state. This method will be called every render pass if the AppState is both attached and enabled.
      Specified by:
      render in interface AppState
      Overrides:
      render in class BaseAppState
      Parameters:
      rm - RenderManager
    • updateComponentDependencies

      public void updateComponentDependencies(Component fragment, Object... deps)
      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 interface ComponentManager
      Parameters:
      fragment - The component to update dependencies for
      deps - The new dependencies for the component