@inglorious/renderer-react-dom 8.0.1 → 9.0.1
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/package.json +4 -4
- package/src/game/game.jsx +72 -72
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/renderer-react-dom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "A renderer for the Inglorious Engine, using React components.",
|
|
5
5
|
"author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"react": "^19.1.1",
|
|
28
28
|
"react-dom": "^19.1.1",
|
|
29
29
|
"react-redux": "^9.2.0",
|
|
30
|
-
"@inglorious/
|
|
31
|
-
"@inglorious/
|
|
30
|
+
"@inglorious/engine": "10.0.1",
|
|
31
|
+
"@inglorious/utils": "3.6.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "^19.1.1",
|
|
35
35
|
"react-dom": "^19.1.1",
|
|
36
36
|
"react-redux": "^9.2.0",
|
|
37
|
-
"@inglorious/engine": "
|
|
37
|
+
"@inglorious/engine": "10.0.1",
|
|
38
38
|
"@inglorious/utils": "3.6.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
package/src/game/game.jsx
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { withAbsolutePosition } from "@inglorious/renderer-react-dom/hocs/with-absolute-position/index.jsx"
|
|
2
|
-
import { useSelector } from "react-redux"
|
|
3
|
-
|
|
4
|
-
import Character from "./character/index.jsx"
|
|
5
|
-
import Cursor from "./cursor/index.jsx"
|
|
6
|
-
import Form from "./form/index.jsx"
|
|
7
|
-
import Fps from "./fps/index.jsx"
|
|
8
|
-
import Platform from "./platform/index.jsx"
|
|
9
|
-
import Scene from "./scene/index.jsx"
|
|
10
|
-
import Sprite from "./sprite/index.jsx"
|
|
11
|
-
import Stats from "./stats/index.jsx"
|
|
12
|
-
|
|
13
|
-
const Components = {
|
|
14
|
-
character: withAbsolutePosition(Character),
|
|
15
|
-
mouse: withAbsolutePosition(Cursor),
|
|
16
|
-
form: withAbsolutePosition(Form),
|
|
17
|
-
fps: withAbsolutePosition(Fps),
|
|
18
|
-
platform: withAbsolutePosition(Platform),
|
|
19
|
-
sprite: withAbsolutePosition(Sprite),
|
|
20
|
-
stats: withAbsolutePosition(Stats),
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const Y = 1
|
|
24
|
-
const Z = 2
|
|
25
|
-
|
|
26
|
-
export default function Game({ engine }) {
|
|
27
|
-
// NOTE: don't use simply engine.entities here: need to subscribe to animate scene!
|
|
28
|
-
const entities = useSelector((state) => state)
|
|
29
|
-
// const entities = engine._store.getState()
|
|
30
|
-
|
|
31
|
-
const types = engine._store.getTypes()
|
|
32
|
-
const { mouse, ...rest } = entities
|
|
33
|
-
const options = { types, entities }
|
|
34
|
-
|
|
35
|
-
const render = createDraw(options)
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Scene entities={entities}>
|
|
39
|
-
{Object.values(rest)
|
|
40
|
-
.filter(({ position }) => position)
|
|
41
|
-
.toSorted(
|
|
42
|
-
(a, b) =>
|
|
43
|
-
a.layer - b.layer ||
|
|
44
|
-
a.position[Y] - b.position[Y] ||
|
|
45
|
-
b.position[Z] - a.position[Z],
|
|
46
|
-
)
|
|
47
|
-
.map(render)}
|
|
48
|
-
{mouse && render(mouse)}
|
|
49
|
-
</Scene>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function createDraw(options) {
|
|
54
|
-
return function Draw(entity) {
|
|
55
|
-
const { types, entities } = options
|
|
56
|
-
const type = types[entity.type]
|
|
57
|
-
|
|
58
|
-
const Component = entity.sprite
|
|
59
|
-
? Components.sprite
|
|
60
|
-
: Components[entity.type]
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<Component
|
|
64
|
-
key={entity.id}
|
|
65
|
-
id={entity.id}
|
|
66
|
-
type={type}
|
|
67
|
-
entity={entity}
|
|
68
|
-
entities={entities}
|
|
69
|
-
/>
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
import { withAbsolutePosition } from "@inglorious/renderer-react-dom/hocs/with-absolute-position/index.jsx"
|
|
2
|
+
import { useSelector } from "react-redux"
|
|
3
|
+
|
|
4
|
+
import Character from "./character/index.jsx"
|
|
5
|
+
import Cursor from "./cursor/index.jsx"
|
|
6
|
+
import Form from "./form/index.jsx"
|
|
7
|
+
import Fps from "./fps/index.jsx"
|
|
8
|
+
import Platform from "./platform/index.jsx"
|
|
9
|
+
import Scene from "./scene/index.jsx"
|
|
10
|
+
import Sprite from "./sprite/index.jsx"
|
|
11
|
+
import Stats from "./stats/index.jsx"
|
|
12
|
+
|
|
13
|
+
const Components = {
|
|
14
|
+
character: withAbsolutePosition(Character),
|
|
15
|
+
mouse: withAbsolutePosition(Cursor),
|
|
16
|
+
form: withAbsolutePosition(Form),
|
|
17
|
+
fps: withAbsolutePosition(Fps),
|
|
18
|
+
platform: withAbsolutePosition(Platform),
|
|
19
|
+
sprite: withAbsolutePosition(Sprite),
|
|
20
|
+
stats: withAbsolutePosition(Stats),
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Y = 1
|
|
24
|
+
const Z = 2
|
|
25
|
+
|
|
26
|
+
export default function Game({ engine }) {
|
|
27
|
+
// NOTE: don't use simply engine.entities here: need to subscribe to animate scene!
|
|
28
|
+
const entities = useSelector((state) => state)
|
|
29
|
+
// const entities = engine._store.getState()
|
|
30
|
+
|
|
31
|
+
const types = engine._store.getTypes()
|
|
32
|
+
const { mouse, ...rest } = entities
|
|
33
|
+
const options = { types, entities }
|
|
34
|
+
|
|
35
|
+
const render = createDraw(options)
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Scene entities={entities}>
|
|
39
|
+
{Object.values(rest)
|
|
40
|
+
.filter(({ position }) => position)
|
|
41
|
+
.toSorted(
|
|
42
|
+
(a, b) =>
|
|
43
|
+
a.layer - b.layer ||
|
|
44
|
+
a.position[Y] - b.position[Y] ||
|
|
45
|
+
b.position[Z] - a.position[Z],
|
|
46
|
+
)
|
|
47
|
+
.map(render)}
|
|
48
|
+
{mouse && render(mouse)}
|
|
49
|
+
</Scene>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function createDraw(options) {
|
|
54
|
+
return function Draw(entity) {
|
|
55
|
+
const { types, entities } = options
|
|
56
|
+
const type = types[entity.type]
|
|
57
|
+
|
|
58
|
+
const Component = entity.sprite
|
|
59
|
+
? Components.sprite
|
|
60
|
+
: Components[entity.type]
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Component
|
|
64
|
+
key={entity.id}
|
|
65
|
+
id={entity.id}
|
|
66
|
+
type={type}
|
|
67
|
+
entity={entity}
|
|
68
|
+
entities={entities}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
}
|