create-mud 2.0.1 → 2.0.2-main-a1101f78
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/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var t=require("create-create-app"),s=require("path");var e={name:"create-mud",version:"2.0.
|
|
2
|
+
"use strict";var t=require("create-create-app"),s=require("path");var e={name:"create-mud",version:"2.0.2-main-a1101f78",description:"Create a new MUD project",license:"MIT",author:"Lattice <mud@lattice.xyz>",bin:"dist/cli.js",files:["dist"],scripts:{build:"pnpm run build:js","build:js":"tsup && ./scripts/copy-templates.sh",clean:"pnpm run clean:js","clean:js":"rimraf dist",dev:"tsup --watch",prepublishOnly:"npm run clean && npm run build",test:"pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs","test:ci":"pnpm run test","test:phaser":"dist/cli.js test-project --template phaser && rimraf test-project","test:react":"dist/cli.js test-project --template react && rimraf test-project","test:react-ecs":"dist/cli.js test-project --template react-ecs && rimraf test-project","test:threejs":"dist/cli.js test-project --template threejs && rimraf test-project","test:vanilla":"dist/cli.js test-project --template vanilla && rimraf test-project"},dependencies:{"create-create-app":"git+https://github.com/holic/create-create-app#74376c59b48a04aabbe94d9cacfe9cb1cecccd63"},devDependencies:{"@types/node":"^18.15.11",tsup:"^6.7.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org"}};var c=(0,s.resolve)(__dirname,"..","dist","templates");(0,t.create)("create-mud",{templateRoot:c,defaultTemplate:"vanilla",defaultPackageManager:"pnpm",promptForDescription:!1,promptForAuthor:!1,promptForEmail:!1,promptForLicense:!1,promptForTemplate:!0,caveat:({answers:r,packageManager:a})=>`Done! Play in the MUD with \`cd ${r.name}\` and \`${a} run dev\``,extra:{"mud-version":{type:"input",describe:"The version of MUD packages to use, defaults to latest",default:e.version}}});
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@latticexyz/store-sync": "{{mud-version}}",
|
|
21
21
|
"@latticexyz/utils": "{{mud-version}}",
|
|
22
22
|
"@latticexyz/world": "{{mud-version}}",
|
|
23
|
-
"@react-three/fiber": "^8.
|
|
23
|
+
"@react-three/fiber": "^8.15.19",
|
|
24
24
|
"contracts": "workspace:*",
|
|
25
25
|
"react": "^18.2.0",
|
|
26
26
|
"react-dom": "^18.2.0",
|
|
@@ -1,27 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable react/no-unknown-property */
|
|
2
|
+
// Workaround react-three-fiber types by disabling unknown properties:
|
|
3
|
+
// https://github.com/pmndrs/react-three-fiber/discussions/2487
|
|
4
|
+
|
|
2
5
|
import { Canvas, Color, ThreeElements, useThree } from "@react-three/fiber";
|
|
3
6
|
import { useComponentValue, useEntityQuery } from "@latticexyz/react";
|
|
4
7
|
import { getComponentValueStrict, Has } from "@latticexyz/recs";
|
|
5
8
|
import { useMUD } from "./MUDContext";
|
|
6
9
|
import { useKeyboardMovement } from "./useKeyboardMovement";
|
|
7
10
|
|
|
8
|
-
const Plane = (
|
|
11
|
+
const Plane = () => {
|
|
9
12
|
return (
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
<>
|
|
14
|
+
<mesh position={[0, -1, 0]}>
|
|
15
|
+
<boxGeometry args={[20, 0.1, 20]} />
|
|
16
|
+
<meshStandardMaterial color="#000" opacity="0.9" transparent />
|
|
17
|
+
</mesh>
|
|
18
|
+
|
|
19
|
+
<mesh position={[0, 3, -10]}>
|
|
20
|
+
<boxGeometry args={[20, 5, 0.1]} />
|
|
21
|
+
<meshStandardMaterial color="#F00" opacity="0.5" transparent />
|
|
22
|
+
</mesh>
|
|
23
|
+
|
|
24
|
+
<mesh position={[10, 3, 0]}>
|
|
25
|
+
<boxGeometry args={[0.1, 5, 20]} />
|
|
26
|
+
<meshStandardMaterial color="#0F0" opacity="0.5" transparent />
|
|
27
|
+
</mesh>
|
|
28
|
+
|
|
29
|
+
<mesh position={[5, 2, 0]}>
|
|
30
|
+
<sphereGeometry args={[2, 10, 10]} />
|
|
31
|
+
<meshStandardMaterial color="#FF0" opacity="0.8" transparent />
|
|
32
|
+
</mesh>
|
|
33
|
+
|
|
34
|
+
<mesh position={[0, 2, 5]}>
|
|
35
|
+
<sphereGeometry args={[2, 10, 10]} />
|
|
36
|
+
<meshStandardMaterial color="#FF0" opacity="0.8" transparent />
|
|
37
|
+
</mesh>
|
|
38
|
+
|
|
39
|
+
<mesh position={[-5, 2, 0]}>
|
|
40
|
+
<sphereGeometry args={[2, 10, 10]} />
|
|
41
|
+
<meshStandardMaterial color="#FF0" opacity="0.8" transparent />
|
|
42
|
+
</mesh>
|
|
43
|
+
|
|
44
|
+
<mesh position={[0, 2, -5]}>
|
|
45
|
+
<sphereGeometry args={[2, 10, 10]} />
|
|
46
|
+
<meshStandardMaterial color="#FF0" opacity="0.8" transparent />
|
|
47
|
+
</mesh>
|
|
48
|
+
|
|
49
|
+
<mesh position={[5, 2, -5]}>
|
|
50
|
+
<sphereGeometry args={[1, 10, 10]} />
|
|
51
|
+
<meshStandardMaterial color="#008" opacity="0.8" transparent />
|
|
52
|
+
</mesh>
|
|
53
|
+
|
|
54
|
+
<mesh position={[5, 2, 5]}>
|
|
55
|
+
<sphereGeometry args={[1, 10, 10]} />
|
|
56
|
+
<meshStandardMaterial color="#008" opacity="0.8" transparent />
|
|
57
|
+
</mesh>
|
|
58
|
+
|
|
59
|
+
<mesh position={[-5, 2, -5]}>
|
|
60
|
+
<sphereGeometry args={[1, 10, 10]} />
|
|
61
|
+
<meshStandardMaterial color="#008" opacity="0.8" transparent />
|
|
62
|
+
</mesh>
|
|
63
|
+
</>
|
|
15
64
|
);
|
|
16
65
|
};
|
|
17
66
|
|
|
18
67
|
const Player = (props: ThreeElements["mesh"] & { color: Color }) => {
|
|
19
68
|
return (
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
69
|
+
<>
|
|
70
|
+
<mesh {...props}>
|
|
71
|
+
<boxGeometry args={[1, 2, 1]} />
|
|
72
|
+
<meshStandardMaterial color={props.color} />
|
|
73
|
+
</mesh>
|
|
74
|
+
<mesh {...props}>
|
|
75
|
+
<boxGeometry args={[1, 2, 1]} />
|
|
76
|
+
<meshStandardMaterial color={props.color} />
|
|
77
|
+
</mesh>
|
|
78
|
+
</>
|
|
25
79
|
);
|
|
26
80
|
};
|
|
27
81
|
|
|
@@ -58,7 +112,7 @@ const Scene = () => {
|
|
|
58
112
|
<ambientLight />
|
|
59
113
|
{/* eslint-disable-next-line react/no-unknown-property */}
|
|
60
114
|
<pointLight position={[10, 10, 10]} />
|
|
61
|
-
<Plane
|
|
115
|
+
<Plane />
|
|
62
116
|
{players.map((p, i) => (
|
|
63
117
|
<Player
|
|
64
118
|
key={i}
|
|
@@ -72,10 +126,88 @@ const Scene = () => {
|
|
|
72
126
|
|
|
73
127
|
const styles = { height: "100vh" };
|
|
74
128
|
|
|
129
|
+
const Directions = () => {
|
|
130
|
+
return (
|
|
131
|
+
<>
|
|
132
|
+
<p>
|
|
133
|
+
You are the rectangular prism, moving around the scene. To move use <b>W</b>, <b>A</b>, <b>S</b>, and <b>D</b>.
|
|
134
|
+
You can also move up (<b>T</b>) and down (<b>G</b>).
|
|
135
|
+
</p>
|
|
136
|
+
</>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const PlayerInfo = () => {
|
|
141
|
+
const {
|
|
142
|
+
components: { Position },
|
|
143
|
+
network: { playerEntity },
|
|
144
|
+
} = useMUD();
|
|
145
|
+
|
|
146
|
+
const playerPosition = useComponentValue(Position, playerEntity);
|
|
147
|
+
|
|
148
|
+
if (!playerPosition) {
|
|
149
|
+
return (
|
|
150
|
+
<div style={{ backgroundColor: "black", color: "white" }}>
|
|
151
|
+
<table>
|
|
152
|
+
<tbody>
|
|
153
|
+
<tr>
|
|
154
|
+
<td>
|
|
155
|
+
<h2>Reading player position</h2>
|
|
156
|
+
</td>
|
|
157
|
+
<td>
|
|
158
|
+
<Directions />
|
|
159
|
+
</td>
|
|
160
|
+
</tr>
|
|
161
|
+
</tbody>
|
|
162
|
+
</table>
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<div style={{ backgroundColor: "black", color: "white" }}>
|
|
169
|
+
<table>
|
|
170
|
+
<tbody>
|
|
171
|
+
<tr>
|
|
172
|
+
<td>
|
|
173
|
+
<table>
|
|
174
|
+
<tbody>
|
|
175
|
+
<tr>
|
|
176
|
+
<th>Coordinate</th>
|
|
177
|
+
<th>Value</th>
|
|
178
|
+
</tr>
|
|
179
|
+
<tr>
|
|
180
|
+
<th>x</th>
|
|
181
|
+
<td align="right">{playerPosition.x}</td>
|
|
182
|
+
</tr>
|
|
183
|
+
<tr>
|
|
184
|
+
<th>y</th>
|
|
185
|
+
<td align="right">{playerPosition.y}</td>
|
|
186
|
+
</tr>
|
|
187
|
+
<tr>
|
|
188
|
+
<th>z</th>
|
|
189
|
+
<td align="right">{playerPosition.z}</td>
|
|
190
|
+
</tr>
|
|
191
|
+
</tbody>
|
|
192
|
+
</table>
|
|
193
|
+
</td>
|
|
194
|
+
<td style={{ padding: 20 }}>
|
|
195
|
+
<Directions />
|
|
196
|
+
</td>
|
|
197
|
+
</tr>
|
|
198
|
+
</tbody>
|
|
199
|
+
</table>
|
|
200
|
+
</div>
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
|
|
75
204
|
export const App = () => {
|
|
76
205
|
return (
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
|
|
206
|
+
<>
|
|
207
|
+
<PlayerInfo />
|
|
208
|
+
<Canvas style={styles}>
|
|
209
|
+
<Scene />
|
|
210
|
+
</Canvas>
|
|
211
|
+
</>
|
|
80
212
|
);
|
|
81
213
|
};
|
|
@@ -8,22 +8,22 @@ export const useKeyboardMovement = () => {
|
|
|
8
8
|
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
const listener = (e: KeyboardEvent) => {
|
|
11
|
-
if (e.key === "
|
|
11
|
+
if (e.key === "w") {
|
|
12
12
|
moveBy(1, 0, 0);
|
|
13
13
|
}
|
|
14
|
-
if (e.key === "
|
|
14
|
+
if (e.key === "s") {
|
|
15
15
|
moveBy(-1, 0, 0);
|
|
16
16
|
}
|
|
17
|
-
if (e.key === "
|
|
17
|
+
if (e.key === "a") {
|
|
18
18
|
moveBy(0, 0, -1);
|
|
19
19
|
}
|
|
20
|
-
if (e.key === "
|
|
20
|
+
if (e.key === "d") {
|
|
21
21
|
moveBy(0, 0, 1);
|
|
22
22
|
}
|
|
23
|
-
if (e.key === "
|
|
23
|
+
if (e.key === "t") {
|
|
24
24
|
moveBy(0, 1, 0);
|
|
25
25
|
}
|
|
26
|
-
if (e.
|
|
26
|
+
if (e.key === "g") {
|
|
27
27
|
moveBy(0, -1, 0);
|
|
28
28
|
}
|
|
29
29
|
};
|