react-simple-game-engine 0.1.61 → 0.1.64
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/animation.d.ts +14 -0
- package/lib/classes/animations/animation.d.ts.map +1 -0
- package/lib/classes/animations/animation.js +35 -0
- package/lib/classes/animations/avatar.animation.d.ts +16 -0
- package/lib/classes/animations/avatar.animation.d.ts.map +1 -0
- package/lib/classes/animations/avatar.animation.js +45 -0
- package/lib/classes/animations/color.animation.d.ts +9 -0
- package/lib/classes/animations/color.animation.d.ts.map +1 -0
- package/lib/classes/animations/color.animation.js +33 -0
- package/lib/classes/camera.d.ts +14 -0
- package/lib/classes/camera.d.ts.map +1 -0
- package/lib/classes/camera.js +34 -0
- package/lib/classes/entities/circle.entity.d.ts +15 -0
- package/lib/classes/entities/circle.entity.d.ts.map +1 -0
- package/lib/classes/entities/circle.entity.js +55 -0
- package/lib/classes/entities/entity-sult.d.ts +34 -0
- package/lib/classes/entities/entity-sult.d.ts.map +1 -0
- package/lib/classes/entities/entity-sult.js +108 -0
- package/lib/classes/entities/entity.d.ts +55 -0
- package/lib/classes/entities/entity.d.ts.map +1 -0
- package/lib/classes/entities/entity.js +180 -0
- package/lib/classes/entities/rect.entity.d.ts +17 -0
- package/lib/classes/entities/rect.entity.d.ts.map +1 -0
- package/lib/classes/entities/rect.entity.js +56 -0
- package/lib/classes/logic-component.d.ts +16 -0
- package/lib/classes/logic-component.d.ts.map +1 -0
- package/lib/classes/logic-component.js +77 -0
- package/lib/classes/p5.d.ts +11 -0
- package/lib/classes/p5.d.ts.map +1 -0
- package/lib/classes/p5.js +58 -0
- package/lib/classes/particle-system.d.ts +30 -0
- package/lib/classes/particle-system.d.ts.map +1 -0
- package/lib/classes/particle-system.js +98 -0
- package/lib/classes/particle.d.ts +35 -0
- package/lib/classes/particle.d.ts.map +1 -0
- package/lib/classes/particle.js +117 -0
- package/lib/classes/prefab.d.ts +7 -0
- package/lib/classes/prefab.d.ts.map +1 -0
- package/lib/classes/prefab.js +24 -0
- package/lib/classes/saver.d.ts +11 -0
- package/lib/classes/saver.d.ts.map +1 -0
- package/lib/classes/saver.js +33 -0
- package/lib/classes/scene-management.d.ts +22 -0
- package/lib/classes/scene-management.d.ts.map +1 -0
- package/lib/classes/scene-management.js +58 -0
- package/lib/classes/scene.d.ts +75 -0
- package/lib/classes/scene.d.ts.map +1 -0
- package/lib/classes/scene.js +433 -0
- package/lib/classes/sound-watcher.d.ts +16 -0
- package/lib/classes/sound-watcher.d.ts.map +1 -0
- package/lib/classes/sound-watcher.js +33 -0
- package/lib/classes/sound.d.ts +14 -0
- package/lib/classes/sound.d.ts.map +1 -0
- package/lib/classes/sound.js +119 -0
- package/lib/classes/sprites/avatar.sprite.d.ts +20 -0
- package/lib/classes/sprites/avatar.sprite.d.ts.map +1 -0
- package/lib/classes/sprites/avatar.sprite.js +89 -0
- package/lib/classes/sprites/color.sprite.d.ts +7 -0
- package/lib/classes/sprites/color.sprite.d.ts.map +1 -0
- package/lib/classes/sprites/color.sprite.js +40 -0
- package/lib/classes/sprites/sprite.d.ts +26 -0
- package/lib/classes/sprites/sprite.d.ts.map +1 -0
- package/lib/classes/sprites/sprite.js +70 -0
- package/lib/classes/watcher.d.ts +11 -0
- package/lib/classes/watcher.d.ts.map +1 -0
- package/lib/classes/watcher.js +44 -0
- package/lib/classes/world-management.d.ts +28 -0
- package/lib/classes/world-management.d.ts.map +1 -0
- package/lib/classes/world-management.js +160 -0
- package/lib/decorators/scene-tag.decor.d.ts +6 -0
- package/lib/decorators/scene-tag.decor.d.ts.map +1 -0
- package/lib/decorators/scene-tag.decor.js +5 -0
- package/lib/decorators/scene-ui.decor.d.ts +7 -0
- package/lib/decorators/scene-ui.decor.d.ts.map +1 -0
- package/lib/decorators/scene-ui.decor.js +5 -0
- package/lib/decorators/sound-from.decor.d.ts +6 -0
- package/lib/decorators/sound-from.decor.d.ts.map +1 -0
- package/lib/decorators/sound-from.decor.js +17 -0
- package/lib/decorators/sprite-from.decor.d.ts +4 -0
- package/lib/decorators/sprite-from.decor.d.ts.map +1 -0
- package/lib/decorators/sprite-from.decor.js +13 -0
- package/lib/export-enums.d.ts.map +1 -0
- package/lib/export-enums.js +5 -0
- package/lib/export-interfaces.d.ts.map +1 -0
- package/lib/export-interfaces.js +1 -0
- package/lib/export-types.d.ts.map +1 -0
- package/lib/export-types.js +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/ui-components/SceneRunner.d.ts +14 -0
- package/lib/ui-components/SceneRunner.d.ts.map +1 -0
- package/lib/ui-components/SceneRunner.js +43 -0
- package/lib/ui-components/ScenesProcess.d.ts +9 -0
- package/lib/ui-components/ScenesProcess.d.ts.map +1 -0
- package/lib/ui-components/ScenesProcess.js +46 -0
- package/lib/ui-components/Sketch.d.ts +12 -0
- package/lib/ui-components/Sketch.d.ts.map +1 -0
- package/lib/ui-components/Sketch.js +33 -0
- package/lib/utilities.d.ts.map +1 -0
- package/lib/utilities.js +2 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +97 -0
- package/package.json +2 -6
@@ -0,0 +1,117 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
17
|
+
var t = {};
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
19
|
+
t[p] = s[p];
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
23
|
+
t[p[i]] = s[p[i]];
|
24
|
+
}
|
25
|
+
return t;
|
26
|
+
};
|
27
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
28
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
29
|
+
if (ar || !(i in from)) {
|
30
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
31
|
+
ar[i] = from[i];
|
32
|
+
}
|
33
|
+
}
|
34
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
35
|
+
};
|
36
|
+
import p5 from "p5";
|
37
|
+
import { copyProperties } from "../utils";
|
38
|
+
var Particle = /** @class */ (function (_super) {
|
39
|
+
__extends(Particle, _super);
|
40
|
+
function Particle() {
|
41
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
42
|
+
_this.vec = Renderer.createVector(); //velocity
|
43
|
+
_this.acc = Renderer.createVector(); //acceleration
|
44
|
+
_this.angle = 0;
|
45
|
+
_this.color = [255, 255, 255];
|
46
|
+
_this.size = 5;
|
47
|
+
_this.lifetimeRemain = _this.lifetime; // in seconds
|
48
|
+
_this.forceSpriteSize = false;
|
49
|
+
_this._lifetime = 2; // in seconds
|
50
|
+
return _this;
|
51
|
+
}
|
52
|
+
Object.defineProperty(Particle.prototype, "lifetime", {
|
53
|
+
get: function () {
|
54
|
+
return this._lifetime;
|
55
|
+
},
|
56
|
+
set: function (lifetime) {
|
57
|
+
this._lifetime = lifetime;
|
58
|
+
this.lifetimeRemain = lifetime;
|
59
|
+
},
|
60
|
+
enumerable: false,
|
61
|
+
configurable: true
|
62
|
+
});
|
63
|
+
Particle.prototype.initial = function (_a) {
|
64
|
+
var vec = _a.vec, params = __rest(_a, ["vec"]);
|
65
|
+
if (vec) {
|
66
|
+
this.vec.set(vec.x, vec.y);
|
67
|
+
}
|
68
|
+
copyProperties(this, params);
|
69
|
+
};
|
70
|
+
Particle.prototype.applyForce = function (force) {
|
71
|
+
this.acc.add(force);
|
72
|
+
};
|
73
|
+
Particle.prototype.isDead = function () {
|
74
|
+
return this.lifetimeRemain <= 0;
|
75
|
+
};
|
76
|
+
Particle.prototype.update = function () {
|
77
|
+
this.vec.add(this.acc);
|
78
|
+
this.add(this.vec);
|
79
|
+
this.acc.set(0);
|
80
|
+
this.lifetimeRemain -= Renderer.deltaTime / 1000;
|
81
|
+
};
|
82
|
+
Particle.prototype.draw = function () {
|
83
|
+
Renderer.push();
|
84
|
+
Renderer.noStroke();
|
85
|
+
Renderer.translate(this.x - this.camera.x, this.y - this.camera.y);
|
86
|
+
Renderer.rotate(this.angle);
|
87
|
+
var color = __spreadArray([], this.color, true);
|
88
|
+
var alpha = Renderer.map(this.lifetimeRemain, 0, this.lifetime, 0, 255);
|
89
|
+
color[3] = alpha;
|
90
|
+
if (this.sprite) {
|
91
|
+
var size = this.forceSpriteSize
|
92
|
+
? [this.size, this.size]
|
93
|
+
: [this.sprite.width, this.sprite.height];
|
94
|
+
Renderer.tint.apply(Renderer, color);
|
95
|
+
Renderer.image.apply(Renderer, __spreadArray(__spreadArray([this.sprite,
|
96
|
+
// position on canvas
|
97
|
+
0,
|
98
|
+
0], size, false), [
|
99
|
+
//crop on source image
|
100
|
+
0,
|
101
|
+
0,
|
102
|
+
this.sprite.width,
|
103
|
+
this.sprite.height], false));
|
104
|
+
}
|
105
|
+
else {
|
106
|
+
Renderer.fill.apply(Renderer, color);
|
107
|
+
this.onDraw(color);
|
108
|
+
}
|
109
|
+
//
|
110
|
+
Renderer.pop();
|
111
|
+
};
|
112
|
+
Particle.prototype.onDraw = function (_) {
|
113
|
+
Renderer.circle(0, 0, this.size);
|
114
|
+
};
|
115
|
+
return Particle;
|
116
|
+
}(p5.Vector));
|
117
|
+
export { Particle };
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { Configable } from "../export-types";
|
2
|
+
import { EntitySult } from "./entities/entity-sult";
|
3
|
+
import { LogicComponent } from "./logic-component";
|
4
|
+
export declare class Prefab<C extends EntitySult = EntitySult> extends LogicComponent<C> {
|
5
|
+
constructor(configale: Configable<C>);
|
6
|
+
}
|
7
|
+
//# sourceMappingURL=prefab.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"prefab.d.ts","sourceRoot":"","sources":["../../src/classes/prefab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,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,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;CAGrC"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { LogicComponent } from "./logic-component";
|
17
|
+
var Prefab = /** @class */ (function (_super) {
|
18
|
+
__extends(Prefab, _super);
|
19
|
+
function Prefab(configale) {
|
20
|
+
return _super.call(this, configale, true) || this;
|
21
|
+
}
|
22
|
+
return Prefab;
|
23
|
+
}(LogicComponent));
|
24
|
+
export { Prefab };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
declare type Typed = never | undefined | BooleanConstructor | StringConstructor | NumberConstructor;
|
2
|
+
declare type ValueType<V extends any = undefined, T extends Typed = Typed> = V extends undefined ? T extends BooleanConstructor ? boolean : T extends StringConstructor ? string : T extends NumberConstructor ? number : V : V;
|
3
|
+
declare class _Saver {
|
4
|
+
private store;
|
5
|
+
constructor();
|
6
|
+
set<V extends any = any>(key: string, value: V): void;
|
7
|
+
get<V extends any = undefined, T extends Typed = Typed>(key: string, type?: T): ValueType<V, T>;
|
8
|
+
}
|
9
|
+
export declare const Saver: _Saver;
|
10
|
+
export {};
|
11
|
+
//# sourceMappingURL=saver.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"saver.d.ts","sourceRoot":"","sources":["../../src/classes/saver.ts"],"names":[],"mappings":"AAAA,aAAK,KAAK,GACN,KAAK,GACL,SAAS,GACT,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,aAAK,SAAS,CACZ,CAAC,SAAS,GAAG,GAAG,SAAS,EACzB,CAAC,SAAS,KAAK,GAAG,KAAK,IACrB,CAAC,SAAS,SAAS,GACnB,CAAC,SAAS,kBAAkB,GAC1B,OAAO,GACP,CAAC,SAAS,iBAAiB,GAC3B,MAAM,GACN,CAAC,SAAS,iBAAiB,GAC3B,MAAM,GACN,CAAC,GACH,CAAC,CAAC;AAEN,cAAM,MAAM;IACV,OAAO,CAAC,KAAK,CAAuB;;IAOpC,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIrD,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,SAAS,EAAE,CAAC,SAAS,KAAK,GAAG,KAAK,EACpD,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,CAAC,GACP,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;CAoBnB;AAED,eAAO,MAAM,KAAK,QAAe,CAAC"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
var _Saver = /** @class */ (function () {
|
2
|
+
function _Saver() {
|
3
|
+
this.store = window.localStorage;
|
4
|
+
this.store
|
5
|
+
? console.log("Initial saver success")
|
6
|
+
: console.log("Initial saver fail");
|
7
|
+
}
|
8
|
+
_Saver.prototype.set = function (key, value) {
|
9
|
+
this.store.setItem(key, JSON.stringify(value));
|
10
|
+
};
|
11
|
+
_Saver.prototype.get = function (key, type) {
|
12
|
+
var raw = this.store.getItem(key);
|
13
|
+
var parsed = (raw == null ? raw : JSON.parse(raw));
|
14
|
+
if (type === Boolean) {
|
15
|
+
return (parsed === "0" || parsed === "false" || !parsed
|
16
|
+
? false
|
17
|
+
: true);
|
18
|
+
}
|
19
|
+
if (type === Number) {
|
20
|
+
return (parsed == null || isNaN(parsed)
|
21
|
+
? parsed
|
22
|
+
: +parsed);
|
23
|
+
}
|
24
|
+
if (type === String) {
|
25
|
+
return (parsed == null || typeof type === "string"
|
26
|
+
? parsed
|
27
|
+
: parsed.toString());
|
28
|
+
}
|
29
|
+
return parsed;
|
30
|
+
};
|
31
|
+
return _Saver;
|
32
|
+
}());
|
33
|
+
export var Saver = new _Saver();
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { Scene } from "./scene";
|
2
|
+
export declare type SceneClass = {
|
3
|
+
new (): Scene;
|
4
|
+
tag?: string;
|
5
|
+
};
|
6
|
+
declare type ChangeSceneListener = (scene: Scene) => void;
|
7
|
+
export declare class SceneManagement {
|
8
|
+
private Scenes;
|
9
|
+
private _currentScene;
|
10
|
+
private changeSceneListener;
|
11
|
+
static getTag(Scene: SceneClass): string | undefined;
|
12
|
+
constructor(Scenes: SceneClass[]);
|
13
|
+
get currentScene(): Scene<any>;
|
14
|
+
onChangeScene(func: ChangeSceneListener): void;
|
15
|
+
canNext(): boolean;
|
16
|
+
next(): void;
|
17
|
+
replay(): void;
|
18
|
+
gotoScene(tag: string): void;
|
19
|
+
private startScene;
|
20
|
+
}
|
21
|
+
export {};
|
22
|
+
//# sourceMappingURL=scene-management.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"scene-management.d.ts","sourceRoot":"","sources":["../../src/classes/scene-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,oBAAY,UAAU,GAAG;IAAE,QAAQ,KAAK,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACzD,aAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAElD,qBAAa,eAAe;IAOd,OAAO,CAAC,MAAM;IAN1B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,mBAAmB,CAAuB;IAClD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU;gBAIX,MAAM,EAAE,UAAU,EAAE;IAKxC,IAAI,YAAY,eAEf;IAED,aAAa,CAAC,IAAI,EAAE,mBAAmB;IAIvC,OAAO;IAQP,IAAI;IAUJ,MAAM;IAIN,SAAS,CAAC,GAAG,EAAE,MAAM;IAarB,OAAO,CAAC,UAAU;CAKnB"}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
var SceneManagement = /** @class */ (function () {
|
2
|
+
function SceneManagement(Scenes) {
|
3
|
+
this.Scenes = Scenes;
|
4
|
+
this._currentScene = new Scenes[0]();
|
5
|
+
this._currentScene.manager = this;
|
6
|
+
}
|
7
|
+
SceneManagement.getTag = function (Scene) {
|
8
|
+
return Scene.tag;
|
9
|
+
};
|
10
|
+
Object.defineProperty(SceneManagement.prototype, "currentScene", {
|
11
|
+
get: function () {
|
12
|
+
return this._currentScene;
|
13
|
+
},
|
14
|
+
enumerable: false,
|
15
|
+
configurable: true
|
16
|
+
});
|
17
|
+
SceneManagement.prototype.onChangeScene = function (func) {
|
18
|
+
this.changeSceneListener = func;
|
19
|
+
};
|
20
|
+
SceneManagement.prototype.canNext = function () {
|
21
|
+
var _this = this;
|
22
|
+
var currentIndex = this.Scenes.findIndex(function (Scene) { return _this._currentScene instanceof Scene; });
|
23
|
+
var NextScene = this.Scenes[currentIndex + 1];
|
24
|
+
return !!NextScene;
|
25
|
+
};
|
26
|
+
SceneManagement.prototype.next = function () {
|
27
|
+
var _this = this;
|
28
|
+
var currentIndex = this.Scenes.findIndex(function (Scene) { return _this._currentScene instanceof Scene; });
|
29
|
+
var NextScene = this.Scenes[currentIndex + 1];
|
30
|
+
if (NextScene) {
|
31
|
+
this.startScene(NextScene);
|
32
|
+
}
|
33
|
+
};
|
34
|
+
SceneManagement.prototype.replay = function () {
|
35
|
+
this.gotoScene(this._currentScene.tag);
|
36
|
+
};
|
37
|
+
SceneManagement.prototype.gotoScene = function (tag) {
|
38
|
+
for (var _i = 0, _a = this.Scenes; _i < _a.length; _i++) {
|
39
|
+
var Scene_1 = _a[_i];
|
40
|
+
var _tag = SceneManagement.getTag(Scene_1);
|
41
|
+
if (_tag === tag) {
|
42
|
+
if (this._currentScene) {
|
43
|
+
this._currentScene.destructor();
|
44
|
+
}
|
45
|
+
this.startScene(Scene_1);
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
};
|
50
|
+
SceneManagement.prototype.startScene = function (Scene) {
|
51
|
+
var _a;
|
52
|
+
this._currentScene = new Scene();
|
53
|
+
this._currentScene.manager = this;
|
54
|
+
(_a = this.changeSceneListener) === null || _a === void 0 ? void 0 : _a.call(this, this._currentScene);
|
55
|
+
};
|
56
|
+
return SceneManagement;
|
57
|
+
}());
|
58
|
+
export { SceneManagement };
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/// <reference types="p5" />
|
2
|
+
import { ComponentType } from "react";
|
3
|
+
import { Camera } from "./camera";
|
4
|
+
import { LogicComponent } from "./logic-component";
|
5
|
+
import { SceneManagement } from "./scene-management";
|
6
|
+
import { EntitySult } from "./entities/entity-sult";
|
7
|
+
import { Prefab } from "./prefab";
|
8
|
+
import { Sound } from "./sound";
|
9
|
+
import { Avatar, GetSoundOptions, SoundDecor, SoundManagement, SpriteDecor } from "../export-types";
|
10
|
+
import { SoundType } from "../export-enums";
|
11
|
+
declare type SoundOptionsChangeListener<O extends SoundType> = (options: SoundManagement[O]) => void;
|
12
|
+
declare type LoadAssetsListener = (loadedAssets: boolean) => void;
|
13
|
+
declare type EntityPropsChangeListener<V = any> = (value: V) => void;
|
14
|
+
export declare abstract class Scene<UIP = any> {
|
15
|
+
static soundsDecor: SoundDecor[];
|
16
|
+
static spritesDecor: SpriteDecor[];
|
17
|
+
private ui;
|
18
|
+
private worldManagement;
|
19
|
+
private _loadedAssets;
|
20
|
+
private loadAssetsListener;
|
21
|
+
private readonly entityPropsChangeListeners;
|
22
|
+
private readonly soundBackgroundOptionsChangeListeners;
|
23
|
+
private readonly soundOnceOptionsChangeListeners;
|
24
|
+
private readonly prefabs;
|
25
|
+
readonly sounds: Sound[];
|
26
|
+
readonly sprites: Avatar[];
|
27
|
+
assetsDelay: number;
|
28
|
+
tag: string;
|
29
|
+
manager: SceneManagement;
|
30
|
+
readonly sessionId: string;
|
31
|
+
abstract getComponents(camera: Camera): LogicComponent<EntitySult>[];
|
32
|
+
constructor();
|
33
|
+
get UI(): ComponentType<UIP>;
|
34
|
+
get UIProps(): UIP;
|
35
|
+
get soundBackgroundOptions(): SoundManagement[SoundType.BACKGROUND];
|
36
|
+
get soundOnceOptions(): SoundManagement[SoundType.ONCE];
|
37
|
+
set soundBackgroundOptions(options: Partial<SoundManagement[SoundType.BACKGROUND]>);
|
38
|
+
set soundOnceOptions(options: Partial<SoundManagement[SoundType.ONCE]>);
|
39
|
+
onSoundOnceOptionsChange(func: SoundOptionsChangeListener<SoundType.ONCE>): () => void;
|
40
|
+
onSoundBackgroundOptionsChange(func: SoundOptionsChangeListener<SoundType.BACKGROUND>): () => void;
|
41
|
+
private bootSoundOptions;
|
42
|
+
protected getSoundOptions(): GetSoundOptions;
|
43
|
+
protected onBorn(): void;
|
44
|
+
protected getUIProps(): UIP;
|
45
|
+
get loadedAssets(): boolean;
|
46
|
+
private set loadedAssets(value);
|
47
|
+
emitEntityPropsChange<V = any>(name: string, value: V): void;
|
48
|
+
onEntityPropsChange<V = any>(name: string, func: EntityPropsChangeListener<V>): () => void;
|
49
|
+
onLoadAssetNotify(func: LoadAssetsListener): void;
|
50
|
+
destructor(): void;
|
51
|
+
switchToScene(tag: string): void;
|
52
|
+
private loadSprites;
|
53
|
+
private loadSounds;
|
54
|
+
createSprites(...srcables: (string | {
|
55
|
+
src: string;
|
56
|
+
})[]): Promise<import("p5").Image[]>;
|
57
|
+
createSounds(...srcables: (string | {
|
58
|
+
src: string;
|
59
|
+
volumn?: number;
|
60
|
+
type?: SoundType;
|
61
|
+
})[]): Promise<Sound[]>;
|
62
|
+
mapSprites(...srcs: string[]): Promise<void>;
|
63
|
+
mapSounds(...srcs: string[]): Promise<void>;
|
64
|
+
loadAssets(delay?: number): Promise<void>;
|
65
|
+
onLoadAssets(): Promise<void>;
|
66
|
+
getPrefab<C extends EntitySult>(Class: {
|
67
|
+
new (...args: any[]): Prefab<C>;
|
68
|
+
}): Prefab<C>;
|
69
|
+
bootstrap(camera: Camera): void;
|
70
|
+
protected onDraw(): void;
|
71
|
+
protected onUpdate(): void;
|
72
|
+
action(): void;
|
73
|
+
}
|
74
|
+
export {};
|
75
|
+
//# sourceMappingURL=scene.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../src/classes/scene.ts"],"names":[],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