blob: 5b4168288ecde75b1ecb8209d9254abccc23c044 (
plain) (
blame)
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 { ComponentType, TrailingPositionComponent } from "./component";
import { Game } from "./game";
import { System, SystemType } from "./system";
interface Point {
x: number;
y: number;
time: number;
}
export class TrailingPositionSystem extends System {
constructor(
private readonly point_filter: (trail_point: Array<Point>) => Array<Point>
) {
super(SystemType.TRAILING_POSITION);
}
public update(_dt: number, game: Game) {
game.for_each_entity_with_component(
ComponentType.TRAILING_POSITION,
(entity) => {
const trailing_position = entity.components[
ComponentType.TRAILING_POSITION
] as TrailingPositionComponent;
trailing_position.trails = this.point_filter(trailing_position.trails);
}
);
}
}
|