blob: d2ec898a01046bc0575477cc82ab55ddca35ba86 (
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
30
|
import { Component, ComponentNames } from ".";
import { Entity } from "../entities";
import { Direction } from "../interfaces";
export class GridSpawn extends Component {
public direction: Direction;
public spawnsLeft: number;
public spawner: () => Entity;
constructor(
spawnsLeft: number,
spawner: () => Entity,
direction = Direction.NONE,
) {
super(ComponentNames.GridSpawn);
this.spawnsLeft = spawnsLeft;
this.direction = direction;
this.spawner = spawner;
}
public spawnEntity(direction: Direction): Entity | undefined {
if (this.spawnsLeft === 0) {
return;
}
this.direction = direction;
this.spawnsLeft -= 1;
}
}
|