From 823620b2a6ebb7ece619991e47a37ad46542b69f Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Wed, 6 Mar 2024 14:35:04 -0700 Subject: add particles --- src/engine/systems/Life.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/engine/systems/Life.ts (limited to 'src/engine/systems/Life.ts') 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(ComponentNames.Life); + if (!life.alive) { + game.removeEntity(entity.id); + } + }); + } +} -- cgit v1.2.3-70-g09d2