summaryrefslogtreecommitdiff
path: root/src/engine/components/LambdaSpawn.ts
blob: c45092a6b3b3c1ce268bfdb2d2d0791e25b866f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
  }
}