react-simple-game-engine 0.0.44 → 0.0.47
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/lib/classes/entities/circle.entity.d.ts +1 -2
- package/lib/classes/entities/circle.entity.d.ts.map +1 -1
- package/lib/classes/entities/entity-sult.d.ts +13 -1
- package/lib/classes/entities/entity-sult.d.ts.map +1 -1
- package/lib/classes/entities/entity-sult.js +27 -0
- package/lib/classes/entities/entity.d.ts +8 -13
- package/lib/classes/entities/entity.d.ts.map +1 -1
- package/lib/classes/entities/entity.js +19 -8
- package/lib/classes/entities/rect.entity.d.ts +1 -2
- package/lib/classes/entities/rect.entity.d.ts.map +1 -1
- package/lib/classes/particle-system.d.ts +0 -3
- package/lib/classes/particle-system.d.ts.map +1 -1
- package/lib/classes/particle-system.js +0 -3
- package/lib/classes/scene.js +2 -2
- package/lib/classes/world-management.d.ts +7 -1
- package/lib/classes/world-management.d.ts.map +1 -1
- package/lib/classes/world-management.js +28 -4
- package/package.json +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Body } from "matter-js";
|
|
2
2
|
import { CreateBodyDefine, EntityInitial } from "../../export-types";
|
|
3
|
-
import { Sprite } from "../sprites/sprite";
|
|
4
3
|
import { Entity } from "./entity";
|
|
5
|
-
export declare class CircleEntity
|
|
4
|
+
export declare class CircleEntity extends Entity {
|
|
6
5
|
radius: number;
|
|
7
6
|
onSpriteWidthHeightBinding(): {
|
|
8
7
|
width: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circle.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/circle.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"circle.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/circle.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,YAAa,SAAQ,MAAM;IAC/B,MAAM,EAAG,MAAM,CAAC;IAEvB,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAO/D,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,YAAY,CAAC;IAQlD,SAAS,CAAC,YAAY,CACpB,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,EAC7D,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,IAAI;CAIR"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { Initialler } from "../../export-interfaces";
|
|
2
|
+
import { Camera } from "../camera";
|
|
3
|
+
import { Scene } from "../scene";
|
|
2
4
|
import { WorldManagement } from "../world-management";
|
|
3
5
|
export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
|
6
|
+
camera: Camera;
|
|
7
|
+
private readonly id;
|
|
8
|
+
readonly tag: string;
|
|
9
|
+
private _scene;
|
|
10
|
+
private _worldManagement;
|
|
11
|
+
constructor();
|
|
4
12
|
abstract update(): void;
|
|
5
13
|
abstract draw(): void;
|
|
6
|
-
|
|
14
|
+
get scene(): Scene<any>;
|
|
15
|
+
get worldManagement(): WorldManagement;
|
|
16
|
+
getProperty<T>(name: string): T;
|
|
17
|
+
active(worldManagement: WorldManagement): void;
|
|
18
|
+
onActive(): void;
|
|
7
19
|
initial(params: P): void;
|
|
8
20
|
}
|
|
9
21
|
//# sourceMappingURL=entity-sult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-sult.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity-sult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,8BAAsB,UAAU,CAAC,CAAC,GAAG,GAAG,CAAE,YAAW,UAAU,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"entity-sult.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity-sult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,8BAAsB,UAAU,CAAC,CAAC,GAAG,GAAG,CAAE,YAAW,UAAU,CAAC,CAAC,CAAC;IACzD,MAAM,EAAG,MAAM,CAAC;IACvB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAsD;IACzE,SAAgB,GAAG,EAAG,MAAM,CAAC;IAE7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;;IAM3C,QAAQ,CAAC,MAAM,IAAI,IAAI;IACvB,QAAQ,CAAC,IAAI,IAAI,IAAI;IAErB,IAAI,KAAK,eAER;IAED,IAAI,eAAe,oBAElB;IAED,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAI/B,MAAM,CAAC,eAAe,EAAE,eAAe;IAQvC,QAAQ;IACR,OAAO,CAAC,MAAM,EAAE,CAAC;CAClB"}
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
var EntitySult = /** @class */ (function () {
|
|
2
2
|
function EntitySult() {
|
|
3
|
+
this.id = "".concat(Math.random(), "-").concat(new Date().getTime());
|
|
4
|
+
this.tag = this.constructor.tag;
|
|
3
5
|
}
|
|
6
|
+
Object.defineProperty(EntitySult.prototype, "scene", {
|
|
7
|
+
get: function () {
|
|
8
|
+
return this._scene;
|
|
9
|
+
},
|
|
10
|
+
enumerable: false,
|
|
11
|
+
configurable: true
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(EntitySult.prototype, "worldManagement", {
|
|
14
|
+
get: function () {
|
|
15
|
+
return this._worldManagement;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
EntitySult.prototype.getProperty = function (name) {
|
|
21
|
+
return this[name];
|
|
22
|
+
};
|
|
23
|
+
EntitySult.prototype.active = function (worldManagement) {
|
|
24
|
+
console.log("Initted ".concat(this.tag, " entity (id : ").concat(this.id, ")"));
|
|
25
|
+
this._worldManagement = worldManagement;
|
|
26
|
+
this._scene = this.scene;
|
|
27
|
+
this.camera = worldManagement.camera;
|
|
28
|
+
this.onActive();
|
|
29
|
+
};
|
|
30
|
+
EntitySult.prototype.onActive = function () { };
|
|
4
31
|
EntitySult.prototype.initial = function (params) { };
|
|
5
32
|
return EntitySult;
|
|
6
33
|
}());
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import Matter from "matter-js";
|
|
2
|
-
import { Camera } from "../camera";
|
|
3
|
-
import { WorldManagement } from "../world-management";
|
|
4
2
|
import { Sprite } from "../sprites/sprite";
|
|
5
3
|
import { CreateBodyDefine, EntityInitial, EntityPrepare, MasterBody, Sound } from "../../export-types";
|
|
6
4
|
import { EntitySult } from "./entity-sult";
|
|
7
|
-
export declare abstract class Entity
|
|
5
|
+
export declare abstract class Entity extends EntitySult<EntityInitial<Entity>> {
|
|
8
6
|
private _body;
|
|
9
7
|
private _sprite;
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
protected sound?: Sound;
|
|
15
|
-
constructor();
|
|
16
|
-
set sprite(sprite: SpriteType);
|
|
17
|
-
get sprite(): SpriteType;
|
|
8
|
+
private _children;
|
|
9
|
+
sound?: Sound;
|
|
10
|
+
set sprite(sprite: Sprite<any>);
|
|
11
|
+
get sprite(): Sprite<any>;
|
|
18
12
|
get position(): Matter.Vector;
|
|
19
13
|
get body(): MasterBody;
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
get children(): EntitySult<any>[];
|
|
15
|
+
addChild(entity: EntitySult): void;
|
|
16
|
+
removeChild(entity: EntitySult): void;
|
|
22
17
|
createBody(transform: CreateBodyDefine["transform"], options?: CreateBodyDefine["bodyOptions"]): MasterBody;
|
|
23
18
|
protected abstract onCreateBody(transform: CreateBodyDefine["transform"] | undefined, options?: CreateBodyDefine["bodyOptions"]): Matter.Body;
|
|
24
19
|
initial({ sound, transform, sprite: spriteComponent, bodyOptions, }: EntityInitial<this>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACV,KAAK,EACN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,8BAAsB,MAAO,SAAQ,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACpE,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,SAAS,CAAoB;IAE9B,KAAK,CAAC,EAAE,KAAK,CAAC;IAErB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,EAG7B;IAED,IAAI,MAAM,IALS,MAAM,CAAC,GAAG,CAAC,CAO7B;IAED,IAAI,QAAQ,kBAEX;IAED,IAAI,IAAI,eAEP;IAED,IAAI,QAAQ,sBAEX;IAED,QAAQ,CAAC,MAAM,EAAE,UAAU;IAK3B,WAAW,CAAC,MAAM,EAAE,UAAU;IAQ9B,UAAU,CACR,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,EACxC,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAO3C,SAAS,CAAC,QAAQ,CAAC,YAAY,CAC7B,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,EACpD,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,MAAM,CAAC,IAAI;IAEd,OAAO,CAAC,EACN,KAAK,EACL,SAAc,EACd,MAAM,EAAE,eAAe,EACvB,WAAgB,GACjB,EAAE,aAAa,CAAC,IAAI,CAAC;IAgCtB,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IACnD,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAI1C,MAAM;IAGN,QAAQ;IAER,IAAI;IAIJ,QAAQ,CAAC,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAExE,WAAW,CAAC,MAAM,EAAE,MAAM;IAC1B,cAAc,CAAC,MAAM,EAAE,MAAM;IAC7B,iBAAiB,CAAC,MAAM,EAAE,MAAM;CACjC"}
|
|
@@ -40,9 +40,8 @@ import { EntitySult } from "./entity-sult";
|
|
|
40
40
|
var Entity = /** @class */ (function (_super) {
|
|
41
41
|
__extends(Entity, _super);
|
|
42
42
|
function Entity() {
|
|
43
|
-
var _this = _super.
|
|
44
|
-
_this.
|
|
45
|
-
_this.tag = _this.constructor.tag;
|
|
43
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
44
|
+
_this._children = [];
|
|
46
45
|
return _this;
|
|
47
46
|
}
|
|
48
47
|
Object.defineProperty(Entity.prototype, "sprite", {
|
|
@@ -70,12 +69,24 @@ var Entity = /** @class */ (function (_super) {
|
|
|
70
69
|
enumerable: false,
|
|
71
70
|
configurable: true
|
|
72
71
|
});
|
|
73
|
-
Entity.prototype
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
Object.defineProperty(Entity.prototype, "children", {
|
|
73
|
+
get: function () {
|
|
74
|
+
return this._children;
|
|
75
|
+
},
|
|
76
|
+
enumerable: false,
|
|
77
|
+
configurable: true
|
|
78
|
+
});
|
|
79
|
+
Entity.prototype.addChild = function (entity) {
|
|
80
|
+
this.children.push(entity);
|
|
81
|
+
this.worldManagement.addEntity(entity);
|
|
82
|
+
};
|
|
83
|
+
Entity.prototype.removeChild = function (entity) {
|
|
84
|
+
var delIndex = this.children.indexOf(entity);
|
|
85
|
+
if (delIndex > -1) {
|
|
86
|
+
this.children.splice(delIndex, 1);
|
|
87
|
+
this.worldManagement.removeEntity(entity);
|
|
88
|
+
}
|
|
77
89
|
};
|
|
78
|
-
Entity.prototype.onActive = function () { };
|
|
79
90
|
Entity.prototype.createBody = function (transform, options) {
|
|
80
91
|
this._body = this.onCreateBody(transform, options);
|
|
81
92
|
this._body.entity = this;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Body } from "matter-js";
|
|
2
2
|
import { CreateBodyDefine, EntityInitial } from "../../export-types";
|
|
3
|
-
import { Sprite } from "../sprites/sprite";
|
|
4
3
|
import { Entity } from "./entity";
|
|
5
|
-
export declare class RectEntity
|
|
4
|
+
export declare class RectEntity extends Entity {
|
|
6
5
|
width: number;
|
|
7
6
|
height: number;
|
|
8
7
|
onSpriteWidthHeightBinding(): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rect.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/rect.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"rect.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/rect.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,UAAW,SAAQ,MAAM;IAC7B,KAAK,EAAG,MAAM,CAAC;IACf,MAAM,EAAG,MAAM,CAAC;IAEvB,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAO/D,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,UAAU,CAAC;IAShD,SAAS,CAAC,YAAY,CACpB,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG;QACzC,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,EACD,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,IAAI;CAWR"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import p5 from "p5";
|
|
2
|
-
import { Camera } from "./camera";
|
|
3
2
|
import { EntitySult } from "./entities/entity-sult";
|
|
4
3
|
import { Particle, ParticleInitialParams } from "./particle";
|
|
5
4
|
declare type ParticleClass = {
|
|
@@ -23,8 +22,6 @@ export declare class ParticleSystem extends EntitySult<ParticleSystemInitialPara
|
|
|
23
22
|
private particleClass;
|
|
24
23
|
quantityPerFrame: number;
|
|
25
24
|
vecWeight: number;
|
|
26
|
-
camera: Camera;
|
|
27
|
-
active(): void;
|
|
28
25
|
initial({ forces, particleOptions, ...params }: ParticleSystemInitialParams): void;
|
|
29
26
|
update(): void;
|
|
30
27
|
draw(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle-system.d.ts","sourceRoot":"","sources":["../../src/classes/particle-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"particle-system.d.ts","sourceRoot":"","sources":["../../src/classes/particle-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE7D,aAAK,aAAa,GAAG;IACnB,KAAK,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,GAAG,QAAQ,CAAC;CACjE,CAAC;AAEF,aAAK,eAAe,GAAG,IAAI,CACzB,qBAAqB,EACrB,KAAK,GAAG,OAAO,GAAG,QAAQ,CAC3B,GAAG;IACF,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,aAAK,2BAA2B,GAAG;IACjC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,qBAAa,cAAe,SAAQ,UAAU,CAAC,2BAA2B,CAAC;IACzE,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,eAAe,CAGrB;IACF,OAAO,CAAC,aAAa,CAA2B;IAEzC,gBAAgB,EAAE,MAAM,CAAM;IAC9B,SAAS,EAAE,MAAM,CAAK;IAE7B,OAAO,CAAC,EACN,MAAM,EACN,eAAoB,EACpB,GAAG,MAAM,EACV,EAAE,2BAA2B;IAS9B,MAAM;IAyBN,IAAI;CAKL"}
|
|
@@ -54,9 +54,6 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
|
54
54
|
_this.vecWeight = 5;
|
|
55
55
|
return _this;
|
|
56
56
|
}
|
|
57
|
-
ParticleSystem.prototype.active = function () {
|
|
58
|
-
console.log("Initted particle system", this.particles.length);
|
|
59
|
-
};
|
|
60
57
|
ParticleSystem.prototype.initial = function (_a) {
|
|
61
58
|
var _b;
|
|
62
59
|
var forces = _a.forces, _c = _a.particleOptions, particleOptions = _c === void 0 ? {} : _c, params = __rest(_a, ["forces", "particleOptions"]);
|
package/lib/classes/scene.js
CHANGED
|
@@ -116,11 +116,11 @@ var Scene = /** @class */ (function () {
|
|
|
116
116
|
}); });
|
|
117
117
|
};
|
|
118
118
|
Scene.prototype.bootstrap = function (camera) {
|
|
119
|
-
this.worldManagement = new WorldManagement();
|
|
119
|
+
this.worldManagement = new WorldManagement(camera, this);
|
|
120
120
|
var components = this.getComponents(camera);
|
|
121
121
|
for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
|
|
122
122
|
var component = components_1[_i];
|
|
123
|
-
var entity = component.output(
|
|
123
|
+
var entity = component.output();
|
|
124
124
|
this.worldManagement.addEntity(entity);
|
|
125
125
|
}
|
|
126
126
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { Camera } from "./camera";
|
|
1
2
|
import { EntitySult } from "./entities/entity-sult";
|
|
3
|
+
import { Scene } from "./scene";
|
|
2
4
|
export declare class WorldManagement {
|
|
5
|
+
private _camera;
|
|
6
|
+
private _scene;
|
|
3
7
|
private entities;
|
|
4
8
|
private engine;
|
|
5
|
-
constructor();
|
|
9
|
+
constructor(_camera: Camera, _scene: Scene);
|
|
10
|
+
get camera(): Camera;
|
|
11
|
+
get scene(): Scene<any>;
|
|
6
12
|
destructor(): void;
|
|
7
13
|
addEntity(entity: EntitySult): void;
|
|
8
14
|
removeEntity(entity: EntitySult): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world-management.d.ts","sourceRoot":"","sources":["../../src/classes/world-management.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"world-management.d.ts","sourceRoot":"","sources":["../../src/classes/world-management.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,eAAe;IAId,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,MAAM;IAHnD,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,MAAM,CAAU;gBAEJ,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,KAAK;IAqC1D,IAAI,MAAM,WAET;IAED,IAAI,KAAK,eAER;IAED,UAAU;IAKV,SAAS,CAAC,MAAM,EAAE,UAAU;IAS5B,YAAY,CAAC,MAAM,EAAE,UAAU;IAa/B,MAAM;IAON,IAAI;CAKL"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Engine, World, Events } from "matter-js";
|
|
2
2
|
import { Entity } from "./entities/entity";
|
|
3
3
|
var WorldManagement = /** @class */ (function () {
|
|
4
|
-
function WorldManagement() {
|
|
4
|
+
function WorldManagement(_camera, _scene) {
|
|
5
|
+
this._camera = _camera;
|
|
6
|
+
this._scene = _scene;
|
|
5
7
|
this.entities = [];
|
|
6
8
|
this.engine = Engine.create();
|
|
7
9
|
Events.on(this.engine, "collisionStart", function (event) {
|
|
@@ -32,11 +34,26 @@ var WorldManagement = /** @class */ (function () {
|
|
|
32
34
|
}
|
|
33
35
|
});
|
|
34
36
|
}
|
|
37
|
+
Object.defineProperty(WorldManagement.prototype, "camera", {
|
|
38
|
+
get: function () {
|
|
39
|
+
return this._camera;
|
|
40
|
+
},
|
|
41
|
+
enumerable: false,
|
|
42
|
+
configurable: true
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(WorldManagement.prototype, "scene", {
|
|
45
|
+
get: function () {
|
|
46
|
+
return this._scene;
|
|
47
|
+
},
|
|
48
|
+
enumerable: false,
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
35
51
|
WorldManagement.prototype.destructor = function () {
|
|
36
52
|
World.clear(this.engine.world, false);
|
|
37
53
|
Engine.clear(this.engine);
|
|
38
54
|
};
|
|
39
55
|
WorldManagement.prototype.addEntity = function (entity) {
|
|
56
|
+
// temp pass modifier
|
|
40
57
|
this.entities.push(entity);
|
|
41
58
|
if (entity instanceof Entity) {
|
|
42
59
|
World.add(this.engine.world, entity.body);
|
|
@@ -44,10 +61,17 @@ var WorldManagement = /** @class */ (function () {
|
|
|
44
61
|
entity.active(this);
|
|
45
62
|
};
|
|
46
63
|
WorldManagement.prototype.removeEntity = function (entity) {
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
var delIndex = this.entities.indexOf(entity);
|
|
65
|
+
if (delIndex > -1) {
|
|
66
|
+
if (entity instanceof Entity) {
|
|
67
|
+
World.remove(this.engine.world, entity.body);
|
|
68
|
+
for (var _i = 0, _a = entity.children; _i < _a.length; _i++) {
|
|
69
|
+
var child = _a[_i];
|
|
70
|
+
this.removeEntity(child);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
this.entities.splice(this.entities.indexOf(entity), 1);
|
|
49
74
|
}
|
|
50
|
-
this.entities.splice(this.entities.indexOf(entity), 1);
|
|
51
75
|
};
|
|
52
76
|
WorldManagement.prototype.update = function () {
|
|
53
77
|
Engine.update(this.engine);
|