react-simple-game-engine 0.2.135 → 0.3.0
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/animations/animator.d.ts +2 -2
- package/lib/classes/animations/animator.d.ts.map +1 -1
- package/lib/classes/entities/{entity-sult.d.ts → entity-suit.d.ts} +10 -8
- package/lib/classes/entities/entity-suit.d.ts.map +1 -0
- package/lib/classes/entities/{entity-sult.js → entity-suit.js} +27 -25
- package/lib/classes/entities/entity.d.ts +3 -3
- package/lib/classes/entities/entity.js +2 -2
- package/lib/classes/logic-component.d.ts +6 -6
- package/lib/classes/logic-component.d.ts.map +1 -1
- package/lib/classes/logic-component.js +8 -8
- package/lib/classes/p5.js +2 -2
- package/lib/classes/particle-system.d.ts +2 -2
- package/lib/classes/particle-system.js +2 -2
- package/lib/classes/particle.d.ts +2 -2
- package/lib/classes/particle.d.ts.map +1 -1
- package/lib/classes/prefab.d.ts +4 -4
- package/lib/classes/prefab.d.ts.map +1 -1
- package/lib/classes/prefab.js +2 -2
- package/lib/classes/scene.d.ts +7 -7
- package/lib/classes/scene.d.ts.map +1 -1
- package/lib/classes/scene.js +20 -20
- package/lib/classes/sound.js +1 -1
- package/lib/classes/sprites/avatar.sprite.d.ts +3 -3
- package/lib/classes/sprites/avatar.sprite.d.ts.map +1 -1
- package/lib/classes/sprites/sprite.d.ts.map +1 -1
- package/lib/classes/sprites/sprite.js +2 -1
- package/lib/classes/watcher.js +4 -4
- package/lib/classes/world-management.d.ts +7 -7
- package/lib/classes/world-management.d.ts.map +1 -1
- package/lib/classes/world-management.js +3 -3
- package/lib/decorators/sound-from.decor.d.ts +1 -1
- package/lib/decorators/sound-from.decor.d.ts.map +1 -1
- package/lib/decorators/sound-from.decor.js +5 -5
- package/lib/decorators/sprite-from.decor.d.ts +1 -1
- package/lib/decorators/sprite-from.decor.d.ts.map +1 -1
- package/lib/decorators/sprite-from.decor.js +5 -5
- package/lib/export-interfaces.d.ts +1 -1
- package/lib/export-interfaces.d.ts.map +1 -1
- package/lib/export-types.d.ts +6 -4
- package/lib/export-types.d.ts.map +1 -1
- package/lib/hooks/entity.d.ts +2 -2
- package/lib/hooks/watcher.js +4 -4
- package/lib/ui-components/control.js +2 -2
- package/lib/ui-components/float-container.js +2 -2
- package/lib/ui-components/game-bootstrap.js +4 -4
- package/lib/ui-components/logger.js +3 -3
- package/lib/ui-components/modal.js +3 -3
- package/lib/ui-components/scaler-container.js +2 -2
- package/lib/ui-components/scene-runner.js +4 -4
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +5 -5
- package/package.json +1 -1
- package/lib/classes/entities/entity-sult.d.ts.map +0 -1
@@ -1,11 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import { Initializer } from "../../export-interfaces";
|
2
2
|
import { Sprite } from "../sprites/sprite";
|
3
3
|
import { AnimationSprite } from "./animation";
|
4
4
|
declare type AnimatorInitialParams = {
|
5
5
|
activeKey: any;
|
6
6
|
states: Record<any, AnimationSprite>;
|
7
7
|
};
|
8
|
-
export declare class Animator implements
|
8
|
+
export declare class Animator implements Initializer<AnimatorInitialParams> {
|
9
9
|
private states;
|
10
10
|
private activeKey;
|
11
11
|
initial(params: AnimatorInitialParams): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"animator.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/animator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"animator.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/animator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,aAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;CACtC,CAAC;AAEF,qBAAa,QAAS,YAAW,WAAW,CAAC,qBAAqB,CAAC;IACjE,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,SAAS,CAAM;IAEvB,OAAO,CAAC,MAAM,EAAE,qBAAqB;IAIrC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;IAgB9B,IAAI;IAIJ,kBAAkB;IAIlB,IAAI,KAAK,CAAC,CAAC,EAAE,GAAG,EAEf;IAED,IAAI,KAAK,IAJI,GAAG,CAMf;CACF"}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import { Initializer } from "../../export-interfaces";
|
2
2
|
import { SimpleCamera } from "../simple-camera";
|
3
3
|
import { LogicComponent } from "../logic-component";
|
4
4
|
import { Scene } from "../scene";
|
5
5
|
import { WorldManagement } from "../world-management";
|
6
6
|
import { P5 } from "../p5";
|
7
|
-
export declare abstract class
|
7
|
+
export declare abstract class EntitySuit<P = any> implements Initializer<P> {
|
8
8
|
simpleCamera: SimpleCamera;
|
9
9
|
readonly id: string;
|
10
10
|
private _layerIndex;
|
@@ -15,22 +15,24 @@ export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
|
15
15
|
private _parent?;
|
16
16
|
private _renderer;
|
17
17
|
isVisible: boolean;
|
18
|
+
scaleX: number;
|
19
|
+
scaleY: number;
|
18
20
|
abstract update(): void;
|
19
21
|
abstract draw(): void;
|
20
22
|
get renderer(): P5;
|
21
23
|
set renderer(_renderer: P5);
|
22
|
-
get children():
|
24
|
+
get children(): EntitySuit<any>[];
|
23
25
|
get layerIndex(): number;
|
24
26
|
get name(): string;
|
25
27
|
set layerIndex(_layerIndex: number);
|
26
28
|
set name(_name: string);
|
27
|
-
get parent():
|
29
|
+
get parent(): EntitySuit<any>;
|
28
30
|
get scene(): Scene<any>;
|
29
31
|
set worldManagement(_worldManagement: WorldManagement);
|
30
32
|
get worldManagement(): WorldManagement;
|
31
|
-
addChild(target:
|
32
|
-
removeChild(entity:
|
33
|
-
unChild(entity:
|
33
|
+
addChild(target: EntitySuit | LogicComponent<EntitySuit>): void;
|
34
|
+
removeChild(entity: EntitySuit): void;
|
35
|
+
unChild(entity: EntitySuit): void;
|
34
36
|
getProperty<T>(name: string): T;
|
35
37
|
preInitial(worldManagement: WorldManagement): void;
|
36
38
|
active(_: WorldManagement): void;
|
@@ -62,4 +64,4 @@ export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
|
62
64
|
onBootstrapCompleted(): void;
|
63
65
|
initial(params: P): void;
|
64
66
|
}
|
65
|
-
//# sourceMappingURL=entity-
|
67
|
+
//# sourceMappingURL=entity-suit.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"entity-suit.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity-suit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3B,8BAAsB,UAAU,CAAC,CAAC,GAAG,GAAG,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IAC1D,YAAY,EAAE,YAAY,CAAC;IAClC,SAAgB,EAAE,EAAE,MAAM,CAAW;IAErC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,OAAO,CAAC,CAAa;IAC7B,OAAO,CAAC,SAAS,CAAK;IACf,SAAS,EAAE,OAAO,CAAQ;IAC1B,MAAM,EAAE,MAAM,CAAK;IACnB,MAAM,EAAE,MAAM,CAAK;IAE1B,QAAQ,CAAC,MAAM,IAAI,IAAI;IACvB,QAAQ,CAAC,IAAI,IAAI,IAAI;IAErB,IAAI,QAAQ,IAIY,EAAE,CAFzB;IAED,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,EAMzB;IAED,IAAI,QAAQ,sBAEX;IAED,IAAI,UAAU,IAQc,MAAM,CANjC;IAED,IAAI,IAAI,IAWQ,MAAM,CATrB;IAED,IAAI,UAAU,CAAC,WAAW,EAAE,MAAM,EAKjC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAUrB;IAED,IAAI,MAAM,oBAET;IAED,IAAI,KAAK,eAER;IAED,IAAI,eAAe,CAAC,gBAAgB,EAAE,eAAe,EAOpD;IAED,IAAI,eAAe,IATmB,eAAe,CAWpD;IAED,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC;IASxD,WAAW,CAAC,MAAM,EAAE,UAAU;IAK9B,OAAO,CAAC,MAAM,EAAE,UAAU;IAO1B,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAI/B,UAAU,CAAC,eAAe,EAAE,eAAe;IAO3C,MAAM,CAAC,CAAC,EAAE,eAAe;IAKzB,kBAAkB,CAAC,CAAC,EAAE,eAAe;IAIrC;;;OAGG;IACH,WAAW;IAEX;;;OAGG;IACH,cAAc;IAEd;;;OAGG;IACH,cAAc;IAEd;;;OAGG;IACH,QAAQ;IAER;;;OAGG;IACH,oBAAoB;IAEpB,OAAO,CAAC,MAAM,EAAE,CAAC;CAClB"}
|
@@ -1,13 +1,15 @@
|
|
1
1
|
import { genId } from "../../utils";
|
2
|
-
var
|
3
|
-
function
|
2
|
+
var EntitySuit = /** @class */ (function () {
|
3
|
+
function EntitySuit() {
|
4
4
|
this.id = genId();
|
5
5
|
this._layerIndex = 0;
|
6
6
|
this._name = this.id;
|
7
7
|
this._children = [];
|
8
8
|
this.isVisible = true;
|
9
|
+
this.scaleX = 1;
|
10
|
+
this.scaleY = 1;
|
9
11
|
}
|
10
|
-
Object.defineProperty(
|
12
|
+
Object.defineProperty(EntitySuit.prototype, "renderer", {
|
11
13
|
get: function () {
|
12
14
|
return this._renderer;
|
13
15
|
},
|
@@ -21,14 +23,14 @@ var EntitySult = /** @class */ (function () {
|
|
21
23
|
enumerable: false,
|
22
24
|
configurable: true
|
23
25
|
});
|
24
|
-
Object.defineProperty(
|
26
|
+
Object.defineProperty(EntitySuit.prototype, "children", {
|
25
27
|
get: function () {
|
26
28
|
return this._children;
|
27
29
|
},
|
28
30
|
enumerable: false,
|
29
31
|
configurable: true
|
30
32
|
});
|
31
|
-
Object.defineProperty(
|
33
|
+
Object.defineProperty(EntitySuit.prototype, "layerIndex", {
|
32
34
|
get: function () {
|
33
35
|
return this._layerIndex;
|
34
36
|
},
|
@@ -41,7 +43,7 @@ var EntitySult = /** @class */ (function () {
|
|
41
43
|
enumerable: false,
|
42
44
|
configurable: true
|
43
45
|
});
|
44
|
-
Object.defineProperty(
|
46
|
+
Object.defineProperty(EntitySuit.prototype, "name", {
|
45
47
|
get: function () {
|
46
48
|
return this._name;
|
47
49
|
},
|
@@ -61,21 +63,21 @@ var EntitySult = /** @class */ (function () {
|
|
61
63
|
enumerable: false,
|
62
64
|
configurable: true
|
63
65
|
});
|
64
|
-
Object.defineProperty(
|
66
|
+
Object.defineProperty(EntitySuit.prototype, "parent", {
|
65
67
|
get: function () {
|
66
68
|
return this._parent;
|
67
69
|
},
|
68
70
|
enumerable: false,
|
69
71
|
configurable: true
|
70
72
|
});
|
71
|
-
Object.defineProperty(
|
73
|
+
Object.defineProperty(EntitySuit.prototype, "scene", {
|
72
74
|
get: function () {
|
73
75
|
return this._scene;
|
74
76
|
},
|
75
77
|
enumerable: false,
|
76
78
|
configurable: true
|
77
79
|
});
|
78
|
-
Object.defineProperty(
|
80
|
+
Object.defineProperty(EntitySuit.prototype, "worldManagement", {
|
79
81
|
get: function () {
|
80
82
|
return this._worldManagement;
|
81
83
|
},
|
@@ -90,65 +92,65 @@ var EntitySult = /** @class */ (function () {
|
|
90
92
|
enumerable: false,
|
91
93
|
configurable: true
|
92
94
|
});
|
93
|
-
|
94
|
-
var entity = target instanceof
|
95
|
+
EntitySuit.prototype.addChild = function (target) {
|
96
|
+
var entity = target instanceof EntitySuit ? target : target.output();
|
95
97
|
entity._parent = this;
|
96
98
|
entity._layerIndex = this._layerIndex;
|
97
99
|
this.children.push(entity);
|
98
100
|
this.worldManagement.addEntity(entity);
|
99
101
|
};
|
100
|
-
|
102
|
+
EntitySuit.prototype.removeChild = function (entity) {
|
101
103
|
this.unChild(entity);
|
102
104
|
this.worldManagement.removeEntity(entity);
|
103
105
|
};
|
104
|
-
|
106
|
+
EntitySuit.prototype.unChild = function (entity) {
|
105
107
|
var delIndex = this.children.indexOf(entity);
|
106
108
|
if (delIndex > -1) {
|
107
109
|
this.children.splice(delIndex, 1);
|
108
110
|
}
|
109
111
|
};
|
110
|
-
|
112
|
+
EntitySuit.prototype.getProperty = function (name) {
|
111
113
|
return this[name];
|
112
114
|
};
|
113
|
-
|
115
|
+
EntitySuit.prototype.preInitial = function (worldManagement) {
|
114
116
|
this._worldManagement = worldManagement;
|
115
117
|
this._scene = worldManagement.scene;
|
116
118
|
this._renderer = worldManagement.scene.renderer;
|
117
119
|
this.simpleCamera = worldManagement.camera;
|
118
120
|
};
|
119
|
-
|
121
|
+
EntitySuit.prototype.active = function (_) {
|
120
122
|
// console.log(`Active entity (name : ${this._name})`);
|
121
123
|
this.onActive();
|
122
124
|
};
|
123
|
-
|
125
|
+
EntitySuit.prototype.bootstrapCompleted = function (_) {
|
124
126
|
this.onBootstrapCompleted();
|
125
127
|
};
|
126
128
|
/**
|
127
129
|
* invoke when mouse move on canvas
|
128
130
|
* @void
|
129
131
|
*/
|
130
|
-
|
132
|
+
EntitySuit.prototype.onMouseMove = function () { };
|
131
133
|
/**
|
132
134
|
* invoke when mouse pressed on canvas
|
133
135
|
* @void
|
134
136
|
*/
|
135
|
-
|
137
|
+
EntitySuit.prototype.onMousePressed = function () { };
|
136
138
|
/**
|
137
139
|
* invoke when mouse release from canvas
|
138
140
|
* @void
|
139
141
|
*/
|
140
|
-
|
142
|
+
EntitySuit.prototype.onMouseRelease = function () { };
|
141
143
|
/**
|
142
144
|
* invoke when entity is added into world
|
143
145
|
* @void
|
144
146
|
*/
|
145
|
-
|
147
|
+
EntitySuit.prototype.onActive = function () { };
|
146
148
|
/**
|
147
149
|
* invoke when scene bootstrap completed, if entity that added after scene completed like ex: prefab, bullet,... then this function will not invoke
|
148
150
|
* @void
|
149
151
|
*/
|
150
|
-
|
151
|
-
|
152
|
-
return
|
152
|
+
EntitySuit.prototype.onBootstrapCompleted = function () { };
|
153
|
+
EntitySuit.prototype.initial = function (params) { };
|
154
|
+
return EntitySuit;
|
153
155
|
}());
|
154
|
-
export {
|
156
|
+
export { EntitySuit };
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import Matter from "matter-js";
|
2
2
|
import { Sprite } from "../sprites/sprite";
|
3
3
|
import { Color, CreateBodyDefine, EntityInitial, EntityPrepare, MasterBody, Point } from "../../export-types";
|
4
|
-
import {
|
4
|
+
import { EntitySuit } from "./entity-suit";
|
5
5
|
import { LogicComponent } from "../logic-component";
|
6
6
|
import { Sound } from "../sound";
|
7
7
|
import { Sensor } from "../sensor";
|
8
8
|
declare type TimerJobListener = () => void;
|
9
9
|
declare type TerminateOptions = {
|
10
10
|
duration?: number;
|
11
|
-
effect:
|
11
|
+
effect: EntitySuit | LogicComponent<EntitySuit>;
|
12
12
|
};
|
13
13
|
declare type TimerOptions = {
|
14
14
|
defaultRun?: boolean;
|
@@ -30,7 +30,7 @@ declare type AddSensorParams = {
|
|
30
30
|
width?: never;
|
31
31
|
height?: never;
|
32
32
|
});
|
33
|
-
export declare abstract class Entity<P extends Record<string, any> = Record<string, any>> extends
|
33
|
+
export declare abstract class Entity<P extends Record<string, any> = Record<string, any>> extends EntitySuit<EntityInitial<Entity>> {
|
34
34
|
private _body;
|
35
35
|
private _sprite;
|
36
36
|
private _props;
|
@@ -37,7 +37,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
37
37
|
};
|
38
38
|
import { Bodies, Body } from "matter-js";
|
39
39
|
import { ColorSprite } from "../sprites/color.sprite";
|
40
|
-
import {
|
40
|
+
import { EntitySuit } from "./entity-suit";
|
41
41
|
import { copyProperties, genId } from "../../utils";
|
42
42
|
import { Sensor } from "../sensor";
|
43
43
|
var Entity = /** @class */ (function (_super) {
|
@@ -258,5 +258,5 @@ var Entity = /** @class */ (function (_super) {
|
|
258
258
|
Entity.prototype.onSensorCollisionEnd = function (sensor, target) { };
|
259
259
|
Entity.prototype.onSensorCollisionActive = function (sensor, target) { };
|
260
260
|
return Entity;
|
261
|
-
}(
|
261
|
+
}(EntitySuit));
|
262
262
|
export { Entity };
|
@@ -1,16 +1,16 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { Initializer } from "../export-interfaces";
|
2
|
+
import { Configurable, Configuration } from "../export-types";
|
3
3
|
import { WorldManagement } from "./world-management";
|
4
|
-
export declare class LogicComponent<C extends
|
5
|
-
private readonly
|
4
|
+
export declare class LogicComponent<C extends Initializer = Initializer> {
|
5
|
+
private readonly configurable;
|
6
6
|
private readonly _isPrefab?;
|
7
7
|
private _worldManagement;
|
8
8
|
layerIndex: number;
|
9
|
-
constructor(
|
9
|
+
constructor(configurable: Configurable<C>, _isPrefab?: boolean);
|
10
10
|
get isPrefab(): boolean;
|
11
11
|
set worldManagement(_worldManagement: WorldManagement);
|
12
12
|
output({ worldManagement, ...targetParams }?: {
|
13
13
|
worldManagement?: WorldManagement;
|
14
|
-
} &
|
14
|
+
} & Configuration<C>): C;
|
15
15
|
}
|
16
16
|
//# sourceMappingURL=logic-component.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logic-component.d.ts","sourceRoot":"","sources":["../../src/classes/logic-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"logic-component.d.ts","sourceRoot":"","sources":["../../src/classes/logic-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAI9D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,qBAAa,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAI3D,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAJ7B,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,UAAU,EAAE,MAAM,CAAK;gBAEJ,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,EAC7B,SAAS,CAAC,EAAE,OAAO;IAGtC,IAAI,QAAQ,YAEX;IAED,IAAI,eAAe,CAAC,gBAAgB,EAAE,eAAe,EAMpD;IAED,MAAM,CAAC,EACL,eAAe,EACf,GAAG,YAAY,EAChB,GAAE;QACD,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC,GAAG,aAAa,CAAC,CAAC,CAAM;CA6C1B"}
|
@@ -21,10 +21,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
21
21
|
return t;
|
22
22
|
};
|
23
23
|
import { Entity } from "./entities/entity";
|
24
|
-
import {
|
24
|
+
import { EntitySuit } from "./entities/entity-suit";
|
25
25
|
var LogicComponent = /** @class */ (function () {
|
26
|
-
function LogicComponent(
|
27
|
-
this.
|
26
|
+
function LogicComponent(configurable, _isPrefab) {
|
27
|
+
this.configurable = configurable;
|
28
28
|
this._isPrefab = _isPrefab;
|
29
29
|
this.layerIndex = 0;
|
30
30
|
}
|
@@ -50,15 +50,15 @@ var LogicComponent = /** @class */ (function () {
|
|
50
50
|
LogicComponent.prototype.output = function (_a) {
|
51
51
|
if (_a === void 0) { _a = {}; }
|
52
52
|
var worldManagement = _a.worldManagement, targetParams = __rest(_a, ["worldManagement"]);
|
53
|
-
var
|
54
|
-
var _b = Array.isArray(
|
55
|
-
?
|
56
|
-
: [
|
53
|
+
var configurable = this.configurable;
|
54
|
+
var _b = Array.isArray(configurable)
|
55
|
+
? configurable
|
56
|
+
: [configurable], Class = _b[0], _c = _b[1], params = _c === void 0 ? {} : _c;
|
57
57
|
var c = new Class();
|
58
58
|
if (worldManagement) {
|
59
59
|
this.worldManagement = worldManagement;
|
60
60
|
}
|
61
|
-
if (c instanceof
|
61
|
+
if (c instanceof EntitySuit) {
|
62
62
|
c["_layerIndex"] = this.layerIndex; // use _layerIndex to not trigger change index process at this step
|
63
63
|
c.preInitial(this._worldManagement);
|
64
64
|
}
|
package/lib/classes/p5.js
CHANGED
@@ -81,12 +81,12 @@ var P5 = /** @class */ (function (_super) {
|
|
81
81
|
return t + item[1];
|
82
82
|
}, 0);
|
83
83
|
if (totalPercentsOfRestItems > 1) {
|
84
|
-
var
|
84
|
+
var overMax = totalPercentsOfRestItems - 1;
|
85
85
|
var avg = 1 / restItems.length;
|
86
86
|
for (var _i = 0, restItems_1 = restItems; _i < restItems_1.length; _i++) {
|
87
87
|
var item = restItems_1[_i];
|
88
88
|
if (item[1] > avg) {
|
89
|
-
item[1] -=
|
89
|
+
item[1] -= overMax;
|
90
90
|
}
|
91
91
|
}
|
92
92
|
totalPercentsOfRestItems = 1;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import p5 from "p5";
|
2
2
|
import { Particle, ParticleInitialParams } from "./particle";
|
3
|
-
import {
|
3
|
+
import { EntitySuit } from "./entities/entity-suit";
|
4
4
|
declare type ParticleClass = {
|
5
5
|
new (...args: ConstructorParameters<typeof Particle>): Particle;
|
6
6
|
};
|
@@ -15,7 +15,7 @@ declare type ParticleSystemInitialParams = {
|
|
15
15
|
vecWeight?: number;
|
16
16
|
forces?: p5.Vector[];
|
17
17
|
};
|
18
|
-
export declare class ParticleSystem extends
|
18
|
+
export declare class ParticleSystem extends EntitySuit<ParticleSystemInitialParams> {
|
19
19
|
private particles;
|
20
20
|
private forces;
|
21
21
|
private particleOptions;
|
@@ -38,7 +38,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
38
38
|
import p5 from "p5";
|
39
39
|
import { copyProperties } from "../utils";
|
40
40
|
import { Particle } from "./particle";
|
41
|
-
import {
|
41
|
+
import { EntitySuit } from "./entities/entity-suit";
|
42
42
|
var ParticleSystem = /** @class */ (function (_super) {
|
43
43
|
__extends(ParticleSystem, _super);
|
44
44
|
function ParticleSystem() {
|
@@ -94,5 +94,5 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
94
94
|
}
|
95
95
|
};
|
96
96
|
return ParticleSystem;
|
97
|
-
}(
|
97
|
+
}(EntitySuit));
|
98
98
|
export { ParticleSystem };
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import p5 from "p5";
|
2
|
-
import {
|
2
|
+
import { Initializer } from "../export-interfaces";
|
3
3
|
import { Avatar, Color } from "../export-types";
|
4
4
|
import { SimpleCamera } from "./simple-camera";
|
5
5
|
export declare type ParticleInitialParams = {
|
@@ -12,7 +12,7 @@ export declare type ParticleInitialParams = {
|
|
12
12
|
simpleCamera: SimpleCamera;
|
13
13
|
forceSpriteSize?: boolean;
|
14
14
|
};
|
15
|
-
export declare class Particle extends p5.Vector implements
|
15
|
+
export declare class Particle extends p5.Vector implements Initializer<ParticleInitialParams> {
|
16
16
|
private vec;
|
17
17
|
private acc;
|
18
18
|
private angle;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"particle.d.ts","sourceRoot":"","sources":["../../src/classes/particle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"particle.d.ts","sourceRoot":"","sources":["../../src/classes/particle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI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1,7 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { Configurable } from "../export-types";
|
2
|
+
import { EntitySuit } from "./entities/entity-suit";
|
3
3
|
import { LogicComponent } from "./logic-component";
|
4
|
-
export declare class Prefab<C extends
|
5
|
-
constructor(
|
4
|
+
export declare class Prefab<C extends EntitySuit = EntitySuit> extends LogicComponent<C> {
|
5
|
+
constructor(configurable: Configurable<C>);
|
6
6
|
}
|
7
7
|
//# sourceMappingURL=prefab.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prefab.d.ts","sourceRoot":"","sources":["../../src/classes/prefab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"prefab.d.ts","sourceRoot":"","sources":["../../src/classes/prefab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,qBAAa,MAAM,CACjB,CAAC,SAAS,UAAU,GAAG,UAAU,CACjC,SAAQ,cAAc,CAAC,CAAC,CAAC;gBACb,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;CAG1C"}
|
package/lib/classes/prefab.js
CHANGED
@@ -16,8 +16,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
16
16
|
import { LogicComponent } from "./logic-component";
|
17
17
|
var Prefab = /** @class */ (function (_super) {
|
18
18
|
__extends(Prefab, _super);
|
19
|
-
function Prefab(
|
20
|
-
return _super.call(this,
|
19
|
+
function Prefab(configurable) {
|
20
|
+
return _super.call(this, configurable, true) || this;
|
21
21
|
}
|
22
22
|
return Prefab;
|
23
23
|
}(LogicComponent));
|
package/lib/classes/scene.d.ts
CHANGED
@@ -3,7 +3,7 @@ import { ComponentType, ReactElement } from "react";
|
|
3
3
|
import { LogicComponent } from "./logic-component";
|
4
4
|
import { SceneManagement } from "./scene-management";
|
5
5
|
import { WorldManagement } from "./world-management";
|
6
|
-
import {
|
6
|
+
import { EntitySuit } from "./entities/entity-suit";
|
7
7
|
import { Prefab } from "./prefab";
|
8
8
|
import { Sound } from "./sound";
|
9
9
|
import { AssetErrorType, AssetsFailBehavior, Avatar, GetSoundOptions, JoystickAction, SoundManagement } from "../export-types";
|
@@ -56,7 +56,7 @@ export declare abstract class Scene<UIP = any> {
|
|
56
56
|
private bootSoundOptions;
|
57
57
|
protected getSoundOptions(): GetSoundOptions;
|
58
58
|
protected onBorn(): void;
|
59
|
-
protected getComponents(simpleCamera: SimpleCamera): LogicComponent<
|
59
|
+
protected getComponents(simpleCamera: SimpleCamera): LogicComponent<EntitySuit>[];
|
60
60
|
getUIProps(): Partial<UIP>;
|
61
61
|
getInitialData(): {
|
62
62
|
joystick?: boolean;
|
@@ -77,19 +77,19 @@ export declare abstract class Scene<UIP = any> {
|
|
77
77
|
switchToScene(tag: string): void;
|
78
78
|
private loadSprites;
|
79
79
|
private loadSounds;
|
80
|
-
createSprites(...
|
80
|
+
createSprites(...sources: (string | {
|
81
81
|
src: string;
|
82
82
|
})[]): Promise<import("p5").Image[]>;
|
83
|
-
createSounds(...
|
83
|
+
createSounds(...sources: (string | {
|
84
84
|
src: string;
|
85
85
|
volume?: number;
|
86
86
|
type?: SoundType;
|
87
87
|
})[]): Promise<Sound[]>;
|
88
|
-
mapSprites(...
|
89
|
-
mapSounds(...
|
88
|
+
mapSprites(...sources: string[]): Promise<void>;
|
89
|
+
mapSounds(...sources: string[]): Promise<void>;
|
90
90
|
loadAssets(delay: number | undefined | null, { skip, render }?: AssetsFailBehavior): Promise<void>;
|
91
91
|
onLoadAssets(): Promise<void>;
|
92
|
-
getPrefab<C extends
|
92
|
+
getPrefab<C extends EntitySuit>(Class: {
|
93
93
|
new (...args: any[]): Prefab<C>;
|
94
94
|
}): Prefab<C>;
|
95
95
|
listenNativeEvents(): void;
|
@@ -1 +1 @@
|
|
1
|
-
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AAA;KAAE,CAAC,EAAE;IAsBvE,UAAU,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE;IAgB/B,SAAS,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE;IAc9B,UAAU,CACd,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAChC,EAAE,IAAY,EAAE,MAAM,EAAE,GAAE,kBAAuB;IAyD7C,YAAY;IAElB,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,KAAK,EAAE;QACrC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;KACjC,GAAG,MAAM,CAAC,CAAC,CAAC;IAIb,kBAAkB;IAelB,SAAS,CAAC,eAAe,CAAC,YAAY,EAAE,YAAY;IAEpD,OAAO,CAAC,aAAa;IAIrB,SAAS,CAAC,YAAY,EAAE,YAAY;IAyCpC,SAAS,CAAC,MAAM;IAChB,SAAS,CAAC,QAAQ;IAElB,SAAS;IAQT,YAAY;IAQZ,YAAY;IAQZ,MAAM;CAUP"}
|
package/lib/classes/scene.js
CHANGED
@@ -306,16 +306,16 @@ var Scene = /** @class */ (function () {
|
|
306
306
|
};
|
307
307
|
Scene.prototype.createSprites = function () {
|
308
308
|
var _this_1 = this;
|
309
|
-
var
|
309
|
+
var sources = [];
|
310
310
|
for (var _i = 0; _i < arguments.length; _i++) {
|
311
|
-
|
311
|
+
sources[_i] = arguments[_i];
|
312
312
|
}
|
313
|
-
return parallel(
|
313
|
+
return parallel(sources, function (source) { return __awaiter(_this_1, void 0, void 0, function () {
|
314
314
|
var src, sprite;
|
315
315
|
return __generator(this, function (_a) {
|
316
316
|
switch (_a.label) {
|
317
317
|
case 0:
|
318
|
-
src = (typeof
|
318
|
+
src = (typeof source === "string" ? { src: source } : source).src;
|
319
319
|
return [4 /*yield*/, createAssetImage(src)];
|
320
320
|
case 1:
|
321
321
|
sprite = _a.sent();
|
@@ -326,24 +326,24 @@ var Scene = /** @class */ (function () {
|
|
326
326
|
}); }, MAX_ASSET_PARALLEL_LOAD);
|
327
327
|
};
|
328
328
|
Scene.prototype.createSounds = function () {
|
329
|
-
var
|
329
|
+
var sources = [];
|
330
330
|
for (var _i = 0; _i < arguments.length; _i++) {
|
331
|
-
|
331
|
+
sources[_i] = arguments[_i];
|
332
332
|
}
|
333
333
|
return __awaiter(this, void 0, void 0, function () {
|
334
|
-
var sounds, _a,
|
334
|
+
var sounds, _a, sources_1, source, _b, volume, src, _c, type, sound;
|
335
335
|
return __generator(this, function (_d) {
|
336
336
|
switch (_d.label) {
|
337
337
|
case 0:
|
338
338
|
sounds = [];
|
339
|
-
_a = 0,
|
339
|
+
_a = 0, sources_1 = sources;
|
340
340
|
_d.label = 1;
|
341
341
|
case 1:
|
342
|
-
if (!(_a <
|
343
|
-
|
344
|
-
_b = typeof
|
345
|
-
? { src:
|
346
|
-
:
|
342
|
+
if (!(_a < sources_1.length)) return [3 /*break*/, 4];
|
343
|
+
source = sources_1[_a];
|
344
|
+
_b = typeof source === "string"
|
345
|
+
? { src: source, volume: undefined, type: undefined }
|
346
|
+
: source, volume = _b.volume, src = _b.src, _c = _b.type, type = _c === void 0 ? SoundType.ONCE : _c;
|
347
347
|
return [4 /*yield*/, createAssetSound(src, type)];
|
348
348
|
case 2:
|
349
349
|
sound = _d.sent();
|
@@ -362,9 +362,9 @@ var Scene = /** @class */ (function () {
|
|
362
362
|
});
|
363
363
|
};
|
364
364
|
Scene.prototype.mapSprites = function () {
|
365
|
-
var
|
365
|
+
var sources = [];
|
366
366
|
for (var _i = 0; _i < arguments.length; _i++) {
|
367
|
-
|
367
|
+
sources[_i] = arguments[_i];
|
368
368
|
}
|
369
369
|
return __awaiter(this, void 0, void 0, function () {
|
370
370
|
var spritesDecor;
|
@@ -373,7 +373,7 @@ var Scene = /** @class */ (function () {
|
|
373
373
|
switch (_a.label) {
|
374
374
|
case 0:
|
375
375
|
spritesDecor = this.spritesDecor.filter(function (decor) { return !decor.src; });
|
376
|
-
return [4 /*yield*/, parallel(
|
376
|
+
return [4 /*yield*/, parallel(sources, function (src, _a) {
|
377
377
|
var realIndex = _a.realIndex;
|
378
378
|
return __awaiter(_this_1, void 0, void 0, function () {
|
379
379
|
var decor, sprite;
|
@@ -401,9 +401,9 @@ var Scene = /** @class */ (function () {
|
|
401
401
|
});
|
402
402
|
};
|
403
403
|
Scene.prototype.mapSounds = function () {
|
404
|
-
var
|
404
|
+
var sources = [];
|
405
405
|
for (var _i = 0; _i < arguments.length; _i++) {
|
406
|
-
|
406
|
+
sources[_i] = arguments[_i];
|
407
407
|
}
|
408
408
|
return __awaiter(this, void 0, void 0, function () {
|
409
409
|
var soundsDecor, index, _a, soundsDecor_1, decor, src, sound;
|
@@ -417,7 +417,7 @@ var Scene = /** @class */ (function () {
|
|
417
417
|
case 1:
|
418
418
|
if (!(_a < soundsDecor_1.length)) return [3 /*break*/, 4];
|
419
419
|
decor = soundsDecor_1[_a];
|
420
|
-
src =
|
420
|
+
src = sources[index++];
|
421
421
|
return [4 /*yield*/, createAssetSound(src, decor.type)];
|
422
422
|
case 2:
|
423
423
|
sound = _b.sent();
|
@@ -495,7 +495,7 @@ var Scene = /** @class */ (function () {
|
|
495
495
|
this.loadedAssetsError = errors_1;
|
496
496
|
}
|
497
497
|
else {
|
498
|
-
// when
|
498
|
+
// when don't have error or skip error
|
499
499
|
this.loadedAssets = true;
|
500
500
|
}
|
501
501
|
return [2 /*return*/];
|
package/lib/classes/sound.js
CHANGED
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
36
36
|
};
|
37
37
|
var _a;
|
38
38
|
import { SoundType } from "../export-enums";
|
39
|
-
// cant not Sound extends Audio, because TS
|
39
|
+
// cant not Sound extends Audio, because TS compile, make call new Audio like a function
|
40
40
|
var Sound = /** @class */ (function () {
|
41
41
|
function Sound(type) {
|
42
42
|
if (type === void 0) { type = SoundType.ONCE; }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Avatar } from "../../export-types";
|
2
2
|
import { GetInitialParams, Sprite } from "./sprite";
|
3
|
-
declare type
|
3
|
+
declare type SpriteOffset = {
|
4
4
|
x: number;
|
5
5
|
y: number;
|
6
6
|
width: number;
|
@@ -8,11 +8,11 @@ declare type SpriteOffet = {
|
|
8
8
|
index: number;
|
9
9
|
};
|
10
10
|
declare type AvatarGetInitialParams<S extends AvatarSprite> = GetInitialParams<S> & {
|
11
|
-
offset?: Partial<
|
11
|
+
offset?: Partial<SpriteOffset>;
|
12
12
|
};
|
13
13
|
export declare class AvatarSprite extends Sprite<Avatar | undefined | null> {
|
14
14
|
private _offset;
|
15
|
-
get offset():
|
15
|
+
get offset(): SpriteOffset;
|
16
16
|
onDraw(): void;
|
17
17
|
initial(params?: AvatarGetInitialParams<this>): void;
|
18
18
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"avatar.sprite.d.ts","sourceRoot":"","sources":["../../../src/classes/sprites/avatar.sprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEpD,aAAK,
|
1
|
+
{"version":3,"file":"avatar.sprite.d.ts","sourceRoot":"","sources":["../../../src/classes/sprites/avatar.sprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEpD,aAAK,YAAY,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,aAAK,sBAAsB,CAAC,CAAC,SAAS,YAAY,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG;IAE1E,MAAM,CAAC,EAA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AM,EAKxB;IAED,IAAI,MAAM,IAPS,MAAM,CASxB;IAED,IAAI,KAAK,WAER;IAED,IAAI,MAAM,WAET;IAED,IAAI;IAYJ,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEvB,OAAO,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC;CAexC"}
|
@@ -63,11 +63,12 @@ var Sprite = /** @class */ (function () {
|
|
63
63
|
});
|
64
64
|
Sprite.prototype.draw = function () {
|
65
65
|
var _this = this;
|
66
|
-
var _a = this.entity, body = _a.body, position = _a.position, havePhysicBody = _a.havePhysicBody;
|
66
|
+
var _a = this.entity, body = _a.body, position = _a.position, havePhysicBody = _a.havePhysicBody, scaleX = _a.scaleX, scaleY = _a.scaleY;
|
67
67
|
Renderer.drawHandle(position, function () {
|
68
68
|
if (havePhysicBody) {
|
69
69
|
Renderer.rotate(body.angle);
|
70
70
|
}
|
71
|
+
Renderer.scale(scaleX, scaleY);
|
71
72
|
_this.onDraw();
|
72
73
|
});
|
73
74
|
};
|
package/lib/classes/watcher.js
CHANGED
@@ -27,7 +27,7 @@ export function Watcher(_a) {
|
|
27
27
|
var names = Array.isArray(_names) ? _names : [_names];
|
28
28
|
var _b = useState(initialValues), values = _b[0], setValues = _b[1];
|
29
29
|
useEffect(function () {
|
30
|
-
var
|
30
|
+
var unSubs = names.map(function (name) {
|
31
31
|
return scene.onEntityPropsChange(name, function (value) {
|
32
32
|
setValues(function (prev) {
|
33
33
|
var _a;
|
@@ -36,9 +36,9 @@ export function Watcher(_a) {
|
|
36
36
|
});
|
37
37
|
});
|
38
38
|
return function () {
|
39
|
-
for (var _i = 0,
|
40
|
-
var
|
41
|
-
|
39
|
+
for (var _i = 0, unSubs_1 = unSubs; _i < unSubs_1.length; _i++) {
|
40
|
+
var unSub = unSubs_1[_i];
|
41
|
+
unSub();
|
42
42
|
}
|
43
43
|
};
|
44
44
|
}, __spreadArray(__spreadArray([], names, true), [scene], false));
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Engine, Body } from "matter-js";
|
2
2
|
import { SimpleCamera } from "./simple-camera";
|
3
3
|
import { Scene } from "./scene";
|
4
|
-
import {
|
4
|
+
import { EntitySuit } from "./entities/entity-suit";
|
5
5
|
export declare class WorldManagement {
|
6
6
|
private _camera;
|
7
7
|
private _scene;
|
@@ -14,20 +14,20 @@ export declare class WorldManagement {
|
|
14
14
|
get engine(): Engine;
|
15
15
|
get camera(): SimpleCamera;
|
16
16
|
get scene(): Scene<any>;
|
17
|
-
iterateEntities(action: (entity:
|
17
|
+
iterateEntities(action: (entity: EntitySuit) => boolean | undefined | void): void;
|
18
18
|
private joinPool;
|
19
19
|
private outPool;
|
20
20
|
destructor(): void;
|
21
|
-
changeEntityLayerIndex(entity:
|
22
|
-
changeEntityName(entity:
|
21
|
+
changeEntityLayerIndex(entity: EntitySuit, newIndex: number): void;
|
22
|
+
changeEntityName(entity: EntitySuit, newName: string): void;
|
23
23
|
bootstrapCompleted(): void;
|
24
|
-
getEntity<T extends
|
24
|
+
getEntity<T extends EntitySuit = EntitySuit>(name: string | {
|
25
25
|
new (): T;
|
26
26
|
}): T;
|
27
27
|
addBody(body: Body): void;
|
28
28
|
removeBody(body: Body): void;
|
29
|
-
addEntity(entity:
|
30
|
-
removeEntity(entity:
|
29
|
+
addEntity(entity: EntitySuit): void;
|
30
|
+
removeEntity(entity: EntitySuit): void;
|
31
31
|
update(): void;
|
32
32
|
draw(): void;
|
33
33
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"world-management.d.ts","sourceRoot":"","sources":["../../src/classes/world-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,IAAI,EAAE,MAAM,WAAW,CAAC;AAIxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
1
|
+
{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AAU;IAoB/B,MAAM;IAiBN,IAAI;CAqBL"}
|
@@ -141,14 +141,14 @@ var WorldManagement = /** @class */ (function () {
|
|
141
141
|
return this.entitiesHash[id];
|
142
142
|
}
|
143
143
|
else {
|
144
|
-
var
|
144
|
+
var found_1;
|
145
145
|
this.iterateEntities(function (entity) {
|
146
146
|
if (entity instanceof name) {
|
147
|
-
|
147
|
+
found_1 = entity;
|
148
148
|
return true;
|
149
149
|
}
|
150
150
|
});
|
151
|
-
return
|
151
|
+
return found_1;
|
152
152
|
}
|
153
153
|
};
|
154
154
|
WorldManagement.prototype.addBody = function (body) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sound-from.decor.d.ts","sourceRoot":"","sources":["../../src/decorators/sound-from.decor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,wBAAgB,SAAS,CACvB,
|
1
|
+
{"version":3,"file":"sound-from.decor.d.ts","sourceRoot":"","sources":["../../src/decorators/sound-from.decor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,wBAAgB,SAAS,CACvB,MAAM,CAAC,EAAE,MAAM,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EACnD,IAAI,GAAE,SAA0B,YAEP,GAAG,eAAe,MAAM,UAiBlD"}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { SoundType } from "../export-enums";
|
2
|
-
export function SoundFrom(
|
2
|
+
export function SoundFrom(source, type) {
|
3
3
|
if (type === void 0) { type = SoundType.ONCE; }
|
4
4
|
return function (target, propertyKey) {
|
5
|
-
var _a =
|
6
|
-
? typeof
|
7
|
-
? { src:
|
8
|
-
:
|
5
|
+
var _a = source
|
6
|
+
? typeof source === "string"
|
7
|
+
? { src: source, volume: undefined }
|
8
|
+
: source
|
9
9
|
: { volume: undefined, src: undefined }, volume = _a.volume, src = _a.src;
|
10
10
|
if (!target.soundsDecor) {
|
11
11
|
target.soundsDecor = [];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sprite-from.decor.d.ts","sourceRoot":"","sources":["../../src/decorators/sprite-from.decor.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,
|
1
|
+
{"version":3,"file":"sprite-from.decor.d.ts","sourceRoot":"","sources":["../../src/decorators/sprite-from.decor.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,YAClC,GAAG,eAAe,MAAM,UAelD"}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
export function SpriteFrom(
|
1
|
+
export function SpriteFrom(source) {
|
2
2
|
return function (target, propertyKey) {
|
3
|
-
var src = (
|
4
|
-
? typeof
|
5
|
-
? { src:
|
6
|
-
:
|
3
|
+
var src = (source
|
4
|
+
? typeof source === "string"
|
5
|
+
? { src: source }
|
6
|
+
: source
|
7
7
|
: { src: undefined }).src;
|
8
8
|
if (!target.spritesDecor) {
|
9
9
|
target.spritesDecor = [];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"export-interfaces.d.ts","sourceRoot":"","sources":["../src/export-interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,
|
1
|
+
{"version":3,"file":"export-interfaces.d.ts","sourceRoot":"","sources":["../src/export-interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAClC,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;CAC9B"}
|
package/lib/export-types.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Entity } from "./classes/entities/entity";
|
2
2
|
import { Sprite } from "./classes/sprites/sprite";
|
3
3
|
import type { Body, IChamferableBodyDefinition } from "matter-js";
|
4
|
-
import {
|
4
|
+
import { Initializer } from "./export-interfaces";
|
5
5
|
import { Sound } from "./classes/sound";
|
6
6
|
import { SoundType } from "./export-enums";
|
7
7
|
export type { Collection } from "./classes/p5";
|
@@ -39,14 +39,16 @@ export declare type EntityInitial<E extends Entity> = {
|
|
39
39
|
sound?: Sound;
|
40
40
|
name?: string;
|
41
41
|
isVisible?: boolean;
|
42
|
+
scaleX?: number;
|
43
|
+
scaleY?: number;
|
42
44
|
props?: Partial<E["props"]>;
|
43
45
|
};
|
44
|
-
export declare type
|
45
|
-
export declare type
|
46
|
+
export declare type Configuration<C extends Initializer> = Parameters<C["initial"]>[0];
|
47
|
+
export declare type Configurable<C extends Initializer = Initializer> = {
|
46
48
|
new (): C;
|
47
49
|
} | [{
|
48
50
|
new (): C;
|
49
|
-
},
|
51
|
+
}, Configuration<C>];
|
50
52
|
export declare type SoundManagement = Record<SoundType, {
|
51
53
|
canPlay: boolean;
|
52
54
|
}>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"export-types.d.ts","sourceRoot":"","sources":["../src/export-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,KAAK,EAAE,IAAI,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"export-types.d.ts","sourceRoot":"","sources":["../src/export-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,KAAK,EAAE,IAAI,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,S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CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IACjD;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,GAAG,CAAC,CAAC;AAEN,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/lib/hooks/entity.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { EntitySuit } from "../classes/entities/entity-suit";
|
2
2
|
declare type TargetFind<T> = string | {
|
3
3
|
new (): T;
|
4
4
|
};
|
5
|
-
export declare function useEntity<T extends
|
5
|
+
export declare function useEntity<T extends EntitySuit = EntitySuit>(...entityClasses: TargetFind<T>[]): T[];
|
6
6
|
export {};
|
7
7
|
//# sourceMappingURL=entity.d.ts.map
|
package/lib/hooks/watcher.js
CHANGED
@@ -25,7 +25,7 @@ export function useWatcher(name, initialValues) {
|
|
25
25
|
var names = Array.isArray(name) ? name : [name];
|
26
26
|
var _a = useState(initialValues), values = _a[0], setValues = _a[1];
|
27
27
|
useEffect(function () {
|
28
|
-
var
|
28
|
+
var unSubs = names.map(function (name) {
|
29
29
|
return scene.onEntityPropsChange(name, function (value) {
|
30
30
|
setValues(function (prev) {
|
31
31
|
var _a;
|
@@ -34,9 +34,9 @@ export function useWatcher(name, initialValues) {
|
|
34
34
|
});
|
35
35
|
});
|
36
36
|
return function () {
|
37
|
-
for (var _i = 0,
|
38
|
-
var
|
39
|
-
|
37
|
+
for (var _i = 0, unSubs_1 = unSubs; _i < unSubs_1.length; _i++) {
|
38
|
+
var unSub = unSubs_1[_i];
|
39
|
+
unSub();
|
40
40
|
}
|
41
41
|
};
|
42
42
|
}, __spreadArray(__spreadArray([], names, true), [scene], false));
|
@@ -12,7 +12,7 @@ var __assign = (this && this.__assign) || function () {
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
13
|
import { useMemo } from "react";
|
14
14
|
import { useLongPress } from "../hooks/interact";
|
15
|
-
import {
|
15
|
+
import { getClassName } from "../utils";
|
16
16
|
export function Control(_a) {
|
17
17
|
var _b = _a.xAxisOriginCenter, xAxisOriginCenter = _b === void 0 ? false : _b, _c = _a.yAxisOriginCenter, yAxisOriginCenter = _c === void 0 ? false : _c, top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom, children = _a.children, _d = _a.orientation, orientation = _d === void 0 ? "vertical" : _d, _e = _a.alignment, alignment = _e === void 0 ? "flex-start" : _e, _f = _a.interact, interact = _f === void 0 ? {} : _f;
|
18
18
|
var longPressProps = useLongPress(interact.onLongPress, interact.delay, interact.exts);
|
@@ -21,7 +21,7 @@ export function Control(_a) {
|
|
21
21
|
var y = yAxisOriginCenter ? "".concat(top != null ? -50 : 50, "%") : 0;
|
22
22
|
return "translate(".concat(x, ",").concat(y, ")");
|
23
23
|
}, [left, top, xAxisOriginCenter, yAxisOriginCenter]);
|
24
|
-
return (_jsx("div", __assign({ className:
|
24
|
+
return (_jsx("div", __assign({ className: getClassName("ui-control"), style: {
|
25
25
|
top: top,
|
26
26
|
left: left,
|
27
27
|
right: right,
|
@@ -10,8 +10,8 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
-
import {
|
13
|
+
import { getClassName } from "../utils";
|
14
14
|
export function FloatContainer(_a) {
|
15
15
|
var children = _a.children, style = _a.style, id = _a.id;
|
16
|
-
return (_jsx("div", __assign({ className:
|
16
|
+
return (_jsx("div", __assign({ className: getClassName("float-container"), style: style }, { children: _jsx("div", __assign({ id: id }, { children: children })) })));
|
17
17
|
}
|
@@ -23,7 +23,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
23
23
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
24
24
|
import { useEffect, useMemo, useState } from "react";
|
25
25
|
import { SceneManagement } from "../classes/scene-management";
|
26
|
-
import {
|
26
|
+
import { getClassName } from "../utils";
|
27
27
|
import { Logger } from "./logger";
|
28
28
|
import { SceneRunner } from "./scene-runner";
|
29
29
|
export function GameBootstrap(_a) {
|
@@ -53,9 +53,9 @@ export function GameBootstrap(_a) {
|
|
53
53
|
document.createElement("style");
|
54
54
|
style.id = "game-container-style-wrap";
|
55
55
|
document.head.appendChild(style);
|
56
|
-
var gameRootClass =
|
57
|
-
var gameLoggerClass =
|
58
|
-
style.appendChild(document.createTextNode("\n .".concat(
|
56
|
+
var gameRootClass = getClassName("game-root");
|
57
|
+
var gameLoggerClass = getClassName("game-logger");
|
58
|
+
style.appendChild(document.createTextNode("\n .".concat(getClassName("assets-fail-view"), "{\n background-color: #f28181a1;\n min-height: 100px;\n padding: 10px;\n color: #000;\n }\n \n .").concat(getClassName("game-modal"), " {\n position: fixed;\n top: 0;\n left: 0;\n }\n\n .").concat(getClassName("scene-modal-stack"), "{\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n z-index: 2;\n }\n \n .").concat(getClassName("modal-content-main"), "{\n position: relative;\n z-index: 1;\n min-width: 200px;\n min-height: 200px;\n }\n\n .").concat(getClassName("modal-content-closer"), "{\n width: 100%;\n height: 100%;\n position: absolute;\n z-index: 0;\n }\n .").concat(getClassName("modal-content-centered"), "{\n width: 100%;\n height: 100%;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .").concat(getClassName("modal-content-wrap"), "{\n width: 100%;\n height: 100%;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n .").concat(gameRootClass, ", .").concat(gameRootClass, " *,\n .").concat(gameLoggerClass, ", .").concat(gameLoggerClass, " *\n {\n box-sizing: border-box;\n -webkit-touch-callout: none;\n -webkit-tap-highlight-color: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n text-size-adjust: none;\n }\n\n .").concat(gameRootClass, " {\n overflow: hidden;\n position: relative;\n }\n\n .").concat(gameLoggerClass, " {\n z-index: 4;\n position: fixed;\n top:0;\n right:0;\n }\n\n .").concat(getClassName("message-stack"), " {\n width: cacl(100vw - 40px);\n max-width: 300px;\n max-height: calc(50vh - 50px);\n min-width: 200px;\n min-height: 150px;\n position: absolute;\n top: 5px;\n right: 5px;\n padding: 5px;\n background-color: #0000007b;\n color: #fff;\n font-size: 0.8rem;\n\n display: flex;\n flex-direction: column;\n }\n\n .").concat(getClassName("message-stack-heading"), "{\n width: 100%;\n display: flex;\n justify-content: flex-end;\n }\n\n .").concat(getClassName("message-stack-content"), "{\n flex: 1;\n width: 100%;\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n\n .").concat(getClassName("float-container"), " {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n .").concat(getClassName("float-container"), " > div {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .").concat(getClassName("ui-control"), " {\n position: absolute;\n display: inline-flex;\n }\n\n .").concat(getClassName("scaler-container"), " {\n width: 100%;\n height: 100%;\n position: relative;\n top: 0;\n left: 0;\n }\n\n .").concat(getClassName("scaler-container"), " > div {\n transform-origin: left top;\n position: relative;\n top: 50%;\n left: 50%;\n }\n ")));
|
59
59
|
}, []);
|
60
60
|
return (_jsxs(_Fragment, { children: [_jsx(SceneRunner, __assign({ current: currentScene }, props), currentScene.sessionId), logPopup && _jsx(Logger, {})] }));
|
61
61
|
}
|
@@ -21,13 +21,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
21
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
22
22
|
import { useCallback, useMemo, useRef, useState } from "react";
|
23
23
|
import ReactDOM from "react-dom";
|
24
|
-
import {
|
24
|
+
import { getClassName, toText } from "../utils";
|
25
25
|
export function Logger() {
|
26
26
|
var _a = useState([]), messages = _a[0], setMessages = _a[1];
|
27
27
|
var refList = useRef(null);
|
28
28
|
var container = useMemo(function () {
|
29
29
|
var c = document.createElement("div");
|
30
|
-
c.className =
|
30
|
+
c.className = getClassName("game-logger");
|
31
31
|
document.body.appendChild(c);
|
32
32
|
return c;
|
33
33
|
}, []);
|
@@ -87,5 +87,5 @@ export function Logger() {
|
|
87
87
|
pushMessage(args);
|
88
88
|
};
|
89
89
|
}, [pushMessage]);
|
90
|
-
return ReactDOM.createPortal(messages.length ? (_jsxs("div", __assign({ className:
|
90
|
+
return ReactDOM.createPortal(messages.length ? (_jsxs("div", __assign({ className: getClassName("message-stack") }, { children: [_jsx("div", __assign({ className: getClassName("message-stack-heading") }, { children: _jsx("p", __assign({ onClick: function () { return setMessages([]); } }, { children: "X Clear" })) })), _jsx("div", __assign({ className: getClassName("message-stack-content"), ref: refList }, { children: messages.map(function (mss, i) { return (_jsxs("p", { children: ["- ", mss] }, i)); }) }))] }))) : null, container);
|
91
91
|
}
|
@@ -12,14 +12,14 @@ var __assign = (this && this.__assign) || function () {
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
13
13
|
import { useMemo, useEffect, useState, useCallback, forwardRef, cloneElement, useImperativeHandle, useRef, memo, } from "react";
|
14
14
|
import * as ReactDOM from "react-dom";
|
15
|
-
import {
|
15
|
+
import { getClassName } from "../utils";
|
16
16
|
export var Modal = forwardRef(function (_a, ref) {
|
17
17
|
var _b;
|
18
18
|
var backgroundStyle = _a.backgroundStyle, trigger = _a.children, content = _a.content, _c = _a.defaultOpen, defaultOpen = _c === void 0 ? false : _c, onClose = _a.onClose, _d = _a.event, event = _d === void 0 ? "onClick" : _d;
|
19
19
|
var _e = useState(defaultOpen), isOpen = _e[0], setOpen = _e[1];
|
20
20
|
var container = useMemo(function () {
|
21
21
|
var c = document.createElement("div");
|
22
|
-
c.className =
|
22
|
+
c.className = getClassName("game-modal");
|
23
23
|
return c;
|
24
24
|
}, []);
|
25
25
|
useEffect(function () {
|
@@ -72,5 +72,5 @@ var ModalWrap = memo(function (_a) {
|
|
72
72
|
close: handleClose,
|
73
73
|
}, content.props.children);
|
74
74
|
}, [content]);
|
75
|
-
return (_jsx("div", __assign({ className:
|
75
|
+
return (_jsx("div", __assign({ className: getClassName("modal-content-wrap") }, { children: _jsxs("div", __assign({ className: getClassName("modal-content-centered"), ref: refModal }, { children: [_jsx("div", { className: getClassName("modal-content-closer"), style: __assign({}, backgroundStyle), onClick: handleClose }), _jsx("main", __assign({ className: getClassName("modal-content-main") }, { children: el }))] })) })));
|
76
76
|
});
|
@@ -10,10 +10,10 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
-
import {
|
13
|
+
import { getClassName } from "../utils";
|
14
14
|
export function ScalerContainer(_a) {
|
15
15
|
var width = _a.width, height = _a.height, value = _a.value, children = _a.children;
|
16
|
-
return (_jsx("div", __assign({ className:
|
16
|
+
return (_jsx("div", __assign({ className: getClassName("scaler-container") }, { children: _jsx("div", __assign({ style: {
|
17
17
|
width: width,
|
18
18
|
height: height,
|
19
19
|
transform: "scale(".concat(value, ") translate(-50%, -50%)"),
|
@@ -12,7 +12,7 @@ var __assign = (this && this.__assign) || function () {
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
13
13
|
import { useEffect, useMemo, useRef, useState, } from "react";
|
14
14
|
import { Scaler } from "../classes/scaler";
|
15
|
-
import {
|
15
|
+
import { getClassName, useWindowSize } from "../utils";
|
16
16
|
import { LayoutMode } from "../export-enums";
|
17
17
|
import { UISceneContext } from "../react-context";
|
18
18
|
import { ScalerContainer } from "./scaler-container";
|
@@ -70,7 +70,7 @@ export function SceneRunner(_a) {
|
|
70
70
|
}
|
71
71
|
return (AssetsLoader !== null && AssetsLoader !== void 0 ? AssetsLoader : _jsx("div", { children: "Assets loading..." }));
|
72
72
|
}, [AssetsLoader]);
|
73
|
-
return (_jsxs("div", __assign({ className:
|
73
|
+
return (_jsxs("div", __assign({ className: getClassName("game-root"), style: {
|
74
74
|
width: screenSize.width,
|
75
75
|
height: screenSize.height,
|
76
76
|
} }, { children: [_jsx(FloatContainer, __assign({ style: {
|
@@ -84,9 +84,9 @@ export function SceneRunner(_a) {
|
|
84
84
|
? (function () {
|
85
85
|
var rendered = current.renderAssetsFail();
|
86
86
|
if (Array.isArray(rendered)) {
|
87
|
-
return (_jsx("div", __assign({ className:
|
87
|
+
return (_jsx("div", __assign({ className: getClassName("assets-fail-view") }, { children: rendered.map(function (item, i) { return (_jsxs("p", { children: ["- ", item.type, ": ", item.detail] }, i)); }) })));
|
88
88
|
}
|
89
89
|
return rendered;
|
90
90
|
})()
|
91
|
-
: assetsLoader })) : (_jsx(_Fragment, { children: isBootDone ? (_jsxs(UISceneContext.Provider, __assign({ value: current }, { children: [_jsx(current.UI, __assign({ scene: current }, current.getUIProps())), joystick && (_jsx(MovementControl, __assign({}, (joystick === true ? {} : joystick)))), _jsx("div", { className:
|
91
|
+
: assetsLoader })) : (_jsx(_Fragment, { children: isBootDone ? (_jsxs(UISceneContext.Provider, __assign({ value: current }, { children: [_jsx(current.UI, __assign({ scene: current }, current.getUIProps())), joystick && (_jsx(MovementControl, __assign({}, (joystick === true ? {} : joystick)))), _jsx("div", { className: getClassName("scene-modal-stack"), id: "scene-modal-stack" })] }))) : (_jsx("div", {})) })) }))] })));
|
92
92
|
}
|
package/lib/utils.d.ts
CHANGED
@@ -14,6 +14,6 @@ export declare function useWindowSize(): {
|
|
14
14
|
height: number;
|
15
15
|
};
|
16
16
|
export declare function toText(obj: Record<string, any> | Record<string, any>[]): string | Record<string, any>;
|
17
|
-
export declare function
|
17
|
+
export declare function getClassName(cls: string): string;
|
18
18
|
export declare function genId(length?: number): string;
|
19
19
|
//# sourceMappingURL=utils.d.ts.map
|
package/lib/utils.js
CHANGED
@@ -34,10 +34,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
35
35
|
}
|
36
36
|
};
|
37
|
-
import
|
37
|
+
import OutOfScopeP5 from "p5";
|
38
38
|
import { useEffect, useState } from "react";
|
39
39
|
import { Sound } from "./classes/sound";
|
40
|
-
var
|
40
|
+
var outOfScopeP5;
|
41
41
|
document.addEventListener("DOMContentLoaded", function () {
|
42
42
|
var noop = document.createElement("div");
|
43
43
|
noop.style.position = "absolute";
|
@@ -46,14 +46,14 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
46
46
|
noop.style.left = "-100%";
|
47
47
|
document.body.appendChild(noop);
|
48
48
|
setTimeout(function () {
|
49
|
-
|
49
|
+
outOfScopeP5 = new OutOfScopeP5(function (skt) { }, noop);
|
50
50
|
}, 0);
|
51
51
|
});
|
52
52
|
export function createAssetImage(src) {
|
53
53
|
return __awaiter(this, void 0, void 0, function () {
|
54
54
|
return __generator(this, function (_a) {
|
55
55
|
return [2 /*return*/, new Promise(function (res, rej) {
|
56
|
-
|
56
|
+
outOfScopeP5.loadImage(src, res, rej);
|
57
57
|
})];
|
58
58
|
});
|
59
59
|
});
|
@@ -191,7 +191,7 @@ export function toText(obj) {
|
|
191
191
|
}
|
192
192
|
}
|
193
193
|
var ENGINE_CLASS_PREFIX = "spt-hc_rsgn_";
|
194
|
-
export function
|
194
|
+
export function getClassName(cls) {
|
195
195
|
return ENGINE_CLASS_PREFIX + cls;
|
196
196
|
}
|
197
197
|
export function genId(length) {
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
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,OAA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