-
Notifications
You must be signed in to change notification settings - Fork 112
Component Types
Jesse Wang edited this page Mar 29, 2016
·
8 revisions
The original component type.
- Easiest to work with
- The only component type which "safely" can be shared between multiple entity instances (such as marker-type components, that don't hold any actual data except for the type itself).
- Potentially more work for the garbage collector, consider the other types if the component is frequent and short-lived.
Pooled components are recycled once they're removed from an entity. Use in situations when components are re-created at frequent intervals.
- Zero-argument constructor
- Must use
Entity#edit#createComponent(Class<Component>)
orWorld#edit(int eid)
orComponentMapper<Component>#create(int eid)
- Must not employ
final
fields.
- Somewhat cumbersome to implement vs normal components.
-
@PooledWeaver
can however be used to automate the conversion.
-
Packed components only exist as a single instance per ComponentMapper
plus one held by the ComponentManager
. The template implementation uses a static primitive array to hold the data for all entities.
- Zero-argument constructor
- Calling the constructor must not reset the backing array, if any, else ComponentMappers will reset the component upon initialization.
- Must use
Entity#edit#createComponent(Class<Component>)
orWorld#edit(int eid)
orComponentMapper<Component>#create(int eid)
- No direct field access allowed.
- Better memory layout, potentially improving access times.
- Consumes less memory by reducing component instances.
- Cumbersome to implement (unless in situation where
@PackedWeaver
can be used).
- Overview
- Concepts
- Getting Started
- Using
- More guides
- Plugins
- Game Gallery
- Tools and Frameworks
- API reference