@tsparticles/plugin-infection 3.0.0-alpha.1 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  # tsParticles Infection Plugin
4
4
 
5
- [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-plugin-infection/badge)](https://www.jsdelivr.com/package/npm/tsparticles-plugin-infection)
6
- [![npmjs](https://badge.fury.io/js/tsparticles-plugin-infection.svg)](https://www.npmjs.com/package/tsparticles-plugin-infection)
7
- [![npmjs](https://img.shields.io/npm/dt/tsparticles-plugin-infection)](https://www.npmjs.com/package/tsparticles-plugin-infection) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/plugin-infection/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-infection)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/plugin-infection.svg)](https://www.npmjs.com/package/@tsparticles/plugin-infection)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/plugin-infection)](https://www.npmjs.com/package/@tsparticles/plugin-infection) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
8
 
9
9
  [tsParticles](https://github.com/matteobruni/tsparticles) plugin for particles infection simulation effect.
10
10
 
@@ -26,7 +26,7 @@ Once the scripts are loaded you can set up `tsParticles` and the plugin like thi
26
26
 
27
27
  ```javascript
28
28
  (async () => {
29
- await loadInfectionPlugin();
29
+ await loadInfectionPlugin(tsParticles);
30
30
 
31
31
  await tsParticles.load({
32
32
  id: "tsparticles",
@@ -42,29 +42,33 @@ Once the scripts are loaded you can set up `tsParticles` and the plugin like thi
42
42
  This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
43
 
44
44
  ```shell
45
- $ npm install tsparticles-plugin-infection
45
+ $ npm install @tsparticles/plugin-infection
46
46
  ```
47
47
 
48
48
  or
49
49
 
50
50
  ```shell
51
- $ yarn add tsparticles-plugin-infection
51
+ $ yarn add @tsparticles/plugin-infection
52
52
  ```
53
53
 
54
54
  Then you need to import it in the app, like this:
55
55
 
56
56
  ```javascript
57
- const { tsParticles } = require("tsparticles-engine");
58
- const { loadInfectionPlugin } = require("tsparticles-plugin-infection");
57
+ const { tsParticles } = require("@tsparticles/engine");
58
+ const { loadInfectionPlugin } = require("@tsparticles/plugin-infection");
59
59
 
60
- loadInfectionPlugin(tsParticles);
60
+ (async () => {
61
+ await loadInfectionPlugin(tsParticles);
62
+ })();
61
63
  ```
62
64
 
63
65
  or
64
66
 
65
67
  ```javascript
66
- import { tsParticles } from "tsparticles-engine";
67
- import { loadInfectionPlugin } from "tsparticles-plugin-infection";
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadInfectionPlugin } from "@tsparticles/plugin-infection";
68
70
 
69
- loadInfectionPlugin(tsParticles);
71
+ (async () => {
72
+ await loadInfectionPlugin(tsParticles);
73
+ })();
70
74
  ```
@@ -1,97 +1,95 @@
1
1
  export class Infecter {
2
2
  constructor(container) {
3
- this.container = container;
3
+ this._nextInfectionStage = (particle) => {
4
+ const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
5
+ if (!infectionOptions || !infection) {
6
+ return;
7
+ }
8
+ const stagesCount = infectionOptions.stages.length;
9
+ if (stagesCount <= 0 || infection.stage === undefined) {
10
+ return;
11
+ }
12
+ infection.time = 0;
13
+ if (stagesCount <= ++infection.stage) {
14
+ if (infectionOptions.cure) {
15
+ delete infection.stage;
16
+ delete infection.time;
17
+ return;
18
+ }
19
+ else {
20
+ infection.stage = 0;
21
+ infection.time = 0;
22
+ }
23
+ }
24
+ };
25
+ this._container = container;
4
26
  }
5
27
  startInfection(particle, stage) {
6
- const options = this.container.actualOptions;
7
- if (!options.infection || !particle.infection) {
28
+ const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
29
+ if (!infectionOptions || !infection) {
8
30
  return;
9
31
  }
10
- const stages = options.infection.stages, stagesCount = stages.length;
32
+ const stages = infectionOptions.stages, stagesCount = stages.length;
11
33
  if (stage > stagesCount || stage < 0) {
12
34
  return;
13
35
  }
14
- particle.infection.delay = 0;
15
- particle.infection.delayStage = stage;
36
+ infection.delay = 0;
37
+ infection.delayStage = stage;
16
38
  }
17
39
  updateInfection(particle, delta) {
18
- const infection = this.container.actualOptions.infection;
19
- if (!infection || !particle.infection) {
40
+ const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
41
+ if (!infectionOptions || !infection) {
20
42
  return;
21
43
  }
22
- const stages = infection.stages, stagesCount = stages.length;
23
- if (particle.infection.delay !== undefined && particle.infection.delayStage !== undefined) {
24
- const stage = particle.infection.delayStage;
44
+ const stages = infectionOptions.stages, stagesCount = stages.length;
45
+ if (infection.delay !== undefined && infection.delayStage !== undefined) {
46
+ const stage = infection.delayStage;
25
47
  if (stage > stagesCount || stage < 0) {
26
48
  return;
27
49
  }
28
- if (particle.infection.delay >= infection.delay * 1000) {
29
- particle.infection.stage = stage;
30
- particle.infection.time = 0;
31
- delete particle.infection.delay;
32
- delete particle.infection.delayStage;
50
+ if (infection.delay >= infectionOptions.delay * 1000) {
51
+ infection.stage = stage;
52
+ infection.time = 0;
53
+ delete infection.delay;
54
+ delete infection.delayStage;
33
55
  }
34
56
  else {
35
- particle.infection.delay += delta;
57
+ infection.delay += delta;
36
58
  }
37
59
  }
38
60
  else {
39
- delete particle.infection.delay;
40
- delete particle.infection.delayStage;
61
+ delete infection.delay;
62
+ delete infection.delayStage;
41
63
  }
42
- if (particle.infection.stage !== undefined && particle.infection.time !== undefined) {
43
- const infectionStage = stages[particle.infection.stage];
64
+ if (infection.stage !== undefined && infection.time !== undefined) {
65
+ const infectionStage = stages[infection.stage];
44
66
  if (infectionStage.duration !== undefined && infectionStage.duration >= 0) {
45
- if (particle.infection.time > infectionStage.duration * 1000) {
46
- this.nextInfectionStage(particle);
67
+ if (infection.time > infectionStage.duration * 1000) {
68
+ this._nextInfectionStage(particle);
47
69
  }
48
70
  else {
49
- particle.infection.time += delta;
71
+ infection.time += delta;
50
72
  }
51
73
  }
52
74
  else {
53
- particle.infection.time += delta;
75
+ infection.time += delta;
54
76
  }
55
77
  }
56
78
  else {
57
- delete particle.infection.stage;
58
- delete particle.infection.time;
79
+ delete infection.stage;
80
+ delete infection.time;
59
81
  }
60
82
  }
61
83
  updateInfectionStage(particle, stage) {
62
- const options = this.container.actualOptions;
63
- if (!options.infection || !particle.infection) {
84
+ const options = this._container.actualOptions, { infection } = particle;
85
+ if (!options.infection || !infection) {
64
86
  return;
65
87
  }
66
88
  const stagesCount = options.infection.stages.length;
67
- if (stage > stagesCount ||
68
- stage < 0 ||
69
- (particle.infection.stage !== undefined && particle.infection.stage > stage)) {
89
+ if (stage > stagesCount || stage < 0 || (infection.stage !== undefined && infection.stage > stage)) {
70
90
  return;
71
91
  }
72
- particle.infection.stage = stage;
73
- particle.infection.time = 0;
74
- }
75
- nextInfectionStage(particle) {
76
- const options = this.container.actualOptions;
77
- if (!options.infection || !particle.infection) {
78
- return;
79
- }
80
- const stagesCount = options.infection.stages.length;
81
- if (stagesCount <= 0 || particle.infection.stage === undefined) {
82
- return;
83
- }
84
- particle.infection.time = 0;
85
- if (stagesCount <= ++particle.infection.stage) {
86
- if (options.infection.cure) {
87
- delete particle.infection.stage;
88
- delete particle.infection.time;
89
- return;
90
- }
91
- else {
92
- particle.infection.stage = 0;
93
- particle.infection.time = 0;
94
- }
95
- }
92
+ infection.stage = stage;
93
+ infection.time = 0;
96
94
  }
97
95
  }
@@ -1,12 +1,12 @@
1
- import { Infecter } from "./Infecter";
2
1
  import { itemFromArray } from "@tsparticles/engine";
2
+ import { Infecter } from "./Infecter.js";
3
3
  export class InfectionInstance {
4
4
  constructor(container) {
5
- this.container = container;
6
- this.container.infecter = new Infecter(this.container);
5
+ this._container = container;
6
+ this._container.infecter = new Infecter(this._container);
7
7
  }
8
8
  particleFillColor(particle) {
9
- const options = this.container.actualOptions;
9
+ const options = this._container.actualOptions;
10
10
  if (!particle.infection || !options.infection) {
11
11
  return;
12
12
  }
@@ -17,13 +17,12 @@ export class InfectionInstance {
17
17
  return this.particleFillColor(particle);
18
18
  }
19
19
  particlesSetup() {
20
- var _a;
21
- const options = this.container.actualOptions;
20
+ const options = this._container.actualOptions;
22
21
  if (!options.infection) {
23
22
  return;
24
23
  }
25
24
  for (let i = 0; i < options.infection.infections; i++) {
26
- const notInfected = this.container.particles.array.filter((p) => {
25
+ const notInfected = this._container.particles.filter((p) => {
27
26
  const infP = p;
28
27
  if (!infP.infection) {
29
28
  infP.infection = {};
@@ -31,7 +30,7 @@ export class InfectionInstance {
31
30
  return infP.infection.stage === undefined;
32
31
  });
33
32
  const infected = itemFromArray(notInfected);
34
- (_a = this.container.infecter) === null || _a === void 0 ? void 0 : _a.startInfection(infected, 0);
33
+ this._container.infecter?.startInfection(infected, 0);
35
34
  }
36
35
  }
37
36
  }
@@ -1,4 +1,4 @@
1
- import { InfectionStage } from "./InfectionStage";
1
+ import { InfectionStage } from "./InfectionStage.js";
2
2
  export class Infection {
3
3
  constructor() {
4
4
  this.cure = false;
@@ -8,46 +8,43 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
8
8
  init() {
9
9
  }
10
10
  async interact(p1, delta) {
11
- var _a, _b, _c, _d, _e;
12
11
  const infecter = this.container.infecter;
13
12
  if (!infecter) {
14
13
  return;
15
14
  }
16
15
  infecter.updateInfection(p1, delta.value);
17
- if (((_a = p1.infection) === null || _a === void 0 ? void 0 : _a.stage) === undefined) {
16
+ if (p1.infection?.stage === undefined) {
18
17
  return;
19
18
  }
20
19
  const container = this.container, options = container.actualOptions, infectionOptions = options.infection;
21
- if (!(infectionOptions === null || infectionOptions === void 0 ? void 0 : infectionOptions.enable) || infectionOptions.stages.length < 1) {
20
+ if (!infectionOptions?.enable || infectionOptions.stages.length < 1) {
22
21
  return;
23
22
  }
24
- const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * 2 + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = (_b = infectionStage1.infectedStage) !== null && _b !== void 0 ? _b : p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
23
+ const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * 2 + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
25
24
  for (const p2 of query) {
26
25
  const infP2 = p2;
27
26
  if (infP2 === p1 ||
28
27
  infP2.destroyed ||
29
28
  infP2.spawning ||
30
- !(((_c = infP2.infection) === null || _c === void 0 ? void 0 : _c.stage) === undefined || infP2.infection.stage !== p1.infection.stage)) {
29
+ !(infP2.infection?.stage === undefined || infP2.infection.stage !== p1.infection.stage) ||
30
+ getRandom() >= infections / neighbors) {
31
31
  continue;
32
32
  }
33
- if (getRandom() < infections / neighbors) {
34
- if (((_d = infP2.infection) === null || _d === void 0 ? void 0 : _d.stage) === undefined) {
35
- infecter.startInfection(infP2, infectedStage1);
36
- }
37
- else if (infP2.infection.stage < p1.infection.stage) {
38
- infecter.updateInfectionStage(infP2, infectedStage1);
39
- }
40
- else if (infP2.infection.stage > p1.infection.stage) {
41
- const infectionStage2 = infectionOptions.stages[infP2.infection.stage];
42
- const infectedStage2 = (_e = infectionStage2 === null || infectionStage2 === void 0 ? void 0 : infectionStage2.infectedStage) !== null && _e !== void 0 ? _e : infP2.infection.stage;
43
- infecter.updateInfectionStage(p1, infectedStage2);
44
- }
33
+ if (infP2.infection?.stage === undefined) {
34
+ infecter.startInfection(infP2, infectedStage1);
35
+ }
36
+ else if (infP2.infection.stage < p1.infection.stage) {
37
+ infecter.updateInfectionStage(infP2, infectedStage1);
38
+ }
39
+ else if (infP2.infection.stage > p1.infection.stage) {
40
+ const infectionStage2 = infectionOptions.stages[infP2.infection.stage];
41
+ const infectedStage2 = infectionStage2?.infectedStage ?? infP2.infection.stage;
42
+ infecter.updateInfectionStage(p1, infectedStage2);
45
43
  }
46
44
  }
47
45
  }
48
46
  isEnabled() {
49
- var _a, _b, _c;
50
- return (_c = (_b = (_a = this.container.actualOptions) === null || _a === void 0 ? void 0 : _a.infection) === null || _b === void 0 ? void 0 : _b.enable) !== null && _c !== void 0 ? _c : false;
47
+ return this.container.actualOptions?.infection?.enable ?? false;
51
48
  }
52
49
  reset() {
53
50
  }
package/browser/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { Infection } from "./Options/Classes/Infection";
2
- import { InfectionInstance } from "./InfectionInstance";
3
- import { ParticlesInfecter } from "./ParticlesInfecter";
1
+ import { Infection } from "./Options/Classes/Infection.js";
2
+ import { InfectionInstance } from "./InfectionInstance.js";
3
+ import { ParticlesInfecter } from "./ParticlesInfecter.js";
4
4
  class InfectionPlugin {
5
5
  constructor() {
6
6
  this.id = "infection";
@@ -9,24 +9,23 @@ class InfectionPlugin {
9
9
  return new InfectionInstance(container);
10
10
  }
11
11
  loadOptions(options, source) {
12
- if (!this.needsPlugin(source)) {
12
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
13
13
  return;
14
14
  }
15
15
  let infectionOptions = options.infection;
16
- if ((infectionOptions === null || infectionOptions === void 0 ? void 0 : infectionOptions.load) === undefined) {
16
+ if (infectionOptions?.load === undefined) {
17
17
  options.infection = infectionOptions = new Infection();
18
18
  }
19
- infectionOptions.load(source === null || source === void 0 ? void 0 : source.infection);
19
+ infectionOptions.load(source?.infection);
20
20
  }
21
21
  needsPlugin(options) {
22
- var _a, _b;
23
- return (_b = (_a = options === null || options === void 0 ? void 0 : options.infection) === null || _a === void 0 ? void 0 : _a.enable) !== null && _b !== void 0 ? _b : false;
22
+ return options?.infection?.enable ?? false;
24
23
  }
25
24
  }
26
- export async function loadInfectionPlugin(engine) {
25
+ export async function loadInfectionPlugin(engine, refresh = true) {
27
26
  const plugin = new InfectionPlugin();
28
- await engine.addPlugin(plugin);
29
- await engine.addInteractor("particlesInfection", (container) => new ParticlesInfecter(container));
27
+ await engine.addPlugin(plugin, refresh);
28
+ await engine.addInteractor("particlesInfection", (container) => new ParticlesInfecter(container), refresh);
30
29
  }
31
- export * from "./Options/Interfaces/IInfection";
32
- export * from "./Options/Interfaces/IInfectionStage";
30
+ export * from "./Options/Interfaces/IInfection.js";
31
+ export * from "./Options/Interfaces/IInfectionStage.js";
@@ -0,0 +1 @@
1
+ { "type": "module" }
package/cjs/Infecter.js CHANGED
@@ -3,99 +3,97 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Infecter = void 0;
4
4
  class Infecter {
5
5
  constructor(container) {
6
- this.container = container;
6
+ this._nextInfectionStage = (particle) => {
7
+ const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
8
+ if (!infectionOptions || !infection) {
9
+ return;
10
+ }
11
+ const stagesCount = infectionOptions.stages.length;
12
+ if (stagesCount <= 0 || infection.stage === undefined) {
13
+ return;
14
+ }
15
+ infection.time = 0;
16
+ if (stagesCount <= ++infection.stage) {
17
+ if (infectionOptions.cure) {
18
+ delete infection.stage;
19
+ delete infection.time;
20
+ return;
21
+ }
22
+ else {
23
+ infection.stage = 0;
24
+ infection.time = 0;
25
+ }
26
+ }
27
+ };
28
+ this._container = container;
7
29
  }
8
30
  startInfection(particle, stage) {
9
- const options = this.container.actualOptions;
10
- if (!options.infection || !particle.infection) {
31
+ const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
32
+ if (!infectionOptions || !infection) {
11
33
  return;
12
34
  }
13
- const stages = options.infection.stages, stagesCount = stages.length;
35
+ const stages = infectionOptions.stages, stagesCount = stages.length;
14
36
  if (stage > stagesCount || stage < 0) {
15
37
  return;
16
38
  }
17
- particle.infection.delay = 0;
18
- particle.infection.delayStage = stage;
39
+ infection.delay = 0;
40
+ infection.delayStage = stage;
19
41
  }
20
42
  updateInfection(particle, delta) {
21
- const infection = this.container.actualOptions.infection;
22
- if (!infection || !particle.infection) {
43
+ const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
44
+ if (!infectionOptions || !infection) {
23
45
  return;
24
46
  }
25
- const stages = infection.stages, stagesCount = stages.length;
26
- if (particle.infection.delay !== undefined && particle.infection.delayStage !== undefined) {
27
- const stage = particle.infection.delayStage;
47
+ const stages = infectionOptions.stages, stagesCount = stages.length;
48
+ if (infection.delay !== undefined && infection.delayStage !== undefined) {
49
+ const stage = infection.delayStage;
28
50
  if (stage > stagesCount || stage < 0) {
29
51
  return;
30
52
  }
31
- if (particle.infection.delay >= infection.delay * 1000) {
32
- particle.infection.stage = stage;
33
- particle.infection.time = 0;
34
- delete particle.infection.delay;
35
- delete particle.infection.delayStage;
53
+ if (infection.delay >= infectionOptions.delay * 1000) {
54
+ infection.stage = stage;
55
+ infection.time = 0;
56
+ delete infection.delay;
57
+ delete infection.delayStage;
36
58
  }
37
59
  else {
38
- particle.infection.delay += delta;
60
+ infection.delay += delta;
39
61
  }
40
62
  }
41
63
  else {
42
- delete particle.infection.delay;
43
- delete particle.infection.delayStage;
64
+ delete infection.delay;
65
+ delete infection.delayStage;
44
66
  }
45
- if (particle.infection.stage !== undefined && particle.infection.time !== undefined) {
46
- const infectionStage = stages[particle.infection.stage];
67
+ if (infection.stage !== undefined && infection.time !== undefined) {
68
+ const infectionStage = stages[infection.stage];
47
69
  if (infectionStage.duration !== undefined && infectionStage.duration >= 0) {
48
- if (particle.infection.time > infectionStage.duration * 1000) {
49
- this.nextInfectionStage(particle);
70
+ if (infection.time > infectionStage.duration * 1000) {
71
+ this._nextInfectionStage(particle);
50
72
  }
51
73
  else {
52
- particle.infection.time += delta;
74
+ infection.time += delta;
53
75
  }
54
76
  }
55
77
  else {
56
- particle.infection.time += delta;
78
+ infection.time += delta;
57
79
  }
58
80
  }
59
81
  else {
60
- delete particle.infection.stage;
61
- delete particle.infection.time;
82
+ delete infection.stage;
83
+ delete infection.time;
62
84
  }
63
85
  }
64
86
  updateInfectionStage(particle, stage) {
65
- const options = this.container.actualOptions;
66
- if (!options.infection || !particle.infection) {
87
+ const options = this._container.actualOptions, { infection } = particle;
88
+ if (!options.infection || !infection) {
67
89
  return;
68
90
  }
69
91
  const stagesCount = options.infection.stages.length;
70
- if (stage > stagesCount ||
71
- stage < 0 ||
72
- (particle.infection.stage !== undefined && particle.infection.stage > stage)) {
92
+ if (stage > stagesCount || stage < 0 || (infection.stage !== undefined && infection.stage > stage)) {
73
93
  return;
74
94
  }
75
- particle.infection.stage = stage;
76
- particle.infection.time = 0;
77
- }
78
- nextInfectionStage(particle) {
79
- const options = this.container.actualOptions;
80
- if (!options.infection || !particle.infection) {
81
- return;
82
- }
83
- const stagesCount = options.infection.stages.length;
84
- if (stagesCount <= 0 || particle.infection.stage === undefined) {
85
- return;
86
- }
87
- particle.infection.time = 0;
88
- if (stagesCount <= ++particle.infection.stage) {
89
- if (options.infection.cure) {
90
- delete particle.infection.stage;
91
- delete particle.infection.time;
92
- return;
93
- }
94
- else {
95
- particle.infection.stage = 0;
96
- particle.infection.time = 0;
97
- }
98
- }
95
+ infection.stage = stage;
96
+ infection.time = 0;
99
97
  }
100
98
  }
101
99
  exports.Infecter = Infecter;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InfectionInstance = void 0;
4
- const Infecter_1 = require("./Infecter");
5
4
  const engine_1 = require("@tsparticles/engine");
5
+ const Infecter_js_1 = require("./Infecter.js");
6
6
  class InfectionInstance {
7
7
  constructor(container) {
8
- this.container = container;
9
- this.container.infecter = new Infecter_1.Infecter(this.container);
8
+ this._container = container;
9
+ this._container.infecter = new Infecter_js_1.Infecter(this._container);
10
10
  }
11
11
  particleFillColor(particle) {
12
- const options = this.container.actualOptions;
12
+ const options = this._container.actualOptions;
13
13
  if (!particle.infection || !options.infection) {
14
14
  return;
15
15
  }
@@ -20,13 +20,12 @@ class InfectionInstance {
20
20
  return this.particleFillColor(particle);
21
21
  }
22
22
  particlesSetup() {
23
- var _a;
24
- const options = this.container.actualOptions;
23
+ const options = this._container.actualOptions;
25
24
  if (!options.infection) {
26
25
  return;
27
26
  }
28
27
  for (let i = 0; i < options.infection.infections; i++) {
29
- const notInfected = this.container.particles.array.filter((p) => {
28
+ const notInfected = this._container.particles.filter((p) => {
30
29
  const infP = p;
31
30
  if (!infP.infection) {
32
31
  infP.infection = {};
@@ -34,7 +33,7 @@ class InfectionInstance {
34
33
  return infP.infection.stage === undefined;
35
34
  });
36
35
  const infected = (0, engine_1.itemFromArray)(notInfected);
37
- (_a = this.container.infecter) === null || _a === void 0 ? void 0 : _a.startInfection(infected, 0);
36
+ this._container.infecter?.startInfection(infected, 0);
38
37
  }
39
38
  }
40
39
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Infection = void 0;
4
- const InfectionStage_1 = require("./InfectionStage");
4
+ const InfectionStage_js_1 = require("./InfectionStage.js");
5
5
  class Infection {
6
6
  constructor() {
7
7
  this.cure = false;
@@ -30,7 +30,7 @@ class Infection {
30
30
  return;
31
31
  }
32
32
  this.stages = data.stages.map((t) => {
33
- const s = new InfectionStage_1.InfectionStage();
33
+ const s = new InfectionStage_js_1.InfectionStage();
34
34
  s.load(t);
35
35
  return s;
36
36
  });