1 | import { Plugins } from "../Utils";
|
2 | import { InteractorType } from "../Enums";
|
3 |
|
4 |
|
5 |
|
6 | export class InteractionManager {
|
7 | constructor(container) {
|
8 | this.container = container;
|
9 | const interactors = Plugins.getInteractors(container);
|
10 | this.externalInteractors = [];
|
11 | this.particleInteractors = [];
|
12 | for (const interactor of interactors) {
|
13 | switch (interactor.type) {
|
14 | case InteractorType.External:
|
15 | this.externalInteractors.push(interactor);
|
16 | break;
|
17 | case InteractorType.Particles:
|
18 | this.particleInteractors.push(interactor);
|
19 | break;
|
20 | }
|
21 | }
|
22 | }
|
23 | externalInteract(delta) {
|
24 | for (const interactor of this.externalInteractors) {
|
25 | if (interactor.isEnabled()) {
|
26 | interactor.interact(delta);
|
27 | }
|
28 | }
|
29 | }
|
30 | particlesInteract(particle, delta) {
|
31 | for (const interactor of this.externalInteractors) {
|
32 | interactor.reset(particle);
|
33 | }
|
34 |
|
35 | for (const interactor of this.particleInteractors) {
|
36 | if (interactor.isEnabled(particle)) {
|
37 | interactor.interact(particle, delta);
|
38 | }
|
39 | }
|
40 | }
|
41 | }
|