diff options
Diffstat (limited to 'src/engine/systems/Life.ts')
-rw-r--r-- | src/engine/systems/Life.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/engine/systems/Life.ts b/src/engine/systems/Life.ts new file mode 100644 index 0000000..f454437 --- /dev/null +++ b/src/engine/systems/Life.ts @@ -0,0 +1,18 @@ +import { System, SystemNames } from "."; +import { Game } from ".."; +import { Life as LifeComponent, ComponentNames } from "../components"; + +export class Life extends System { + constructor() { + super(SystemNames.Life); + } + + public update(_dt: number, game: Game) { + game.forEachEntityWithComponent(ComponentNames.Life, (entity) => { + const life = entity.getComponent<LifeComponent>(ComponentNames.Life); + if (!life.alive) { + game.removeEntity(entity.id); + } + }); + } +} |