react-simple-game-engine 0.2.72 → 0.2.74
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/scene.d.ts +2 -2
- package/lib/classes/scene.d.ts.map +1 -1
- package/lib/classes/scene.js +3 -0
- package/lib/ui-components/control-container.d.ts +8 -0
- package/lib/ui-components/control-container.d.ts.map +1 -0
- package/lib/ui-components/control-container.js +30 -0
- package/lib/ui-components/control.d.ts +3 -7
- package/lib/ui-components/control.d.ts.map +1 -1
- package/lib/ui-components/control.js +2 -39
- package/lib/ui-components/movement-control.d.ts +14 -0
- package/lib/ui-components/movement-control.d.ts.map +1 -0
- package/lib/ui-components/movement-control.js +53 -0
- package/lib/ui-components/scene-runner.d.ts +2 -2
- package/lib/ui-components/scene-runner.d.ts.map +1 -1
- package/lib/ui-components/scene-runner.js +4 -4
- package/lib/utilities.d.ts +2 -0
- package/lib/utilities.d.ts.map +1 -1
- package/lib/utilities.js +2 -0
- package/package.json +1 -1
package/lib/classes/scene.d.ts
CHANGED
@@ -40,7 +40,6 @@ export declare abstract class Scene<UIP = any> {
|
|
40
40
|
assetsDelay: number;
|
41
41
|
tag: string;
|
42
42
|
manager: SceneManagement;
|
43
|
-
abstract getComponents(simpleCamera: SimpleCamera): LogicComponent<EntitySult>[];
|
44
43
|
constructor();
|
45
44
|
get renderer(): P5;
|
46
45
|
get worldManagement(): WorldManagement;
|
@@ -57,7 +56,8 @@ export declare abstract class Scene<UIP = any> {
|
|
57
56
|
private bootSoundOptions;
|
58
57
|
protected getSoundOptions(): GetSoundOptions;
|
59
58
|
protected onBorn(): void;
|
60
|
-
|
59
|
+
protected getComponents(simpleCamera: SimpleCamera): LogicComponent<EntitySult>[];
|
60
|
+
getUIProps(): Partial<UIP>;
|
61
61
|
getInitialData(): {
|
62
62
|
joystick?: boolean;
|
63
63
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":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AAE,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
@@ -132,6 +132,9 @@ var Scene = /** @class */ (function () {
|
|
132
132
|
return {};
|
133
133
|
};
|
134
134
|
Scene.prototype.onBorn = function () { };
|
135
|
+
Scene.prototype.getComponents = function (simpleCamera) {
|
136
|
+
return [];
|
137
|
+
};
|
135
138
|
Scene.prototype.getUIProps = function () {
|
136
139
|
return {};
|
137
140
|
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { ReactElement } from "react";
|
2
|
+
declare type ControlContainerProps = {
|
3
|
+
full?: boolean;
|
4
|
+
children: ReactElement | ReactElement[];
|
5
|
+
};
|
6
|
+
export declare function ControlContainer({ full, children }: ControlContainerProps): JSX.Element;
|
7
|
+
export {};
|
8
|
+
//# sourceMappingURL=control-container.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"control-container.d.ts","sourceRoot":"","sources":["../../src/ui-components/control-container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAE9C,aAAK,qBAAqB,GAAG;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;CACzC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,qBAAqB,eAsBzE"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
import { useMemo } from "react";
|
14
|
+
export function ControlContainer(_a) {
|
15
|
+
var full = _a.full, children = _a.children;
|
16
|
+
var _children = useMemo(function () {
|
17
|
+
var _children = Array.isArray(children) ? children : [children];
|
18
|
+
return _children
|
19
|
+
.reduce(function (arr, child) {
|
20
|
+
arr.push.apply(arr, (Array.isArray(child) ? child : [child]));
|
21
|
+
return arr;
|
22
|
+
}, [])
|
23
|
+
.filter(Boolean);
|
24
|
+
}, [children]);
|
25
|
+
return (_jsx("div", __assign({ style: {
|
26
|
+
width: "100%",
|
27
|
+
height: full ? "100%" : undefined,
|
28
|
+
position: "relative",
|
29
|
+
} }, { children: _children })));
|
30
|
+
}
|
@@ -1,14 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
import { Scene } from "../classes/scene";
|
3
|
-
import { IJoystickProps } from "./react-joystick-component/Joystick";
|
1
|
+
import { ReactNode } from "react";
|
4
2
|
export declare type ControlProps = {
|
5
|
-
scene: Scene;
|
6
3
|
top?: number;
|
7
4
|
left?: number;
|
8
5
|
right?: number;
|
9
6
|
bottom?: number;
|
10
|
-
|
11
|
-
props?: Omit<IJoystickProps, "start" | "move" | "stop">;
|
7
|
+
children: ReactNode;
|
12
8
|
};
|
13
|
-
export declare function Control({
|
9
|
+
export declare function Control({ top, left, right, bottom, children, }: ControlProps): JSX.Element;
|
14
10
|
//# sourceMappingURL=control.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/ui-components/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/ui-components/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,oBAAY,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,OAAO,CAAC,EACtB,GAAO,EACP,IAAQ,EACR,KAAK,EACL,MAAM,EACN,QAAQ,GACT,EAAE,YAAY,eAMd"}
|
@@ -10,44 +10,7 @@ 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 { useMemo } from "react";
|
14
|
-
import { JoystickActionType } from "../export-enums";
|
15
|
-
import { Watcher } from "../utilities";
|
16
|
-
import { Joystick } from "./react-joystick-component";
|
17
13
|
export function Control(_a) {
|
18
|
-
var
|
19
|
-
|
20
|
-
return scene.getInitialData();
|
21
|
-
}, [scene]).joystick;
|
22
|
-
var el = useMemo(function () {
|
23
|
-
var onAction = function (e) {
|
24
|
-
if (e.type === JoystickActionType.MOVE) {
|
25
|
-
scene.emitJoystickAction({
|
26
|
-
type: e.type,
|
27
|
-
vector: Renderer.createVector(e.x, -e.y).normalize(),
|
28
|
-
weight: e.distance / 100,
|
29
|
-
length: e.distance,
|
30
|
-
direction: e.direction,
|
31
|
-
});
|
32
|
-
}
|
33
|
-
else {
|
34
|
-
scene.emitJoystickAction({
|
35
|
-
type: e.type,
|
36
|
-
});
|
37
|
-
}
|
38
|
-
};
|
39
|
-
return (_jsx("div", __assign({ style: {
|
40
|
-
position: "absolute",
|
41
|
-
left: left,
|
42
|
-
top: top,
|
43
|
-
bottom: bottom,
|
44
|
-
right: right,
|
45
|
-
} }, { children: _jsx(Joystick, __assign({ size: 60, baseColor: "#2D2D2D", stickColor: "rgb(120,121,122)", throttle: 100 }, props, { start: onAction, move: onAction, stop: onAction })) })));
|
46
|
-
}, [props]);
|
47
|
-
return (_jsx(Watcher, __assign({ initialValues: {
|
48
|
-
isShow: defaultShow,
|
49
|
-
}, scene: scene, names: "control-visible" }, { children: function (_a) {
|
50
|
-
var isShow = _a.isShow;
|
51
|
-
return (isShow ? (render ? render(el) : el) : null);
|
52
|
-
} })));
|
14
|
+
var _b = _a.top, top = _b === void 0 ? 0 : _b, _c = _a.left, left = _c === void 0 ? 0 : _c, right = _a.right, bottom = _a.bottom, children = _a.children;
|
15
|
+
return (_jsx("div", __assign({ style: { position: "absolute", top: top, left: left, right: right, bottom: bottom } }, { children: children })));
|
53
16
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
2
|
+
import { Scene } from "../classes/scene";
|
3
|
+
import { IJoystickProps } from "./react-joystick-component/Joystick";
|
4
|
+
export declare type MovementControlProps = {
|
5
|
+
scene: Scene;
|
6
|
+
top?: number;
|
7
|
+
left?: number;
|
8
|
+
right?: number;
|
9
|
+
bottom?: number;
|
10
|
+
render?: (el: ReactElement) => ReactNode;
|
11
|
+
props?: Omit<IJoystickProps, "start" | "move" | "stop">;
|
12
|
+
};
|
13
|
+
export declare function MovementControl({ scene, render, top, left, right, bottom, props, }: MovementControlProps): JSX.Element;
|
14
|
+
//# sourceMappingURL=movement-control.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"movement-control.d.ts","sourceRoot":"","sources":["../../src/ui-components/movement-control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EACL,cAAc,EAEf,MAAM,qCAAqC,CAAC;AAE7C,oBAAY,oBAAoB,GAAG;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,SAAS,CAAC;IACzC,KAAK,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;CACzD,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAS,EACT,KAAK,EACL,MAAW,EACX,KAAK,GACN,EAAE,oBAAoB,eAwDtB"}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
import { useMemo } from "react";
|
14
|
+
import { JoystickActionType } from "../export-enums";
|
15
|
+
import { Watcher } from "../utilities";
|
16
|
+
import { Joystick } from "./react-joystick-component";
|
17
|
+
export function MovementControl(_a) {
|
18
|
+
var scene = _a.scene, render = _a.render, top = _a.top, _b = _a.left, left = _b === void 0 ? 50 : _b, right = _a.right, _c = _a.bottom, bottom = _c === void 0 ? 50 : _c, props = _a.props;
|
19
|
+
var defaultShow = useMemo(function () {
|
20
|
+
return scene.getInitialData();
|
21
|
+
}, [scene]).joystick;
|
22
|
+
var el = useMemo(function () {
|
23
|
+
var onAction = function (e) {
|
24
|
+
if (e.type === JoystickActionType.MOVE) {
|
25
|
+
scene.emitJoystickAction({
|
26
|
+
type: e.type,
|
27
|
+
vector: Renderer.createVector(e.x, -e.y).normalize(),
|
28
|
+
weight: e.distance / 100,
|
29
|
+
length: e.distance,
|
30
|
+
direction: e.direction,
|
31
|
+
});
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
scene.emitJoystickAction({
|
35
|
+
type: e.type,
|
36
|
+
});
|
37
|
+
}
|
38
|
+
};
|
39
|
+
return (_jsx("div", __assign({ style: {
|
40
|
+
position: "absolute",
|
41
|
+
left: left,
|
42
|
+
top: top,
|
43
|
+
bottom: bottom,
|
44
|
+
right: right,
|
45
|
+
} }, { children: _jsx(Joystick, __assign({ size: 60, baseColor: "#2D2D2D", stickColor: "rgb(120,121,122)", throttle: 100 }, props, { start: onAction, move: onAction, stop: onAction })) })));
|
46
|
+
}, [props]);
|
47
|
+
return (_jsx(Watcher, __assign({ initialValues: {
|
48
|
+
isShow: defaultShow,
|
49
|
+
}, scene: scene, names: "control-visible" }, { children: function (_a) {
|
50
|
+
var isShow = _a.isShow;
|
51
|
+
return (isShow ? (render ? render(el) : el) : null);
|
52
|
+
} })));
|
53
|
+
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { ComponentType, ReactNode } from "react";
|
2
2
|
import { Scene } from "../classes/scene";
|
3
3
|
import { LayoutMode } from "../export-enums";
|
4
|
-
import { ControlProps } from "./control";
|
5
4
|
import { AssetsFailBehavior } from "../export-types";
|
5
|
+
import { MovementControlProps } from "./movement-control";
|
6
6
|
export declare type SceneRunnerPublicProps = {
|
7
7
|
width: number;
|
8
8
|
height: number;
|
@@ -11,7 +11,7 @@ export declare type SceneRunnerPublicProps = {
|
|
11
11
|
assetsFailBehavior?: AssetsFailBehavior;
|
12
12
|
layoutMode?: LayoutMode;
|
13
13
|
voidSpace?: ReactNode;
|
14
|
-
joystick?: Omit<
|
14
|
+
joystick?: Omit<MovementControlProps, "scene"> | true;
|
15
15
|
};
|
16
16
|
declare type SceneRunnerProps = SceneRunnerPublicProps & {
|
17
17
|
current: Scene;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scene-runner.d.ts","sourceRoot":"","sources":["../../src/ui-components/scene-runner.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"scene-runner.d.ts","sourceRoot":"","sources":["../../src/ui-components/scene-runner.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAIrD,OAAO,EAAmB,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG3E,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACvD,CAAC;AAEF,aAAK,gBAAgB,GAAG,sBAAsB,GAAG;IAC/C,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,MAAM,EACN,OAAO,EACP,UAAiC,EAEjC,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,YAAY,EAAE,YAAY,EAC1B,QAAQ,GACT,EAAE,gBAAgB,eAsJlB"}
|
@@ -12,11 +12,11 @@ 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 { ScalerContainer } from "./scaler-container";
|
16
|
-
import { Sketch } from "./sketch";
|
17
15
|
import { useWindowSize } from "../utils";
|
18
16
|
import { LayoutMode } from "../export-enums";
|
19
|
-
import {
|
17
|
+
import { ScalerContainer } from "./scaler-container";
|
18
|
+
import { Sketch } from "./sketch";
|
19
|
+
import { MovementControl } from "./movement-control";
|
20
20
|
import { FloatContainer } from "./float-container";
|
21
21
|
export function SceneRunner(_a) {
|
22
22
|
var width = _a.width, height = _a.height, current = _a.current, _b = _a.layoutMode, layoutMode = _b === void 0 ? LayoutMode.LANDSCAPE : _b,
|
@@ -93,7 +93,7 @@ export function SceneRunner(_a) {
|
|
93
93
|
}
|
94
94
|
return rendered;
|
95
95
|
})()
|
96
|
-
: assetsLoader })) : (_jsx(_Fragment, { children: isBootDone ? (_jsxs(_Fragment, { children: [_jsx(current.UI, __assign({ scene: current }, current.getUIProps())), joystick && (_jsx(
|
96
|
+
: assetsLoader })) : (_jsx(_Fragment, { children: isBootDone ? (_jsxs(_Fragment, { children: [_jsx(current.UI, __assign({ scene: current }, current.getUIProps())), joystick && (_jsx(MovementControl, __assign({ scene: current }, (joystick === true ? {} : joystick)))), _jsx("div", { id: "scene-modal-stack", style: {
|
97
97
|
position: "absolute",
|
98
98
|
top: 0,
|
99
99
|
left: 0,
|
package/lib/utilities.d.ts
CHANGED
package/lib/utilities.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC"}
|
package/lib/utilities.js
CHANGED