1.3 KiB
1.3 KiB
| JavaECS | docs | component | component.md
Component
Contents
About
Components are raw data that gets associated with an entity.
For an Object-Oriented language like Java, they are objects.
Each component is an array of objects, containing the data that should be associated with the entity.
E.g.: A position component is defined such as:
class position{
double x = 0.0;
double y = 0.0;
}
As the component is simply an object, the associated data can be anything, including scripts:
class script{
String statement = "";
Function<void> foo = () -> {
statement += "boo";
};
}
Two different usages of this data can then be applied:
- System-less data usage - which stores data but does not have a system that interacts with it every frame
and
- System-based interaction - which utilises the current data (of one or more components) to check if certain conditions have been met.
I.e.:
The position
component might not have a position_system
, but may be utilised by the collision_system
, which may use position.x
and position.y
to determine the location of the entity.
See System for more information.