48 lines
1.0 KiB
Markdown
Raw Normal View History

*[JavaECS](../../README.md) / [docs](../overview.md) / system*
2021-06-03 13:25:17 +12:00
# System
2021-06-03 13:25:17 +12:00
### Contents
[About](#About)
[Implementation](#Implementation)
[Examples](#Examples)
2021-06-03 13:25:17 +12:00
## About
The system runs operations that must be performed on its assoiciated components.
Typically, this is expected to be run every frame, though this is not a strict requirement.
Examples of the `system` include the `health_system`; which reads the value of the entitie's `health` component and ensures h > 0.
``` java
void health_system(){
for (i = 0; i < registeredComponents.size(); i++){
if (registeredComponents[i].health <= 0){
registeredComponents[i].dead = true;
if (registeredComponents[i].isPlayer){
GameOver();
}
}
}
}
```
## Implementation
The systems are managed by the following code:
``` java
class SystemManager{
ECS baseECS;
int systemIndex;
public SystemManager(ECS baseECS){
this.baseECS = baseECS;
systemIndex = 0;
}
}
```
## Examples
2021-06-03 13:25:17 +12:00