Interface Fragment
- All Known Subinterfaces:
AppFragment
,AssetLoadingFragment
,AsyncAssetLoadingFragment
,GuiViewPortFragment
,InputHandlerFragment
,LogicFragment
,MainViewPortFragment
,RenderFragment
- All Known Implementing Classes:
NWindowManagerComponent
,PlayerManagerComponent
public interface Fragment
Fragments are interfaces that define specialized capabilities for components in the engine.
The fragment system provides a composition-based approach to building app components, allowing developers to opt-in to specific engine functionalities without complex inheritance hierarchies or linking code. Each fragment represents a specific capability or integration point with the engine.
Common fragment types include:
MainViewPortFragment
- For scene rendering and camera manipulationLogicFragment
- For game logicInputHandlerFragment
- For receiving and processing input eventsAsyncAssetLoadingFragment
- For loading assets in background threadsRenderFragment
- For low-level render operations
When a component implements a fragment interface, the ComponentManager automatically detects this capability and connects the component to the appropriate subsystem, eliminating the need for manual registration or boilerplate code.
Multiple fragments can be implemented by a single component, enabling a flexible mix of capabilities through interface composition rather than inheritance.Method Execution Order
Fragments follow a specific execution sequence:- Initialization Phase: All
receiveXXX
methods (likereceiveViewPort
,receiveInputManager
) are called when the component is first initialized. - Loading Phase: All
load
methods (likeloadAssetsAsync
) are called right before the component would be enabled. The component remains in pending state until all load methods complete. - Enable Phase: The
Component.onEnable(ComponentManager, Runner, DataStoreProvider, boolean, Object)
method is called when the component is enabled, after the initialization and loading phases are complete. - Update Phase: All update methods (like
updateViewPort
,update
) are called every frame for each enabled component. - Disable Phase: The
Component.onDisable(ComponentManager, Runner, DataStoreProvider)
method is called when the component is disabled, either explicitly, due to a dependency change or due it being detached.
- See Also: