summaryrefslogtreecommitdiff
path: root/src/engine/systems/Life.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-06 14:35:04 -0700
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-06 14:35:04 -0700
commit823620b2a6ebb7ece619991e47a37ad46542b69f (patch)
tree82a1501c5f707a1bcbc6c28bd6d0f5731cc9f618 /src/engine/systems/Life.ts
parentce06fa7c29ba4e3d6137f7aa74fbfe45af0e8b73 (diff)
downloadthe-abstraction-engine-823620b2a6ebb7ece619991e47a37ad46542b69f.tar.gz
the-abstraction-engine-823620b2a6ebb7ece619991e47a37ad46542b69f.zip
add particles
Diffstat (limited to 'src/engine/systems/Life.ts')
-rw-r--r--src/engine/systems/Life.ts18
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);
+ }
+ });
+ }
+}