react-simple-game-engine 0.2.61 → 0.2.62
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.
@@ -3,6 +3,7 @@ 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
|
+
import { P5 } from "../p5";
|
6
7
|
export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
7
8
|
simpleCamera: SimpleCamera;
|
8
9
|
readonly id: string;
|
@@ -12,8 +13,11 @@ export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
|
12
13
|
private _worldManagement;
|
13
14
|
private _children;
|
14
15
|
private _parent?;
|
16
|
+
private _renderer;
|
15
17
|
abstract update(): void;
|
16
18
|
abstract draw(): void;
|
19
|
+
get renderer(): P5;
|
20
|
+
set renderer(_renderer: P5);
|
17
21
|
get children(): EntitySult<any>[];
|
18
22
|
get layerIndex(): number;
|
19
23
|
get name(): string;
|
@@ -21,13 +25,14 @@ export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
|
21
25
|
set name(_name: string);
|
22
26
|
get parent(): EntitySult<any>;
|
23
27
|
get scene(): Scene<any>;
|
28
|
+
set worldManagement(_worldManagement: WorldManagement);
|
24
29
|
get worldManagement(): WorldManagement;
|
25
30
|
addChild(target: EntitySult | LogicComponent<EntitySult>): void;
|
26
31
|
removeChild(entity: EntitySult): void;
|
27
32
|
unChild(entity: EntitySult): void;
|
28
33
|
getProperty<T>(name: string): T;
|
29
34
|
preInitial(worldManagement: WorldManagement): void;
|
30
|
-
active(
|
35
|
+
active(_: WorldManagement): void;
|
31
36
|
onActive(): void;
|
32
37
|
initial(params: P): void;
|
33
38
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"entity-sult.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity-sult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,U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AI,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,QAAQ;IACR,OAAO,CAAC,MAAM,EAAE,CAAC;CAClB"}
|
@@ -5,6 +5,20 @@ var EntitySult = /** @class */ (function () {
|
|
5
5
|
this._name = this.id;
|
6
6
|
this._children = [];
|
7
7
|
}
|
8
|
+
Object.defineProperty(EntitySult.prototype, "renderer", {
|
9
|
+
get: function () {
|
10
|
+
return this._renderer;
|
11
|
+
},
|
12
|
+
set: function (_renderer) {
|
13
|
+
if (this._renderer) {
|
14
|
+
console.warn("Not allow to change renderer of entity");
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
this._renderer = _renderer;
|
18
|
+
},
|
19
|
+
enumerable: false,
|
20
|
+
configurable: true
|
21
|
+
});
|
8
22
|
Object.defineProperty(EntitySult.prototype, "children", {
|
9
23
|
get: function () {
|
10
24
|
return this._children;
|
@@ -63,13 +77,19 @@ var EntitySult = /** @class */ (function () {
|
|
63
77
|
get: function () {
|
64
78
|
return this._worldManagement;
|
65
79
|
},
|
80
|
+
set: function (_worldManagement) {
|
81
|
+
if (!this._worldManagement) {
|
82
|
+
this._worldManagement = _worldManagement;
|
83
|
+
this._renderer = _worldManagement.scene.renderer;
|
84
|
+
this._scene = _worldManagement.scene;
|
85
|
+
this.simpleCamera = _worldManagement.camera;
|
86
|
+
}
|
87
|
+
},
|
66
88
|
enumerable: false,
|
67
89
|
configurable: true
|
68
90
|
});
|
69
91
|
EntitySult.prototype.addChild = function (target) {
|
70
|
-
var entity = target instanceof EntitySult
|
71
|
-
? target
|
72
|
-
: target.output({ worldManagement: this.worldManagement });
|
92
|
+
var entity = target instanceof EntitySult ? target : target.output();
|
73
93
|
entity._parent = this;
|
74
94
|
entity._layerIndex = this._layerIndex;
|
75
95
|
this.children.push(entity);
|
@@ -91,14 +111,10 @@ var EntitySult = /** @class */ (function () {
|
|
91
111
|
EntitySult.prototype.preInitial = function (worldManagement) {
|
92
112
|
this._worldManagement = worldManagement;
|
93
113
|
this._scene = worldManagement.scene;
|
114
|
+
this._renderer = worldManagement.scene.renderer;
|
94
115
|
this.simpleCamera = worldManagement.camera;
|
95
116
|
};
|
96
|
-
EntitySult.prototype.active = function (
|
97
|
-
if (!this._worldManagement) {
|
98
|
-
this._worldManagement = worldManagement;
|
99
|
-
this._scene = worldManagement.scene;
|
100
|
-
this.simpleCamera = worldManagement.camera;
|
101
|
-
}
|
117
|
+
EntitySult.prototype.active = function (_) {
|
102
118
|
// console.log(`Active entity (name : ${this._name})`);
|
103
119
|
this.onActive();
|
104
120
|
};
|
package/lib/classes/scene.d.ts
CHANGED
@@ -9,6 +9,7 @@ import { Sound } from "./sound";
|
|
9
9
|
import { AssetErrorType, AssetsFailBehavior, Avatar, GetSoundOptions, JoystickAction, SoundManagement } from "../export-types";
|
10
10
|
import { SoundType } from "../export-enums";
|
11
11
|
import { SimpleCamera } from "./simple-camera";
|
12
|
+
import { P5 } from "./p5";
|
12
13
|
declare type SoundOptionsChangeListener<O extends SoundType> = (options: SoundManagement[O]) => void;
|
13
14
|
declare type LoadAssetsListener = (loadedAssets: boolean, errors?: {
|
14
15
|
type: AssetErrorType;
|
@@ -21,6 +22,7 @@ export declare abstract class Scene<UIP = any> {
|
|
21
22
|
private ui;
|
22
23
|
private _worldManagement;
|
23
24
|
private _loadedAssets;
|
25
|
+
private _renderer;
|
24
26
|
private _renderAssetsFail;
|
25
27
|
private loadAssetsListener;
|
26
28
|
private nativeEventsUnsubscribes;
|
@@ -40,6 +42,7 @@ export declare abstract class Scene<UIP = any> {
|
|
40
42
|
manager: SceneManagement;
|
41
43
|
abstract getComponents(simpleCamera: SimpleCamera): LogicComponent<EntitySult>[];
|
42
44
|
constructor();
|
45
|
+
get renderer(): P5;
|
43
46
|
get worldManagement(): WorldManagement;
|
44
47
|
get renderAssetsFail(): () => ReactElement<any, string | import("react").JSXElementConstructor<any>> | {
|
45
48
|
type: AssetErrorType;
|
@@ -48,6 +51,7 @@ export declare abstract class Scene<UIP = any> {
|
|
48
51
|
get UI(): ComponentType<UIP> | (() => any);
|
49
52
|
get soundBackgroundOptions(): SoundManagement[SoundType.BACKGROUND];
|
50
53
|
get soundOnceOptions(): SoundManagement[SoundType.ONCE];
|
54
|
+
set renderer(_renderer: P5);
|
51
55
|
set soundBackgroundOptions(options: Partial<SoundManagement[SoundType.BACKGROUND]>);
|
52
56
|
set soundOnceOptions(options: Partial<SoundManagement[SoundType.ONCE]>);
|
53
57
|
private bootSoundOptions;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../src/classes/scene.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AASlC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;A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AAC,GAAG,EAAE,MAAM;YAIX,WAAW;YAcX,UAAU;IAcxB,aAAa,CAAC,GAAG,QAAQ,EAAE,CAAC,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE;IAcjD,YAAY,CAChB,GAAG,QAAQ,EAAE,CAAC,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,EAAE;IAsBxE,UAAU,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAgB5B,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAc3B,UAAU,CACd,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAChC,EAAE,IAAY,EAAE,MAAM,EAAE,GAAE,kBAAuB;IA+C7C,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;IAwCpC,SAAS,CAAC,MAAM;IAChB,SAAS,CAAC,QAAQ;IAElB,MAAM;CAUP"}
|
package/lib/classes/scene.js
CHANGED
@@ -59,6 +59,20 @@ var Scene = /** @class */ (function () {
|
|
59
59
|
this._loadedAssets = false;
|
60
60
|
this.onBorn();
|
61
61
|
}
|
62
|
+
Object.defineProperty(Scene.prototype, "renderer", {
|
63
|
+
get: function () {
|
64
|
+
return this._renderer;
|
65
|
+
},
|
66
|
+
set: function (_renderer) {
|
67
|
+
if (this._renderer) {
|
68
|
+
console.warn("Not allow to change renderer of scene");
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
this._renderer = _renderer;
|
72
|
+
},
|
73
|
+
enumerable: false,
|
74
|
+
configurable: true
|
75
|
+
});
|
62
76
|
Object.defineProperty(Scene.prototype, "worldManagement", {
|
63
77
|
get: function () {
|
64
78
|
return this._worldManagement;
|
@@ -501,6 +515,7 @@ var Scene = /** @class */ (function () {
|
|
501
515
|
};
|
502
516
|
Scene.prototype.bootstrap = function (simpleCamera) {
|
503
517
|
var _this_1 = this;
|
518
|
+
this._renderer = window.Renderer;
|
504
519
|
this.listenNativeEvents();
|
505
520
|
this.bootSoundOptions();
|
506
521
|
this.onProcessStateChangeListener(function (isForeground) {
|