From 4b9349b3f8bee21eb086cfd6e7668532a50e6048 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sat, 2 Mar 2024 04:02:20 -0700 Subject: add text on lambda factory --- src/engine/components/LambdaSpawn.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/engine/components/LambdaSpawn.ts (limited to 'src/engine/components/LambdaSpawn.ts') diff --git a/src/engine/components/LambdaSpawn.ts b/src/engine/components/LambdaSpawn.ts new file mode 100644 index 0000000..c45092a --- /dev/null +++ b/src/engine/components/LambdaSpawn.ts @@ -0,0 +1,29 @@ +import { Component, ComponentNames } from "."; +import { Direction } from "../interfaces"; + +export class LambdaSpawn extends Component { + public direction: Direction | null; + public spawnsLeft: number; + public code: string = ""; + + constructor( + spawnsLeft: number, + code: string, + direction: Direction | null = null, + ) { + super(ComponentNames.LambdaSpawn); + + this.spawnsLeft = spawnsLeft; + this.direction = direction; + this.code = code; + } + + public spawn(direction: Direction) { + if (this.spawnsLeft <= 0) { + return; + } + + this.direction = direction; + this.spawnsLeft -= 1; + } +} -- cgit v1.2.3-70-g09d2