create-mud 2.0.0-alpha.1.21 → 2.0.0-alpha.1.211
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/README.md +1 -1
- package/dist/cli.js +1 -1
- package/dist/templates/{minimal/packages/client → phaser}/.eslintrc +1 -3
- package/dist/templates/phaser/package.json +28 -0
- package/dist/templates/phaser/packages/art/.gitignore +0 -0
- package/dist/templates/phaser/packages/art/README.md +33 -0
- package/dist/templates/phaser/packages/art/config-sprites.json +21 -0
- package/dist/templates/phaser/packages/art/package.json +27 -0
- package/dist/templates/phaser/packages/art/scripts/cli.mjs +190 -0
- package/dist/templates/phaser/packages/art/scripts/export-tiled-types.ts +292 -0
- package/dist/templates/phaser/packages/art/sprites/golem/attack/0.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/attack/1.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/attack/2.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/attack/3.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/attack/4.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/attack/5.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/death/0.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/death/1.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/death/2.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/idle/0.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/idle/1.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/idle/2.png +0 -0
- package/dist/templates/phaser/packages/art/sprites/golem/idle/3.png +0 -0
- package/dist/templates/phaser/packages/art/tilesets/images/world.png +0 -0
- package/dist/templates/phaser/packages/art/tilesets/world.tsx +19 -0
- package/dist/templates/phaser/packages/client/.env +1 -0
- package/dist/templates/phaser/packages/client/.eslintrc +7 -0
- package/dist/templates/phaser/packages/client/index.html +39 -0
- package/dist/templates/phaser/packages/client/package.json +48 -0
- package/dist/templates/phaser/packages/client/public/assets/atlases/atlas.json +292 -0
- package/dist/templates/phaser/packages/client/public/assets/atlases/atlas.png +0 -0
- package/dist/templates/phaser/packages/client/public/assets/tilesets/world.png +0 -0
- package/dist/templates/phaser/packages/client/src/artTypes/world.ts +9 -0
- package/dist/templates/phaser/packages/client/src/index.tsx +11 -0
- package/dist/templates/phaser/packages/client/src/layers/network/createNetworkLayer.ts +24 -0
- package/dist/templates/phaser/packages/client/src/layers/phaser/configurePhaser.ts +91 -0
- package/dist/templates/phaser/packages/client/src/layers/phaser/constants.ts +22 -0
- package/dist/templates/phaser/packages/client/src/layers/phaser/createPhaserLayer.ts +33 -0
- package/dist/templates/phaser/packages/client/src/layers/phaser/systems/createCamera.ts +13 -0
- package/dist/templates/phaser/packages/client/src/layers/phaser/systems/createMapSystem.ts +32 -0
- package/dist/templates/phaser/packages/client/src/layers/phaser/systems/index.ts +1 -0
- package/dist/templates/phaser/packages/client/src/layers/phaser/systems/registerSystems.ts +8 -0
- package/dist/templates/phaser/packages/client/src/mud/contractComponents.ts +24 -0
- package/dist/templates/phaser/packages/client/src/mud/createClientComponents.ts +10 -0
- package/dist/templates/phaser/packages/client/src/mud/createSystemCalls.ts +21 -0
- package/dist/templates/phaser/packages/client/src/mud/getNetworkConfig.ts +53 -0
- package/dist/templates/phaser/packages/client/src/mud/setup.ts +16 -0
- package/dist/templates/phaser/packages/client/src/mud/setupNetwork.ts +102 -0
- package/dist/templates/phaser/packages/client/src/mud/supportedChains.ts +5 -0
- package/dist/templates/phaser/packages/client/src/mud/world.ts +3 -0
- package/dist/templates/phaser/packages/client/src/store.ts +38 -0
- package/dist/templates/phaser/packages/client/src/ui/App.tsx +23 -0
- package/dist/templates/phaser/packages/client/src/ui/LoadingScreen/BootScreen.tsx +42 -0
- package/dist/templates/phaser/packages/client/src/ui/LoadingScreen/LoadingBar.tsx +21 -0
- package/dist/templates/phaser/packages/client/src/ui/LoadingScreen/LoadingScreen.tsx +52 -0
- package/dist/templates/phaser/packages/client/src/ui/LoadingScreen/index.ts +1 -0
- package/dist/templates/phaser/packages/client/src/ui/PhaserLayer.tsx +20 -0
- package/dist/templates/phaser/packages/client/src/ui/UIRoot.tsx +20 -0
- package/dist/templates/phaser/packages/client/src/ui/Wrapper.tsx +5 -0
- package/dist/templates/phaser/packages/client/src/ui/hooks/useNetworkLayer.tsx +17 -0
- package/dist/templates/phaser/packages/client/src/ui/hooks/usePhaserLayer.tsx +87 -0
- package/dist/templates/phaser/packages/client/src/ui/hooks/usePromiseValue.ts +24 -0
- package/dist/templates/phaser/packages/client/src/ui/theme/ClickWrapper.tsx +18 -0
- package/dist/templates/phaser/packages/client/src/ui/theme/SpriteImage.tsx +52 -0
- package/dist/templates/{minimal → phaser}/packages/client/tsconfig.json +3 -4
- package/dist/templates/phaser/packages/client/vite.config.ts +15 -0
- package/dist/templates/phaser/packages/contracts/.env +8 -0
- package/dist/templates/{minimal → phaser}/packages/contracts/.gitignore +3 -2
- package/dist/templates/{minimal → phaser}/packages/contracts/.solhint.json +2 -1
- package/dist/templates/phaser/packages/contracts/foundry.toml +22 -0
- package/dist/templates/phaser/packages/contracts/mud.config.ts +10 -0
- package/dist/templates/phaser/packages/contracts/package.json +45 -0
- package/dist/templates/phaser/packages/contracts/remappings.txt +3 -0
- package/dist/templates/phaser/packages/contracts/script/PostDeploy.s.sol +17 -0
- package/dist/templates/phaser/packages/contracts/src/codegen/Tables.sol +6 -0
- package/dist/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol +120 -0
- package/dist/templates/phaser/packages/contracts/src/codegen/world/IIncrementSystem.sol +8 -0
- package/dist/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol +16 -0
- package/dist/templates/phaser/packages/contracts/src/systems/IncrementSystem.sol +14 -0
- package/dist/templates/phaser/packages/contracts/test/CounterTest.t.sol +38 -0
- package/dist/templates/phaser/packages/contracts/tsconfig.json +13 -0
- package/dist/templates/phaser/packages/contracts/worlds.json +5 -0
- package/dist/templates/react/.eslintrc +10 -0
- package/dist/templates/react/package.json +13 -3
- package/dist/templates/react/packages/client/.env +1 -0
- package/dist/templates/react/packages/client/.eslintrc +2 -12
- package/dist/templates/react/packages/client/package.json +18 -21
- package/dist/templates/react/packages/client/src/App.tsx +11 -13
- package/dist/templates/react/packages/client/src/MUDContext.tsx +21 -0
- package/dist/templates/react/packages/client/src/index.tsx +12 -31
- package/dist/templates/react/packages/client/src/mud/contractComponents.ts +24 -0
- package/dist/templates/react/packages/client/src/mud/createClientComponents.ts +10 -0
- package/dist/templates/react/packages/client/src/mud/createSystemCalls.ts +21 -0
- package/dist/templates/react/packages/client/src/mud/getNetworkConfig.ts +53 -0
- package/dist/templates/react/packages/client/src/mud/setup.ts +16 -0
- package/dist/templates/react/packages/client/src/mud/setupNetwork.ts +102 -0
- package/dist/templates/react/packages/client/src/mud/supportedChains.ts +5 -0
- package/dist/templates/react/packages/client/src/mud/world.ts +3 -0
- package/dist/templates/react/packages/client/tsconfig.json +0 -3
- package/dist/templates/react/packages/client/vite.config.ts +3 -0
- package/dist/templates/react/packages/contracts/.env +8 -0
- package/dist/templates/react/packages/contracts/.gitignore +3 -2
- package/dist/templates/react/packages/contracts/.solhint.json +2 -1
- package/dist/templates/react/packages/contracts/foundry.toml +13 -2
- package/dist/templates/react/packages/contracts/mud.config.ts +10 -0
- package/dist/templates/react/packages/contracts/package.json +25 -20
- package/dist/templates/react/packages/contracts/remappings.txt +3 -9
- package/dist/templates/react/packages/contracts/script/PostDeploy.s.sol +24 -0
- package/dist/templates/react/packages/contracts/src/codegen/Tables.sol +6 -0
- package/dist/templates/react/packages/contracts/src/codegen/tables/Counter.sol +120 -0
- package/dist/templates/react/packages/contracts/src/codegen/world/IIncrementSystem.sol +8 -0
- package/dist/templates/react/packages/contracts/src/codegen/world/IWorld.sol +16 -0
- package/dist/templates/react/packages/contracts/src/systems/IncrementSystem.sol +7 -15
- package/dist/templates/react/packages/contracts/test/CounterTest.t.sol +38 -0
- package/dist/templates/react/packages/contracts/tsconfig.json +9 -8
- package/dist/templates/react/packages/contracts/worlds.json +5 -0
- package/dist/templates/threejs/.eslintrc +10 -0
- package/dist/templates/threejs/.gitignore +1 -0
- package/dist/templates/threejs/.vscode/extensions.json +3 -0
- package/dist/templates/threejs/.vscode/settings.json +3 -0
- package/dist/templates/threejs/package.json +28 -0
- package/dist/templates/threejs/packages/client/.env +1 -0
- package/dist/templates/threejs/packages/client/.eslintrc +7 -0
- package/dist/templates/threejs/packages/client/.gitignore +3 -0
- package/dist/templates/threejs/packages/client/index.html +12 -0
- package/dist/templates/threejs/packages/client/package.json +41 -0
- package/dist/templates/threejs/packages/client/src/App.tsx +81 -0
- package/dist/templates/threejs/packages/client/src/MUDContext.tsx +21 -0
- package/dist/templates/threejs/packages/client/src/index.tsx +19 -0
- package/dist/templates/threejs/packages/client/src/mud/contractComponents.ts +26 -0
- package/dist/templates/threejs/packages/client/src/mud/createClientComponents.ts +10 -0
- package/dist/templates/threejs/packages/client/src/mud/createSystemCalls.ts +15 -0
- package/dist/templates/threejs/packages/client/src/mud/getNetworkConfig.ts +53 -0
- package/dist/templates/threejs/packages/client/src/mud/setup.ts +16 -0
- package/dist/templates/threejs/packages/client/src/mud/setupNetwork.ts +102 -0
- package/dist/templates/threejs/packages/client/src/mud/supportedChains.ts +5 -0
- package/dist/templates/threejs/packages/client/src/mud/world.ts +3 -0
- package/dist/templates/threejs/packages/client/src/useKeyboardMovement.ts +60 -0
- package/dist/templates/threejs/packages/client/tsconfig.json +19 -0
- package/dist/templates/threejs/packages/client/vite.config.ts +15 -0
- package/dist/templates/threejs/packages/contracts/.env +8 -0
- package/dist/templates/threejs/packages/contracts/.gitignore +11 -0
- package/dist/templates/threejs/packages/contracts/.prettierrc +8 -0
- package/dist/templates/threejs/packages/contracts/.solhint.json +12 -0
- package/dist/templates/threejs/packages/contracts/foundry.toml +22 -0
- package/dist/templates/threejs/packages/contracts/mud.config.ts +13 -0
- package/dist/templates/threejs/packages/contracts/package.json +45 -0
- package/dist/templates/threejs/packages/contracts/remappings.txt +3 -0
- package/dist/templates/threejs/packages/contracts/src/codegen/Tables.sol +6 -0
- package/dist/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +263 -0
- package/dist/templates/threejs/packages/contracts/src/codegen/world/IMoveSystem.sol +8 -0
- package/dist/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol +16 -0
- package/dist/templates/threejs/packages/contracts/src/systems/MoveSystem.sol +25 -0
- package/dist/templates/threejs/packages/contracts/tsconfig.json +13 -0
- package/dist/templates/threejs/packages/contracts/worlds.json +5 -0
- package/dist/templates/threejs/pnpm-workspace.yaml +2 -0
- package/dist/templates/vanilla/.eslintrc +10 -0
- package/dist/templates/vanilla/.gitignore +1 -0
- package/dist/templates/vanilla/.vscode/extensions.json +3 -0
- package/dist/templates/vanilla/.vscode/settings.json +3 -0
- package/dist/templates/vanilla/package.json +28 -0
- package/dist/templates/vanilla/packages/client/.env +1 -0
- package/dist/templates/vanilla/packages/client/.gitignore +3 -0
- package/dist/templates/vanilla/packages/client/package.json +32 -0
- package/dist/templates/vanilla/packages/client/src/index.ts +22 -0
- package/dist/templates/vanilla/packages/client/src/mud/contractComponents.ts +24 -0
- package/dist/templates/vanilla/packages/client/src/mud/createClientComponents.ts +10 -0
- package/dist/templates/vanilla/packages/client/src/mud/createSystemCalls.ts +21 -0
- package/dist/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts +53 -0
- package/dist/templates/vanilla/packages/client/src/mud/setup.ts +16 -0
- package/dist/templates/vanilla/packages/client/src/mud/setupNetwork.ts +102 -0
- package/dist/templates/vanilla/packages/client/src/mud/supportedChains.ts +5 -0
- package/dist/templates/vanilla/packages/client/src/mud/world.ts +3 -0
- package/dist/templates/vanilla/packages/client/tsconfig.json +18 -0
- package/dist/templates/{minimal → vanilla}/packages/client/vite.config.ts +3 -0
- package/dist/templates/vanilla/packages/contracts/.env +8 -0
- package/dist/templates/vanilla/packages/contracts/.gitignore +11 -0
- package/dist/templates/vanilla/packages/contracts/.prettierrc +8 -0
- package/dist/templates/vanilla/packages/contracts/.solhint.json +12 -0
- package/dist/templates/vanilla/packages/contracts/foundry.toml +22 -0
- package/dist/templates/vanilla/packages/contracts/mud.config.ts +10 -0
- package/dist/templates/vanilla/packages/contracts/package.json +45 -0
- package/dist/templates/vanilla/packages/contracts/remappings.txt +3 -0
- package/dist/templates/vanilla/packages/contracts/script/PostDeploy.s.sol +24 -0
- package/dist/templates/vanilla/packages/contracts/src/codegen/Tables.sol +6 -0
- package/dist/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol +120 -0
- package/dist/templates/vanilla/packages/contracts/src/codegen/world/IIncrementSystem.sol +8 -0
- package/dist/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol +16 -0
- package/dist/templates/vanilla/packages/contracts/src/systems/IncrementSystem.sol +14 -0
- package/dist/templates/vanilla/packages/contracts/test/CounterTest.t.sol +38 -0
- package/dist/templates/vanilla/packages/contracts/tsconfig.json +13 -0
- package/dist/templates/vanilla/packages/contracts/worlds.json +5 -0
- package/dist/templates/vanilla/pnpm-workspace.yaml +2 -0
- package/package.json +14 -11
- package/dist/templates/minimal/package.json +0 -18
- package/dist/templates/minimal/packages/client/package.json +0 -37
- package/dist/templates/minimal/packages/client/src/config.ts +0 -22
- package/dist/templates/minimal/packages/client/src/index.ts +0 -37
- package/dist/templates/minimal/packages/contracts/chainSpec.json +0 -5
- package/dist/templates/minimal/packages/contracts/deploy.json +0 -4
- package/dist/templates/minimal/packages/contracts/exports.sh +0 -22
- package/dist/templates/minimal/packages/contracts/foundry.toml +0 -11
- package/dist/templates/minimal/packages/contracts/package.json +0 -40
- package/dist/templates/minimal/packages/contracts/remappings.txt +0 -9
- package/dist/templates/minimal/packages/contracts/src/components/CounterComponent.sol +0 -9
- package/dist/templates/minimal/packages/contracts/src/libraries/LibMath.sol +0 -10
- package/dist/templates/minimal/packages/contracts/src/systems/IncrementSystem.sol +0 -22
- package/dist/templates/minimal/packages/contracts/src/systems/README.md +0 -7
- package/dist/templates/minimal/packages/contracts/src/test/Deploy.sol +0 -19
- package/dist/templates/minimal/packages/contracts/src/test/Deploy.t.sol +0 -14
- package/dist/templates/minimal/packages/contracts/src/test/LibDeploy.sol +0 -22
- package/dist/templates/minimal/packages/contracts/tsconfig.json +0 -12
- package/dist/templates/react/packages/client/src/config.ts +0 -22
- package/dist/templates/react/packages/contracts/chainSpec.json +0 -5
- package/dist/templates/react/packages/contracts/deploy.json +0 -4
- package/dist/templates/react/packages/contracts/exports.sh +0 -22
- package/dist/templates/react/packages/contracts/src/components/CounterComponent.sol +0 -9
- package/dist/templates/react/packages/contracts/src/libraries/LibMath.sol +0 -10
- package/dist/templates/react/packages/contracts/src/systems/README.md +0 -7
- package/dist/templates/react/packages/contracts/src/test/Deploy.sol +0 -19
- package/dist/templates/react/packages/contracts/src/test/Deploy.t.sol +0 -14
- package/dist/templates/react/packages/contracts/src/test/LibDeploy.sol +0 -22
- /package/dist/templates/{minimal → phaser}/.gitignore +0 -0
- /package/dist/templates/{minimal → phaser}/.vscode/extensions.json +0 -0
- /package/dist/templates/{minimal → phaser}/.vscode/settings.json +0 -0
- /package/dist/templates/{minimal → phaser}/packages/client/.gitignore +0 -0
- /package/dist/templates/{minimal → phaser}/packages/contracts/.prettierrc +0 -0
- /package/dist/templates/{minimal → phaser}/pnpm-workspace.yaml +0 -0
- /package/dist/templates/{minimal → vanilla}/packages/client/index.html +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_CHAIN_ID=31337
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>a minimal MUD client</title>
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
body,
|
|
10
|
+
p,
|
|
11
|
+
h1,
|
|
12
|
+
h2,
|
|
13
|
+
h3,
|
|
14
|
+
h4,
|
|
15
|
+
h5,
|
|
16
|
+
h6,
|
|
17
|
+
ul,
|
|
18
|
+
ol,
|
|
19
|
+
li,
|
|
20
|
+
dl,
|
|
21
|
+
dt,
|
|
22
|
+
dd,
|
|
23
|
+
form,
|
|
24
|
+
input,
|
|
25
|
+
textarea,
|
|
26
|
+
button,
|
|
27
|
+
img {
|
|
28
|
+
all: initial;
|
|
29
|
+
margin: 0;
|
|
30
|
+
padding: 0;
|
|
31
|
+
border: none;
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
34
|
+
</head>
|
|
35
|
+
<body>
|
|
36
|
+
<div id="react-root"></div>
|
|
37
|
+
<script type="module" src="/src/index.tsx"></script>
|
|
38
|
+
</body>
|
|
39
|
+
</html>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "client",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"dev": "wait-port localhost:8545 && vite",
|
|
10
|
+
"initialize": "pnpm build",
|
|
11
|
+
"preview": "vite preview",
|
|
12
|
+
"test": "tsc --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@ethersproject/providers": "^5.7.2",
|
|
16
|
+
"@latticexyz/common": "{{mud-version}}",
|
|
17
|
+
"@latticexyz/dev-tools": "{{mud-version}}",
|
|
18
|
+
"@latticexyz/network": "{{mud-version}}",
|
|
19
|
+
"@latticexyz/phaserx": "{{mud-version}}",
|
|
20
|
+
"@latticexyz/react": "{{mud-version}}",
|
|
21
|
+
"@latticexyz/recs": "{{mud-version}}",
|
|
22
|
+
"@latticexyz/schema-type": "{{mud-version}}",
|
|
23
|
+
"@latticexyz/std-client": "{{mud-version}}",
|
|
24
|
+
"@latticexyz/utils": "{{mud-version}}",
|
|
25
|
+
"@latticexyz/world": "{{mud-version}}",
|
|
26
|
+
"@wagmi/chains": "^0.2.14",
|
|
27
|
+
"contracts": "workspace:*",
|
|
28
|
+
"ethers": "^5.7.2",
|
|
29
|
+
"lodash": "^4.17.21",
|
|
30
|
+
"react": "^18.2.0",
|
|
31
|
+
"react-dom": "^18.2.0",
|
|
32
|
+
"simplex-noise": "^4.0.1",
|
|
33
|
+
"styled-components": "^5.3.10",
|
|
34
|
+
"use-resize-observer": "^9.1.0",
|
|
35
|
+
"zustand": "^4.3.8"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/lodash": "^4.14.194",
|
|
39
|
+
"@types/react": "^18.2.6",
|
|
40
|
+
"@types/react-dom": "^18.2.4",
|
|
41
|
+
"@types/styled-components": "^5.1.26",
|
|
42
|
+
"@vitejs/plugin-react": "^3.1.0",
|
|
43
|
+
"eslint-plugin-react": "7.31.11",
|
|
44
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
45
|
+
"vite": "^4.2.1",
|
|
46
|
+
"wait-port": "^1.0.4"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"app": "",
|
|
4
|
+
"version": "1.0.0"
|
|
5
|
+
},
|
|
6
|
+
"textures": [
|
|
7
|
+
{
|
|
8
|
+
"image": "atlas.png?timestamp=1684344504521",
|
|
9
|
+
"format": "RGBA8888",
|
|
10
|
+
"size": {
|
|
11
|
+
"w": 2048,
|
|
12
|
+
"h": 2048
|
|
13
|
+
},
|
|
14
|
+
"scale": 1,
|
|
15
|
+
"frames": [
|
|
16
|
+
{
|
|
17
|
+
"filename": "sprites/golem/attack/0.png",
|
|
18
|
+
"rotated": false,
|
|
19
|
+
"trimmed": false,
|
|
20
|
+
"sourceSize": {
|
|
21
|
+
"w": 32,
|
|
22
|
+
"h": 32
|
|
23
|
+
},
|
|
24
|
+
"spriteSourceSize": {
|
|
25
|
+
"x": 0,
|
|
26
|
+
"y": 0,
|
|
27
|
+
"w": 32,
|
|
28
|
+
"h": 32
|
|
29
|
+
},
|
|
30
|
+
"frame": {
|
|
31
|
+
"x": 0,
|
|
32
|
+
"y": 0,
|
|
33
|
+
"w": 32,
|
|
34
|
+
"h": 32
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"filename": "sprites/golem/attack/1.png",
|
|
39
|
+
"rotated": false,
|
|
40
|
+
"trimmed": false,
|
|
41
|
+
"sourceSize": {
|
|
42
|
+
"w": 32,
|
|
43
|
+
"h": 32
|
|
44
|
+
},
|
|
45
|
+
"spriteSourceSize": {
|
|
46
|
+
"x": 0,
|
|
47
|
+
"y": 0,
|
|
48
|
+
"w": 32,
|
|
49
|
+
"h": 32
|
|
50
|
+
},
|
|
51
|
+
"frame": {
|
|
52
|
+
"x": 32,
|
|
53
|
+
"y": 0,
|
|
54
|
+
"w": 32,
|
|
55
|
+
"h": 32
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"filename": "sprites/golem/attack/2.png",
|
|
60
|
+
"rotated": false,
|
|
61
|
+
"trimmed": false,
|
|
62
|
+
"sourceSize": {
|
|
63
|
+
"w": 32,
|
|
64
|
+
"h": 32
|
|
65
|
+
},
|
|
66
|
+
"spriteSourceSize": {
|
|
67
|
+
"x": 0,
|
|
68
|
+
"y": 0,
|
|
69
|
+
"w": 32,
|
|
70
|
+
"h": 32
|
|
71
|
+
},
|
|
72
|
+
"frame": {
|
|
73
|
+
"x": 0,
|
|
74
|
+
"y": 32,
|
|
75
|
+
"w": 32,
|
|
76
|
+
"h": 32
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"filename": "sprites/golem/attack/3.png",
|
|
81
|
+
"rotated": false,
|
|
82
|
+
"trimmed": false,
|
|
83
|
+
"sourceSize": {
|
|
84
|
+
"w": 32,
|
|
85
|
+
"h": 32
|
|
86
|
+
},
|
|
87
|
+
"spriteSourceSize": {
|
|
88
|
+
"x": 0,
|
|
89
|
+
"y": 0,
|
|
90
|
+
"w": 32,
|
|
91
|
+
"h": 32
|
|
92
|
+
},
|
|
93
|
+
"frame": {
|
|
94
|
+
"x": 32,
|
|
95
|
+
"y": 32,
|
|
96
|
+
"w": 32,
|
|
97
|
+
"h": 32
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"filename": "sprites/golem/attack/4.png",
|
|
102
|
+
"rotated": false,
|
|
103
|
+
"trimmed": false,
|
|
104
|
+
"sourceSize": {
|
|
105
|
+
"w": 32,
|
|
106
|
+
"h": 32
|
|
107
|
+
},
|
|
108
|
+
"spriteSourceSize": {
|
|
109
|
+
"x": 0,
|
|
110
|
+
"y": 0,
|
|
111
|
+
"w": 32,
|
|
112
|
+
"h": 32
|
|
113
|
+
},
|
|
114
|
+
"frame": {
|
|
115
|
+
"x": 64,
|
|
116
|
+
"y": 0,
|
|
117
|
+
"w": 32,
|
|
118
|
+
"h": 32
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"filename": "sprites/golem/attack/5.png",
|
|
123
|
+
"rotated": false,
|
|
124
|
+
"trimmed": false,
|
|
125
|
+
"sourceSize": {
|
|
126
|
+
"w": 32,
|
|
127
|
+
"h": 32
|
|
128
|
+
},
|
|
129
|
+
"spriteSourceSize": {
|
|
130
|
+
"x": 0,
|
|
131
|
+
"y": 0,
|
|
132
|
+
"w": 32,
|
|
133
|
+
"h": 32
|
|
134
|
+
},
|
|
135
|
+
"frame": {
|
|
136
|
+
"x": 64,
|
|
137
|
+
"y": 32,
|
|
138
|
+
"w": 32,
|
|
139
|
+
"h": 32
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"filename": "sprites/golem/death/0.png",
|
|
144
|
+
"rotated": false,
|
|
145
|
+
"trimmed": false,
|
|
146
|
+
"sourceSize": {
|
|
147
|
+
"w": 32,
|
|
148
|
+
"h": 32
|
|
149
|
+
},
|
|
150
|
+
"spriteSourceSize": {
|
|
151
|
+
"x": 0,
|
|
152
|
+
"y": 0,
|
|
153
|
+
"w": 32,
|
|
154
|
+
"h": 32
|
|
155
|
+
},
|
|
156
|
+
"frame": {
|
|
157
|
+
"x": 0,
|
|
158
|
+
"y": 64,
|
|
159
|
+
"w": 32,
|
|
160
|
+
"h": 32
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"filename": "sprites/golem/death/1.png",
|
|
165
|
+
"rotated": false,
|
|
166
|
+
"trimmed": false,
|
|
167
|
+
"sourceSize": {
|
|
168
|
+
"w": 32,
|
|
169
|
+
"h": 32
|
|
170
|
+
},
|
|
171
|
+
"spriteSourceSize": {
|
|
172
|
+
"x": 0,
|
|
173
|
+
"y": 0,
|
|
174
|
+
"w": 32,
|
|
175
|
+
"h": 32
|
|
176
|
+
},
|
|
177
|
+
"frame": {
|
|
178
|
+
"x": 32,
|
|
179
|
+
"y": 64,
|
|
180
|
+
"w": 32,
|
|
181
|
+
"h": 32
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"filename": "sprites/golem/death/2.png",
|
|
186
|
+
"rotated": false,
|
|
187
|
+
"trimmed": false,
|
|
188
|
+
"sourceSize": {
|
|
189
|
+
"w": 32,
|
|
190
|
+
"h": 32
|
|
191
|
+
},
|
|
192
|
+
"spriteSourceSize": {
|
|
193
|
+
"x": 0,
|
|
194
|
+
"y": 0,
|
|
195
|
+
"w": 32,
|
|
196
|
+
"h": 32
|
|
197
|
+
},
|
|
198
|
+
"frame": {
|
|
199
|
+
"x": 64,
|
|
200
|
+
"y": 64,
|
|
201
|
+
"w": 32,
|
|
202
|
+
"h": 32
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"filename": "sprites/golem/idle/0.png",
|
|
207
|
+
"rotated": false,
|
|
208
|
+
"trimmed": false,
|
|
209
|
+
"sourceSize": {
|
|
210
|
+
"w": 32,
|
|
211
|
+
"h": 32
|
|
212
|
+
},
|
|
213
|
+
"spriteSourceSize": {
|
|
214
|
+
"x": 0,
|
|
215
|
+
"y": 0,
|
|
216
|
+
"w": 32,
|
|
217
|
+
"h": 32
|
|
218
|
+
},
|
|
219
|
+
"frame": {
|
|
220
|
+
"x": 96,
|
|
221
|
+
"y": 0,
|
|
222
|
+
"w": 32,
|
|
223
|
+
"h": 32
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"filename": "sprites/golem/idle/1.png",
|
|
228
|
+
"rotated": false,
|
|
229
|
+
"trimmed": false,
|
|
230
|
+
"sourceSize": {
|
|
231
|
+
"w": 32,
|
|
232
|
+
"h": 32
|
|
233
|
+
},
|
|
234
|
+
"spriteSourceSize": {
|
|
235
|
+
"x": 0,
|
|
236
|
+
"y": 0,
|
|
237
|
+
"w": 32,
|
|
238
|
+
"h": 32
|
|
239
|
+
},
|
|
240
|
+
"frame": {
|
|
241
|
+
"x": 96,
|
|
242
|
+
"y": 32,
|
|
243
|
+
"w": 32,
|
|
244
|
+
"h": 32
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"filename": "sprites/golem/idle/2.png",
|
|
249
|
+
"rotated": false,
|
|
250
|
+
"trimmed": false,
|
|
251
|
+
"sourceSize": {
|
|
252
|
+
"w": 32,
|
|
253
|
+
"h": 32
|
|
254
|
+
},
|
|
255
|
+
"spriteSourceSize": {
|
|
256
|
+
"x": 0,
|
|
257
|
+
"y": 0,
|
|
258
|
+
"w": 32,
|
|
259
|
+
"h": 32
|
|
260
|
+
},
|
|
261
|
+
"frame": {
|
|
262
|
+
"x": 96,
|
|
263
|
+
"y": 64,
|
|
264
|
+
"w": 32,
|
|
265
|
+
"h": 32
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"filename": "sprites/golem/idle/3.png",
|
|
270
|
+
"rotated": false,
|
|
271
|
+
"trimmed": false,
|
|
272
|
+
"sourceSize": {
|
|
273
|
+
"w": 32,
|
|
274
|
+
"h": 32
|
|
275
|
+
},
|
|
276
|
+
"spriteSourceSize": {
|
|
277
|
+
"x": 0,
|
|
278
|
+
"y": 0,
|
|
279
|
+
"w": 32,
|
|
280
|
+
"h": 32
|
|
281
|
+
},
|
|
282
|
+
"frame": {
|
|
283
|
+
"x": 0,
|
|
284
|
+
"y": 0,
|
|
285
|
+
"w": 32,
|
|
286
|
+
"h": 32
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
]
|
|
292
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom/client";
|
|
3
|
+
import { App } from "./ui/App";
|
|
4
|
+
import { mount as mountDevTools } from "@latticexyz/dev-tools";
|
|
5
|
+
|
|
6
|
+
const rootElement = document.getElementById("react-root");
|
|
7
|
+
if (!rootElement) throw new Error("React root not found");
|
|
8
|
+
const root = ReactDOM.createRoot(rootElement);
|
|
9
|
+
|
|
10
|
+
root.render(<App />);
|
|
11
|
+
mountDevTools();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { world } from "../../mud/world";
|
|
2
|
+
import { setup } from "../../mud/setup";
|
|
3
|
+
|
|
4
|
+
export type NetworkLayer = Awaited<ReturnType<typeof createNetworkLayer>>;
|
|
5
|
+
|
|
6
|
+
export const createNetworkLayer = async () => {
|
|
7
|
+
const {
|
|
8
|
+
components,
|
|
9
|
+
network: { singletonEntity },
|
|
10
|
+
systemCalls,
|
|
11
|
+
} = await setup();
|
|
12
|
+
|
|
13
|
+
// Give components a Human-readable ID
|
|
14
|
+
Object.entries(components).forEach(([name, component]) => {
|
|
15
|
+
component.id = name;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
world,
|
|
20
|
+
singletonEntity,
|
|
21
|
+
systemCalls,
|
|
22
|
+
components,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineSceneConfig,
|
|
3
|
+
AssetType,
|
|
4
|
+
defineScaleConfig,
|
|
5
|
+
defineMapConfig,
|
|
6
|
+
defineCameraConfig,
|
|
7
|
+
} from "@latticexyz/phaserx";
|
|
8
|
+
import worldTileset from "../../../public/assets/tilesets/world.png";
|
|
9
|
+
import { TileAnimations, Tileset } from "../../artTypes/world";
|
|
10
|
+
import { Sprites, Assets, Maps, Scenes, TILE_HEIGHT, TILE_WIDTH, Animations } from "./constants";
|
|
11
|
+
|
|
12
|
+
const ANIMATION_INTERVAL = 200;
|
|
13
|
+
|
|
14
|
+
const mainMap = defineMapConfig({
|
|
15
|
+
chunkSize: TILE_WIDTH * 64, // tile size * tile amount
|
|
16
|
+
tileWidth: TILE_WIDTH,
|
|
17
|
+
tileHeight: TILE_HEIGHT,
|
|
18
|
+
backgroundTile: [Tileset.Grass],
|
|
19
|
+
animationInterval: ANIMATION_INTERVAL,
|
|
20
|
+
tileAnimations: TileAnimations,
|
|
21
|
+
layers: {
|
|
22
|
+
layers: {
|
|
23
|
+
Background: { tilesets: ["Default"] },
|
|
24
|
+
Foreground: { tilesets: ["Default"] },
|
|
25
|
+
},
|
|
26
|
+
defaultLayer: "Background",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const phaserConfig = {
|
|
31
|
+
sceneConfig: {
|
|
32
|
+
[Scenes.Main]: defineSceneConfig({
|
|
33
|
+
assets: {
|
|
34
|
+
[Assets.Tileset]: {
|
|
35
|
+
type: AssetType.Image,
|
|
36
|
+
key: Assets.Tileset,
|
|
37
|
+
path: worldTileset,
|
|
38
|
+
},
|
|
39
|
+
[Assets.MainAtlas]: {
|
|
40
|
+
type: AssetType.MultiAtlas,
|
|
41
|
+
key: Assets.MainAtlas,
|
|
42
|
+
// Add a timestamp to the end of the path to prevent caching
|
|
43
|
+
path: `/assets/atlases/atlas.json?timestamp=${Date.now()}`,
|
|
44
|
+
options: {
|
|
45
|
+
imagePath: "/assets/atlases/",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
maps: {
|
|
50
|
+
[Maps.Main]: mainMap,
|
|
51
|
+
},
|
|
52
|
+
sprites: {
|
|
53
|
+
[Sprites.Soldier]: {
|
|
54
|
+
assetKey: Assets.MainAtlas,
|
|
55
|
+
frame: "sprites/soldier/idle/0.png",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
animations: [
|
|
59
|
+
{
|
|
60
|
+
key: Animations.SwordsmanIdle,
|
|
61
|
+
assetKey: Assets.MainAtlas,
|
|
62
|
+
startFrame: 0,
|
|
63
|
+
endFrame: 3,
|
|
64
|
+
frameRate: 6,
|
|
65
|
+
repeat: -1,
|
|
66
|
+
prefix: "sprites/soldier/idle/",
|
|
67
|
+
suffix: ".png",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
tilesets: {
|
|
71
|
+
Default: {
|
|
72
|
+
assetKey: Assets.Tileset,
|
|
73
|
+
tileWidth: TILE_WIDTH,
|
|
74
|
+
tileHeight: TILE_HEIGHT,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
scale: defineScaleConfig({
|
|
80
|
+
parent: "phaser-game",
|
|
81
|
+
zoom: 1,
|
|
82
|
+
mode: Phaser.Scale.NONE,
|
|
83
|
+
}),
|
|
84
|
+
cameraConfig: defineCameraConfig({
|
|
85
|
+
pinchSpeed: 1,
|
|
86
|
+
wheelSpeed: 1,
|
|
87
|
+
maxZoom: 3,
|
|
88
|
+
minZoom: 1,
|
|
89
|
+
}),
|
|
90
|
+
cullingChunkSize: TILE_HEIGHT * 16,
|
|
91
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export enum Scenes {
|
|
2
|
+
Main = "Main",
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export enum Maps {
|
|
6
|
+
Main = "Main",
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum Animations {
|
|
10
|
+
SwordsmanIdle = "SwordsmanIdle",
|
|
11
|
+
}
|
|
12
|
+
export enum Sprites {
|
|
13
|
+
Soldier,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export enum Assets {
|
|
17
|
+
MainAtlas = "MainAtlas",
|
|
18
|
+
Tileset = "Tileset",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const TILE_HEIGHT = 32;
|
|
22
|
+
export const TILE_WIDTH = 32;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createPhaserEngine } from "@latticexyz/phaserx";
|
|
2
|
+
import { namespaceWorld } from "@latticexyz/recs";
|
|
3
|
+
import { NetworkLayer } from "../network/createNetworkLayer";
|
|
4
|
+
import { registerSystems } from "./systems";
|
|
5
|
+
|
|
6
|
+
export type PhaserLayer = Awaited<ReturnType<typeof createPhaserLayer>>;
|
|
7
|
+
type PhaserEngineConfig = Parameters<typeof createPhaserEngine>[0];
|
|
8
|
+
|
|
9
|
+
export const createPhaserLayer = async (networkLayer: NetworkLayer, phaserConfig: PhaserEngineConfig) => {
|
|
10
|
+
const world = namespaceWorld(networkLayer.world, "phaser");
|
|
11
|
+
|
|
12
|
+
const { game, scenes, dispose: disposePhaser } = await createPhaserEngine(phaserConfig);
|
|
13
|
+
world.registerDisposer(disposePhaser);
|
|
14
|
+
|
|
15
|
+
const { camera } = scenes.Main;
|
|
16
|
+
|
|
17
|
+
camera.phaserCamera.setBounds(-1000, -1000, 2000, 2000);
|
|
18
|
+
camera.phaserCamera.centerOn(0, 0);
|
|
19
|
+
|
|
20
|
+
const components = {};
|
|
21
|
+
|
|
22
|
+
const layer = {
|
|
23
|
+
networkLayer,
|
|
24
|
+
world,
|
|
25
|
+
game,
|
|
26
|
+
scenes,
|
|
27
|
+
components,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
registerSystems(layer);
|
|
31
|
+
|
|
32
|
+
return layer;
|
|
33
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Tileset } from "../../../artTypes/world";
|
|
2
|
+
import { PhaserLayer } from "../createPhaserLayer";
|
|
3
|
+
import { createNoise2D } from "simplex-noise";
|
|
4
|
+
|
|
5
|
+
export function createMapSystem(layer: PhaserLayer) {
|
|
6
|
+
const {
|
|
7
|
+
scenes: {
|
|
8
|
+
Main: {
|
|
9
|
+
maps: {
|
|
10
|
+
Main: { putTileAt },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
} = layer;
|
|
15
|
+
|
|
16
|
+
const noise = createNoise2D();
|
|
17
|
+
|
|
18
|
+
for (let x = -500; x < 500; x++) {
|
|
19
|
+
for (let y = -500; y < 500; y++) {
|
|
20
|
+
const coord = { x, y };
|
|
21
|
+
const seed = noise(x, y);
|
|
22
|
+
|
|
23
|
+
putTileAt(coord, Tileset.Grass, "Background");
|
|
24
|
+
|
|
25
|
+
if (seed >= 0.45) {
|
|
26
|
+
putTileAt(coord, Tileset.Mountain, "Foreground");
|
|
27
|
+
} else if (seed < -0.45) {
|
|
28
|
+
putTileAt(coord, Tileset.Forest, "Foreground");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./registerSystems";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PhaserLayer } from "../createPhaserLayer";
|
|
2
|
+
import { createCamera } from "./createCamera";
|
|
3
|
+
import { createMapSystem } from "./createMapSystem";
|
|
4
|
+
|
|
5
|
+
export const registerSystems = (layer: PhaserLayer) => {
|
|
6
|
+
createCamera(layer);
|
|
7
|
+
createMapSystem(layer);
|
|
8
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
|
|
3
|
+
import { TableId } from "@latticexyz/utils";
|
|
4
|
+
import { defineComponent, Type as RecsType, World } from "@latticexyz/recs";
|
|
5
|
+
|
|
6
|
+
export function defineContractComponents(world: World) {
|
|
7
|
+
return {
|
|
8
|
+
Counter: (() => {
|
|
9
|
+
const tableId = new TableId("", "Counter");
|
|
10
|
+
return defineComponent(
|
|
11
|
+
world,
|
|
12
|
+
{
|
|
13
|
+
value: RecsType.Number,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
metadata: {
|
|
17
|
+
contractId: tableId.toHexString(),
|
|
18
|
+
tableId: tableId.toString(),
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
})(),
|
|
23
|
+
};
|
|
24
|
+
}
|