create-mud 2.2.17-f88e48e47ceb4a29a3862a3f3b85891490952f0e → 2.2.17-ffefc8f000769d5ca625dd19290007a853a21788
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 +2 -4
- package/bin/cli.js +4 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +9 -2
- package/dist/cli.js.map +1 -1
- package/package.json +17 -11
- package/templates/react/mprocs.yaml +21 -0
- package/templates/react/package.json +31 -0
- package/{dist/templates/threejs → templates/react}/packages/client/index.html +2 -2
- package/templates/react/packages/client/postcss.config.cjs +6 -0
- package/templates/react/packages/client/src/game/useKeyboardMovement.ts +26 -0
- package/templates/react/packages/client/src/index.tsx +19 -0
- package/templates/react/packages/client/src/mud/Explorer.tsx +32 -0
- package/{dist/templates → templates}/react/packages/client/src/mud/Synced.tsx +1 -1
- package/templates/react/packages/client/src/mud/useWorldContract.ts +44 -0
- package/templates/react/packages/client/src/ui/AsyncButton.tsx +41 -0
- package/templates/react/packages/client/src/ui/ErrorFallback.tsx +58 -0
- package/templates/react/packages/client/src/ui/icons/ArrowDownIcon.tsx +22 -0
- package/templates/react/packages/client/src/ui/icons/MUDIcon.tsx +25 -0
- package/templates/react/packages/client/src/wagmiConfig.ts +49 -0
- package/templates/react/packages/client/tailwind.config.ts +10 -0
- package/templates/react/packages/client/tsconfig.json +11 -0
- package/{dist/templates/threejs → templates/react}/packages/client/vite.config.ts +2 -7
- package/templates/react/packages/contracts/.env +11 -0
- package/{dist/templates → templates}/react/packages/contracts/mud.config.ts +0 -7
- package/{dist/templates/vanilla → templates/react}/packages/contracts/package.json +1 -0
- package/{dist/templates/vanilla → templates/react}/packages/contracts/script/PostDeploy.s.sol +1 -5
- package/{dist/templates/vanilla/packages/contracts/src/codegen/index.sol → templates/react/packages/contracts/src/codegen/common.sol} +6 -1
- package/{dist/templates → templates}/react/packages/contracts/test/MoveTest.t.sol +0 -2
- package/templates/react/packages/contracts/test/WorldTest.t.sol +16 -0
- package/templates/react/packages/contracts/worlds.json +5 -0
- package/{dist/templates → templates}/react-ecs/packages/client/package.json +16 -9
- package/templates/react-ecs/packages/client/src/App.tsx +74 -0
- package/templates/react-ecs/packages/client/src/Providers.tsx +29 -0
- package/templates/react-ecs/packages/client/src/common.ts +27 -0
- package/templates/react-ecs/packages/client/src/game/GameMap.tsx +112 -0
- package/templates/react-ecs/packages/client/src/mud/Synced.tsx +14 -0
- package/templates/react-ecs/packages/client/src/mud/recs.ts +6 -0
- package/templates/react-ecs/packages/client/src/mud/useSyncStatus.ts +17 -0
- package/{dist/templates/threejs → templates/react-ecs}/packages/contracts/.env +1 -1
- package/templates/react-ecs/packages/contracts/mud.config.ts +18 -0
- package/templates/react-ecs/packages/contracts/out/IWorld.sol/IWorld.abi.json +2039 -0
- package/templates/react-ecs/packages/contracts/src/Entity.sol +20 -0
- package/templates/react-ecs/packages/contracts/src/MoveSystem.sol +30 -0
- package/templates/react-ecs/packages/contracts/src/SpawnSystem.sol +18 -0
- package/templates/react-ecs/packages/contracts/src/codegen/index.sol +8 -0
- package/{dist/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol → templates/react-ecs/packages/contracts/src/codegen/tables/EntityCount.sol} +35 -35
- package/templates/react-ecs/packages/contracts/src/codegen/tables/Owner.sol +202 -0
- package/templates/react-ecs/packages/contracts/src/codegen/tables/Position.sol +321 -0
- package/templates/react-ecs/packages/contracts/src/codegen/world/IMoveSystem.sol +16 -0
- package/templates/react-ecs/packages/contracts/src/codegen/world/ISpawnSystem.sol +15 -0
- package/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol +17 -0
- package/templates/react-ecs/packages/contracts/src/createEntity.sol +11 -0
- package/templates/react-ecs/packages/contracts/test/MoveTest.t.sol +39 -0
- package/{dist/templates/react → templates/react-ecs}/packages/contracts/test/WorldTest.t.sol +0 -5
- package/dist/templates/phaser/gitignore +0 -7
- package/dist/templates/phaser/packages/art/gitignore +0 -0
- package/dist/templates/phaser/packages/client/gitignore +0 -3
- package/dist/templates/phaser/packages/contracts/gitignore +0 -9
- package/dist/templates/react/gitignore +0 -16
- package/dist/templates/react/packages/client/gitignore +0 -1
- package/dist/templates/react/packages/contracts/gitignore +0 -13
- package/dist/templates/react-ecs/gitignore +0 -7
- package/dist/templates/react-ecs/package.json +0 -32
- package/dist/templates/react-ecs/packages/client/gitignore +0 -3
- package/dist/templates/react-ecs/packages/client/src/App.tsx +0 -29
- package/dist/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts +0 -51
- package/dist/templates/react-ecs/packages/client/src/mud/getNetworkConfig.ts +0 -77
- package/dist/templates/react-ecs/packages/contracts/gitignore +0 -9
- package/dist/templates/threejs/gitignore +0 -7
- package/dist/templates/threejs/packages/client/gitignore +0 -3
- package/dist/templates/threejs/packages/client/src/MUDContext.tsx +0 -21
- package/dist/templates/threejs/packages/client/src/index.tsx +0 -34
- package/dist/templates/threejs/packages/contracts/gitignore +0 -9
- package/dist/templates/vanilla/gitignore +0 -7
- package/dist/templates/vanilla/mprocs.yaml +0 -13
- package/dist/templates/vanilla/packages/client/gitignore +0 -3
- package/dist/templates/vanilla/packages/client/src/mud/createClientComponents.ts +0 -21
- package/dist/templates/vanilla/packages/client/src/mud/setup.ts +0 -21
- package/dist/templates/vanilla/packages/client/src/mud/setupNetwork.ts +0 -106
- package/dist/templates/vanilla/packages/client/src/mud/supportedChains.ts +0 -20
- package/dist/templates/vanilla/packages/client/src/mud/world.ts +0 -3
- package/dist/templates/vanilla/packages/client/tsconfig.json +0 -11
- package/dist/templates/vanilla/packages/contracts/.env +0 -11
- package/dist/templates/vanilla/packages/contracts/gitignore +0 -9
- package/dist/templates/vanilla/packages/contracts/mud.config.ts +0 -13
- package/dist/templates/vanilla/packages/contracts/src/codegen/world/IIncrementSystem.sol +0 -13
- package/dist/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol +0 -16
- package/dist/templates/vanilla/packages/contracts/src/systems/IncrementSystem.sol +0 -14
- package/dist/templates/vanilla/packages/contracts/test/CounterTest.t.sol +0 -31
- package/dist/templates/vanilla/packages/contracts/worlds.json +0 -5
- /package/{dist/templates → templates}/phaser/.eslintrc +0 -0
- /package/{dist/templates → templates}/phaser/.gitattributes +0 -0
- /package/{dist/templates → templates}/phaser/.vscode/extensions.json +0 -0
- /package/{dist/templates → templates}/phaser/.vscode/settings.json +0 -0
- /package/{dist/templates → templates}/phaser/mprocs.yaml +0 -0
- /package/{dist/templates → templates}/phaser/package.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/README.md +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/config-sprites.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/package.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/scripts/cli.mjs +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/scripts/export-tiled-types.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/attack/0.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/attack/1.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/attack/2.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/attack/3.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/attack/4.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/attack/5.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/death/0.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/death/1.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/death/2.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/idle/0.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/idle/1.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/idle/2.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/sprites/golem/idle/3.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/tilesets/images/world.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/art/tilesets/world.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/.env +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/.eslintrc +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/index.html +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/package.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/public/assets/atlases/atlas.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/public/assets/atlases/atlas.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/public/assets/tilesets/world.png +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/artTypes/world.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/index.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/layers/network/createNetworkLayer.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/layers/phaser/configurePhaser.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/layers/phaser/constants.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/layers/phaser/createPhaserLayer.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/layers/phaser/systems/createCamera.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/layers/phaser/systems/createMapSystem.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/layers/phaser/systems/index.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/layers/phaser/systems/registerSystems.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/mud/createClientComponents.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/mud/createSystemCalls.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/mud/getNetworkConfig.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/mud/setup.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/mud/setupNetwork.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/mud/supportedChains.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/mud/world.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/store.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/App.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/LoadingScreen/BootScreen.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/LoadingScreen/LoadingBar.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/LoadingScreen/LoadingScreen.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/LoadingScreen/index.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/PhaserLayer.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/UIRoot.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/Wrapper.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/hooks/useNetworkLayer.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/hooks/usePhaserLayer.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/hooks/usePromiseValue.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/theme/ClickWrapper.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/src/ui/theme/SpriteImage.tsx +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/tsconfig.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/client/vite.config.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/.env +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/.prettierrc +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/.solhint.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/foundry.toml +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/mud.config.ts +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/package.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/remappings.txt +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/script/PostDeploy.s.sol +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/src/codegen/index.sol +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/src/codegen/tables/Counter.sol +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/src/codegen/world/IIncrementSystem.sol +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/src/codegen/world/IWorld.sol +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/src/systems/IncrementSystem.sol +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/test/CounterTest.t.sol +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/tsconfig.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/worlds.json +0 -0
- /package/{dist/templates → templates}/phaser/packages/contracts/worlds.json.d.ts +0 -0
- /package/{dist/templates → templates}/phaser/pnpm-workspace.yaml +0 -0
- /package/{dist/templates → templates}/phaser/tsconfig.json +0 -0
- /package/{dist/templates → templates}/react/.eslintrc +0 -0
- /package/{dist/templates → templates}/react/.gitattributes +0 -0
- /package/{dist/templates → templates}/react/.vscode/extensions.json +0 -0
- /package/{dist/templates → templates}/react/.vscode/settings.json +0 -0
- /package/{dist/templates → templates}/react/packages/client/.env +0 -0
- /package/{dist/templates → templates}/react/packages/client/.eslintrc +0 -0
- /package/{dist/templates → templates}/react/packages/client/package.json +0 -0
- /package/{dist/templates → templates}/react/packages/client/src/App.tsx +0 -0
- /package/{dist/templates → templates}/react/packages/client/src/Providers.tsx +0 -0
- /package/{dist/templates → templates}/react/packages/client/src/common.ts +0 -0
- /package/{dist/templates → templates}/react/packages/client/src/game/GameMap.tsx +0 -0
- /package/{dist/templates → templates}/react/packages/client/src/mud/stash.ts +0 -0
- /package/{dist/templates → templates}/react/packages/client/src/mud/useSyncStatus.ts +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/.prettierrc +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/.solhint.json +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/foundry.toml +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/out/IWorld.sol/IWorld.abi.json +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/remappings.txt +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/src/MoveSystem.sol +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/src/codegen/index.sol +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/src/codegen/tables/Position.sol +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/src/codegen/world/IMoveSystem.sol +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/src/codegen/world/IWorld.sol +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/tsconfig.json +0 -0
- /package/{dist/templates → templates}/react/packages/contracts/worlds.json.d.ts +0 -0
- /package/{dist/templates → templates}/react/pnpm-workspace.yaml +0 -0
- /package/{dist/templates → templates}/react/tsconfig.json +0 -0
- /package/{dist/templates → templates}/react-ecs/.eslintrc +0 -0
- /package/{dist/templates → templates}/react-ecs/.gitattributes +0 -0
- /package/{dist/templates → templates}/react-ecs/.vscode/extensions.json +0 -0
- /package/{dist/templates → templates}/react-ecs/.vscode/settings.json +0 -0
- /package/{dist/templates/react → templates/react-ecs}/mprocs.yaml +0 -0
- /package/{dist/templates/react → templates/react-ecs}/package.json +0 -0
- /package/{dist/templates → templates}/react-ecs/packages/client/.env +0 -0
- /package/{dist/templates → templates}/react-ecs/packages/client/.eslintrc +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/index.html +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/postcss.config.cjs +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/src/game/useKeyboardMovement.ts +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/src/index.tsx +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/src/mud/Explorer.tsx +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/src/mud/useWorldContract.ts +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/src/ui/AsyncButton.tsx +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/src/ui/ErrorFallback.tsx +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/src/ui/icons/ArrowDownIcon.tsx +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/src/ui/icons/MUDIcon.tsx +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/src/wagmiConfig.ts +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/tailwind.config.ts +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/tsconfig.json +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/client/vite.config.ts +0 -0
- /package/{dist/templates → templates}/react-ecs/packages/contracts/.prettierrc +0 -0
- /package/{dist/templates → templates}/react-ecs/packages/contracts/.solhint.json +0 -0
- /package/{dist/templates → templates}/react-ecs/packages/contracts/foundry.toml +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/contracts/package.json +0 -0
- /package/{dist/templates → templates}/react-ecs/packages/contracts/remappings.txt +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/contracts/script/PostDeploy.s.sol +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/contracts/src/codegen/common.sol +0 -0
- /package/{dist/templates → templates}/react-ecs/packages/contracts/tsconfig.json +0 -0
- /package/{dist/templates/react → templates/react-ecs}/packages/contracts/worlds.json +0 -0
- /package/{dist/templates → templates}/react-ecs/packages/contracts/worlds.json.d.ts +0 -0
- /package/{dist/templates → templates}/react-ecs/pnpm-workspace.yaml +0 -0
- /package/{dist/templates → templates}/react-ecs/tsconfig.json +0 -0
- /package/{dist/templates → templates}/threejs/.eslintrc +0 -0
- /package/{dist/templates → templates}/threejs/.gitattributes +0 -0
- /package/{dist/templates → templates}/threejs/.vscode/extensions.json +0 -0
- /package/{dist/templates → templates}/threejs/.vscode/settings.json +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/mprocs.yaml +0 -0
- /package/{dist/templates → templates}/threejs/package.json +0 -0
- /package/{dist/templates → templates}/threejs/packages/client/.env +0 -0
- /package/{dist/templates → templates}/threejs/packages/client/.eslintrc +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/client/index.html +0 -0
- /package/{dist/templates → templates}/threejs/packages/client/package.json +0 -0
- /package/{dist/templates → templates}/threejs/packages/client/src/App.tsx +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/client/src/MUDContext.tsx +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/client/src/index.tsx +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/client/src/mud/createClientComponents.ts +0 -0
- /package/{dist/templates → templates}/threejs/packages/client/src/mud/createSystemCalls.ts +0 -0
- /package/{dist/templates → templates}/threejs/packages/client/src/mud/getNetworkConfig.ts +0 -0
- /package/{dist/templates → templates}/threejs/packages/client/src/mud/setup.ts +0 -0
- /package/{dist/templates → templates}/threejs/packages/client/src/mud/setupNetwork.ts +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/client/src/mud/supportedChains.ts +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/client/src/mud/world.ts +0 -0
- /package/{dist/templates → templates}/threejs/packages/client/src/useKeyboardMovement.ts +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/client/tsconfig.json +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/client/vite.config.ts +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/contracts/.env +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/.prettierrc +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/.solhint.json +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/foundry.toml +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/mud.config.ts +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/package.json +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/remappings.txt +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/src/codegen/index.sol +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/src/codegen/tables/Position.sol +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/src/codegen/world/IMoveSystem.sol +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/src/codegen/world/IWorld.sol +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/src/systems/MoveSystem.sol +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/test/WorldTest.t.sol +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/tsconfig.json +0 -0
- /package/{dist/templates/react-ecs → templates/threejs}/packages/contracts/worlds.json +0 -0
- /package/{dist/templates → templates}/threejs/packages/contracts/worlds.json.d.ts +0 -0
- /package/{dist/templates → templates}/threejs/pnpm-workspace.yaml +0 -0
- /package/{dist/templates → templates}/threejs/tsconfig.json +0 -0
- /package/{dist/templates → templates}/vanilla/.eslintrc +0 -0
- /package/{dist/templates → templates}/vanilla/.gitattributes +0 -0
- /package/{dist/templates → templates}/vanilla/.vscode/extensions.json +0 -0
- /package/{dist/templates → templates}/vanilla/.vscode/settings.json +0 -0
- /package/{dist/templates/threejs → templates/vanilla}/mprocs.yaml +0 -0
- /package/{dist/templates → templates}/vanilla/package.json +0 -0
- /package/{dist/templates → templates}/vanilla/packages/client/.env +0 -0
- /package/{dist/templates → templates}/vanilla/packages/client/index.html +0 -0
- /package/{dist/templates → templates}/vanilla/packages/client/package.json +0 -0
- /package/{dist/templates → templates}/vanilla/packages/client/src/index.ts +0 -0
- /package/{dist/templates/threejs → templates/vanilla}/packages/client/src/mud/createClientComponents.ts +0 -0
- /package/{dist/templates → templates}/vanilla/packages/client/src/mud/createSystemCalls.ts +0 -0
- /package/{dist/templates → templates}/vanilla/packages/client/src/mud/getNetworkConfig.ts +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/client/src/mud/setup.ts +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/client/src/mud/setupNetwork.ts +0 -0
- /package/{dist/templates/threejs → templates/vanilla}/packages/client/src/mud/supportedChains.ts +0 -0
- /package/{dist/templates/threejs → templates/vanilla}/packages/client/src/mud/world.ts +0 -0
- /package/{dist/templates/threejs → templates/vanilla}/packages/client/tsconfig.json +0 -0
- /package/{dist/templates → templates}/vanilla/packages/client/vite.config.ts +0 -0
- /package/{dist/templates/react → templates/vanilla}/packages/contracts/.env +0 -0
- /package/{dist/templates → templates}/vanilla/packages/contracts/.prettierrc +0 -0
- /package/{dist/templates → templates}/vanilla/packages/contracts/.solhint.json +0 -0
- /package/{dist/templates → templates}/vanilla/packages/contracts/foundry.toml +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/contracts/mud.config.ts +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/contracts/package.json +0 -0
- /package/{dist/templates → templates}/vanilla/packages/contracts/remappings.txt +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/contracts/script/PostDeploy.s.sol +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/contracts/src/codegen/index.sol +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/contracts/src/codegen/tables/Counter.sol +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/contracts/src/codegen/world/IIncrementSystem.sol +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/contracts/src/codegen/world/IWorld.sol +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/contracts/src/systems/IncrementSystem.sol +0 -0
- /package/{dist/templates/react-ecs → templates/vanilla}/packages/contracts/test/CounterTest.t.sol +0 -0
- /package/{dist/templates → templates}/vanilla/packages/contracts/tsconfig.json +0 -0
- /package/{dist/templates/threejs → templates/vanilla}/packages/contracts/worlds.json +0 -0
- /package/{dist/templates → templates}/vanilla/packages/contracts/worlds.json.d.ts +0 -0
- /package/{dist/templates → templates}/vanilla/pnpm-workspace.yaml +0 -0
- /package/{dist/templates → templates}/vanilla/tsconfig.json +0 -0
|
@@ -3,7 +3,6 @@ pragma solidity >=0.8.24;
|
|
|
3
3
|
|
|
4
4
|
import "forge-std/Test.sol";
|
|
5
5
|
import { MudTest } from "@latticexyz/world/test/MudTest.t.sol";
|
|
6
|
-
import { getKeysWithValue } from "@latticexyz/world-modules/src/modules/keyswithvalue/getKeysWithValue.sol";
|
|
7
6
|
|
|
8
7
|
import { IWorld } from "../src/codegen/world/IWorld.sol";
|
|
9
8
|
import { Position, PositionData } from "../src/codegen/tables/Position.sol";
|
|
@@ -20,7 +19,6 @@ contract MoveTest is MudTest {
|
|
|
20
19
|
|
|
21
20
|
IWorld(worldAddress).app__move(Direction.North);
|
|
22
21
|
position = Position.get(alice);
|
|
23
|
-
|
|
24
22
|
assertEq(position.x, 0);
|
|
25
23
|
assertEq(position.y, 1);
|
|
26
24
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.8.24;
|
|
3
|
+
|
|
4
|
+
import "forge-std/Test.sol";
|
|
5
|
+
import { MudTest } from "@latticexyz/world/test/MudTest.t.sol";
|
|
6
|
+
|
|
7
|
+
contract WorldTest is MudTest {
|
|
8
|
+
function testWorldDeployed() public {
|
|
9
|
+
uint256 codeSize;
|
|
10
|
+
address addr = worldAddress;
|
|
11
|
+
assembly {
|
|
12
|
+
codeSize := extcodesize(addr)
|
|
13
|
+
}
|
|
14
|
+
assertTrue(codeSize > 0);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -6,32 +6,39 @@
|
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "vite build",
|
|
9
|
-
"dev": "
|
|
9
|
+
"dev": "vite",
|
|
10
10
|
"preview": "vite preview",
|
|
11
11
|
"test": "tsc --noEmit"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@latticexyz/common": "{{mud-version}}",
|
|
15
|
-
"@latticexyz/
|
|
15
|
+
"@latticexyz/entrykit": "{{mud-version}}",
|
|
16
|
+
"@latticexyz/explorer": "{{mud-version}}",
|
|
16
17
|
"@latticexyz/react": "{{mud-version}}",
|
|
17
18
|
"@latticexyz/recs": "{{mud-version}}",
|
|
18
19
|
"@latticexyz/schema-type": "{{mud-version}}",
|
|
19
20
|
"@latticexyz/store-sync": "{{mud-version}}",
|
|
20
21
|
"@latticexyz/utils": "{{mud-version}}",
|
|
21
22
|
"@latticexyz/world": "{{mud-version}}",
|
|
23
|
+
"@tanstack/react-query": "^5.63.0",
|
|
22
24
|
"contracts": "workspace:*",
|
|
23
|
-
"react": "
|
|
24
|
-
"react-dom": "
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"react": "18.2.0",
|
|
26
|
+
"react-dom": "18.2.0",
|
|
27
|
+
"react-error-boundary": "5.0.0",
|
|
28
|
+
"tailwind-merge": "^2.6.0",
|
|
29
|
+
"viem": "2.21.19",
|
|
30
|
+
"wagmi": "2.12.11"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
29
33
|
"@types/react": "18.2.22",
|
|
30
34
|
"@types/react-dom": "18.2.7",
|
|
31
|
-
"@vitejs/plugin-react": "^3.
|
|
35
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
36
|
+
"autoprefixer": "^10.4.20",
|
|
32
37
|
"eslint-plugin-react": "7.31.11",
|
|
33
38
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
39
|
+
"postcss": "^8.4.49",
|
|
40
|
+
"tailwindcss": "^3.4.17",
|
|
41
|
+
"vite": "^6.0.7",
|
|
42
|
+
"vite-plugin-mud": "{{mud-version}}"
|
|
36
43
|
}
|
|
37
44
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { AccountButton } from "@latticexyz/entrykit/internal";
|
|
2
|
+
import { Direction, Entity } from "./common";
|
|
3
|
+
import mudConfig from "contracts/mud.config";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { GameMap } from "./game/GameMap";
|
|
6
|
+
import { useWorldContract } from "./mud/useWorldContract";
|
|
7
|
+
import { Synced } from "./mud/Synced";
|
|
8
|
+
import { useSync } from "@latticexyz/store-sync/react";
|
|
9
|
+
import { components } from "./mud/recs";
|
|
10
|
+
import { useEntityQuery } from "@latticexyz/react";
|
|
11
|
+
import { Has, getComponentValueStrict } from "@latticexyz/recs";
|
|
12
|
+
import { Address } from "viem";
|
|
13
|
+
|
|
14
|
+
export function App() {
|
|
15
|
+
const playerEntities = useEntityQuery([Has(components.Owner), Has(components.Position)]);
|
|
16
|
+
const players = useMemo(
|
|
17
|
+
() =>
|
|
18
|
+
playerEntities.map((entity) => {
|
|
19
|
+
const owner = getComponentValueStrict(components.Owner, entity);
|
|
20
|
+
const position = getComponentValueStrict(components.Position, entity);
|
|
21
|
+
return {
|
|
22
|
+
entity: entity as Entity,
|
|
23
|
+
owner: owner.owner as Address,
|
|
24
|
+
x: position.x,
|
|
25
|
+
y: position.y,
|
|
26
|
+
};
|
|
27
|
+
}),
|
|
28
|
+
[playerEntities],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const sync = useSync();
|
|
32
|
+
const worldContract = useWorldContract();
|
|
33
|
+
|
|
34
|
+
const onMove = useMemo(
|
|
35
|
+
() =>
|
|
36
|
+
sync.data && worldContract
|
|
37
|
+
? async (entity: Entity, direction: Direction) => {
|
|
38
|
+
const tx = await worldContract.write.app__move([entity, mudConfig.enums.Direction.indexOf(direction)]);
|
|
39
|
+
await sync.data.waitForTransaction(tx);
|
|
40
|
+
}
|
|
41
|
+
: undefined,
|
|
42
|
+
[sync.data, worldContract],
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const onSpawn = useMemo(
|
|
46
|
+
() =>
|
|
47
|
+
sync.data && worldContract
|
|
48
|
+
? async () => {
|
|
49
|
+
const tx = await worldContract.write.app__spawn();
|
|
50
|
+
await sync.data.waitForTransaction(tx);
|
|
51
|
+
}
|
|
52
|
+
: undefined,
|
|
53
|
+
[sync.data, worldContract],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<>
|
|
58
|
+
<div className="fixed inset-0 grid place-items-center p-4">
|
|
59
|
+
<Synced
|
|
60
|
+
fallback={({ message, percentage }) => (
|
|
61
|
+
<div className="tabular-nums">
|
|
62
|
+
{message} ({percentage.toFixed(1)}%)…
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
>
|
|
66
|
+
<GameMap players={players} onMove={onMove} onSpawn={onSpawn} />
|
|
67
|
+
</Synced>
|
|
68
|
+
</div>
|
|
69
|
+
<div className="fixed top-2 right-2">
|
|
70
|
+
<AccountButton />
|
|
71
|
+
</div>
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { WagmiProvider } from "wagmi";
|
|
2
|
+
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { SyncProvider } from "@latticexyz/store-sync/react";
|
|
5
|
+
import { defineConfig, EntryKitProvider } from "@latticexyz/entrykit/internal";
|
|
6
|
+
import { wagmiConfig } from "./wagmiConfig";
|
|
7
|
+
import { chainId, getWorldAddress, startBlock } from "./common";
|
|
8
|
+
import { syncAdapter } from "./mud/recs";
|
|
9
|
+
|
|
10
|
+
const queryClient = new QueryClient();
|
|
11
|
+
|
|
12
|
+
export type Props = {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function Providers({ children }: Props) {
|
|
17
|
+
const worldAddress = getWorldAddress();
|
|
18
|
+
return (
|
|
19
|
+
<WagmiProvider config={wagmiConfig}>
|
|
20
|
+
<QueryClientProvider client={queryClient}>
|
|
21
|
+
<EntryKitProvider config={defineConfig({ chainId, worldAddress })}>
|
|
22
|
+
<SyncProvider chainId={chainId} address={worldAddress} startBlock={startBlock} adapter={syncAdapter}>
|
|
23
|
+
{children}
|
|
24
|
+
</SyncProvider>
|
|
25
|
+
</EntryKitProvider>
|
|
26
|
+
</QueryClientProvider>
|
|
27
|
+
</WagmiProvider>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import mudConfig from "contracts/mud.config";
|
|
2
|
+
import { chains } from "./wagmiConfig";
|
|
3
|
+
import { Chain, Hex } from "viem";
|
|
4
|
+
|
|
5
|
+
export const chainId = import.meta.env.CHAIN_ID;
|
|
6
|
+
export const worldAddress = import.meta.env.WORLD_ADDRESS;
|
|
7
|
+
export const startBlock = import.meta.env.START_BLOCK;
|
|
8
|
+
|
|
9
|
+
export const url = new URL(window.location.href);
|
|
10
|
+
|
|
11
|
+
export type Entity = Hex;
|
|
12
|
+
export type Direction = (typeof mudConfig.enums.Direction)[number];
|
|
13
|
+
|
|
14
|
+
export function getWorldAddress() {
|
|
15
|
+
if (!worldAddress) {
|
|
16
|
+
throw new Error("No world address configured. Is the world still deploying?");
|
|
17
|
+
}
|
|
18
|
+
return worldAddress;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getChain(): Chain {
|
|
22
|
+
const chain = chains.find((c) => c.id === chainId);
|
|
23
|
+
if (!chain) {
|
|
24
|
+
throw new Error(`No chain configured for chain ID ${chainId}.`);
|
|
25
|
+
}
|
|
26
|
+
return chain;
|
|
27
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { serialize, useAccount } from "wagmi";
|
|
2
|
+
import { useKeyboardMovement } from "./useKeyboardMovement";
|
|
3
|
+
import { Address, Hex, hexToBigInt, keccak256 } from "viem";
|
|
4
|
+
import { ArrowDownIcon } from "../ui/icons/ArrowDownIcon";
|
|
5
|
+
import { twMerge } from "tailwind-merge";
|
|
6
|
+
import { Direction, Entity } from "../common";
|
|
7
|
+
import mudConfig from "contracts/mud.config";
|
|
8
|
+
import { AsyncButton } from "../ui/AsyncButton";
|
|
9
|
+
import { useAccountModal } from "@latticexyz/entrykit/internal";
|
|
10
|
+
import { useMemo } from "react";
|
|
11
|
+
|
|
12
|
+
export type Props = {
|
|
13
|
+
readonly players?: {
|
|
14
|
+
readonly entity: Entity;
|
|
15
|
+
readonly owner: Address;
|
|
16
|
+
readonly x: number;
|
|
17
|
+
readonly y: number;
|
|
18
|
+
}[];
|
|
19
|
+
readonly onMove?: (entity: Entity, direction: Direction) => Promise<void>;
|
|
20
|
+
readonly onSpawn?: () => Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const size = 40;
|
|
24
|
+
const scale = 100 / size;
|
|
25
|
+
|
|
26
|
+
function getColorAngle(seed: Hex) {
|
|
27
|
+
return Number(hexToBigInt(keccak256(seed)) % 360n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const rotateClassName = {
|
|
31
|
+
North: "rotate-0",
|
|
32
|
+
East: "rotate-90",
|
|
33
|
+
South: "rotate-180",
|
|
34
|
+
West: "-rotate-90",
|
|
35
|
+
} as const satisfies Record<Direction, `${"" | "-"}rotate-${number}`>;
|
|
36
|
+
|
|
37
|
+
export function GameMap({ players = [], onMove, onSpawn }: Props) {
|
|
38
|
+
const { openAccountModal } = useAccountModal();
|
|
39
|
+
const { address: userAddress } = useAccount();
|
|
40
|
+
|
|
41
|
+
const currentPlayer = players.find((player) => player.owner.toLowerCase() === userAddress?.toLowerCase());
|
|
42
|
+
|
|
43
|
+
useKeyboardMovement(
|
|
44
|
+
useMemo(
|
|
45
|
+
() => (onMove && currentPlayer ? (direction: Direction) => onMove(currentPlayer.entity, direction) : undefined),
|
|
46
|
+
[currentPlayer, onMove],
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div className="aspect-square w-full max-w-[40rem]">
|
|
52
|
+
<div className="relative w-full h-full border-8 border-black/10">
|
|
53
|
+
{currentPlayer && onMove
|
|
54
|
+
? mudConfig.enums.Direction.map((direction) => (
|
|
55
|
+
<button
|
|
56
|
+
key={direction}
|
|
57
|
+
title={`Move ${direction.toLowerCase()}`}
|
|
58
|
+
className={twMerge(
|
|
59
|
+
"outline-0 absolute inset-0 cursor-pointer grid p-4",
|
|
60
|
+
rotateClassName[direction],
|
|
61
|
+
"transition bg-gradient-to-t from-transparent via-transparent to-blue-50 text-blue-400 opacity-0 hover:opacity-40 active:opacity-100",
|
|
62
|
+
)}
|
|
63
|
+
style={{ clipPath: "polygon(0% 0%, 100% 0%, 50% 50%)" }}
|
|
64
|
+
onClick={() => onMove(currentPlayer.entity, direction)}
|
|
65
|
+
>
|
|
66
|
+
<ArrowDownIcon className="rotate-180 text-4xl self-start justify-self-center" />
|
|
67
|
+
</button>
|
|
68
|
+
))
|
|
69
|
+
: null}
|
|
70
|
+
|
|
71
|
+
{players.map((player) => (
|
|
72
|
+
<div
|
|
73
|
+
key={player.entity}
|
|
74
|
+
className="absolute bg-current"
|
|
75
|
+
style={{
|
|
76
|
+
color: `hwb(${getColorAngle(player.owner)} 40% 20%)`,
|
|
77
|
+
width: `${scale}%`,
|
|
78
|
+
height: `${scale}%`,
|
|
79
|
+
left: `${((((player.x + size / 2) % size) + size) % size) * scale}%`,
|
|
80
|
+
top: `${((size - ((player.y + size / 2) % size)) % size) * scale}%`,
|
|
81
|
+
}}
|
|
82
|
+
title={serialize(player, null, 2)}
|
|
83
|
+
>
|
|
84
|
+
{player === currentPlayer ? <div className="w-full h-full bg-current animate-ping opacity-50" /> : null}
|
|
85
|
+
</div>
|
|
86
|
+
))}
|
|
87
|
+
|
|
88
|
+
{!currentPlayer ? (
|
|
89
|
+
onSpawn ? (
|
|
90
|
+
<div className="absolute inset-0 grid place-items-center">
|
|
91
|
+
<AsyncButton
|
|
92
|
+
className="group outline-0 p-4 border-4 border-green-400 transition ring-green-300 hover:ring-4 active:scale-95 rounded-lg text-lg font-medium aria-busy:pointer-events-none aria-busy:animate-pulse"
|
|
93
|
+
onClick={() => onSpawn()}
|
|
94
|
+
>
|
|
95
|
+
Spawn<span className="hidden group-aria-busy:inline">ing…</span>
|
|
96
|
+
</AsyncButton>
|
|
97
|
+
</div>
|
|
98
|
+
) : (
|
|
99
|
+
<div className="absolute inset-0 grid place-items-center">
|
|
100
|
+
<button
|
|
101
|
+
className="group outline-0 p-4 border-4 border-green-400 transition ring-green-300 hover:ring-4 active:scale-95 rounded-lg text-lg font-medium aria-busy:pointer-events-none aria-busy:animate-pulse"
|
|
102
|
+
onClick={openAccountModal}
|
|
103
|
+
>
|
|
104
|
+
Sign in to play
|
|
105
|
+
</button>
|
|
106
|
+
</div>
|
|
107
|
+
)
|
|
108
|
+
) : null}
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { useSyncStatus } from "./useSyncStatus";
|
|
3
|
+
import { ComponentValue } from "@latticexyz/recs";
|
|
4
|
+
import { components } from "./recs";
|
|
5
|
+
|
|
6
|
+
export type Props = {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
fallback?: (props: ComponentValue<(typeof components)["SyncProgress"]["schema"]>) => ReactNode;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function Synced({ children, fallback }: Props) {
|
|
12
|
+
const status = useSyncStatus();
|
|
13
|
+
return status.isLive ? children : fallback?.(status);
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createWorld } from "@latticexyz/recs";
|
|
2
|
+
import { createSyncAdapter } from "@latticexyz/store-sync/recs";
|
|
3
|
+
import config from "contracts/mud.config";
|
|
4
|
+
|
|
5
|
+
export const world = createWorld();
|
|
6
|
+
export const { syncAdapter, components } = createSyncAdapter({ world, config });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { initialProgress } from "@latticexyz/store-sync/internal";
|
|
2
|
+
import { SyncStep } from "@latticexyz/store-sync";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { useComponentValue } from "@latticexyz/react";
|
|
5
|
+
import { singletonEntity } from "@latticexyz/store-sync/recs";
|
|
6
|
+
import { components } from "./recs";
|
|
7
|
+
|
|
8
|
+
export function useSyncStatus() {
|
|
9
|
+
const progress = useComponentValue(components.SyncProgress, singletonEntity, initialProgress);
|
|
10
|
+
return useMemo(
|
|
11
|
+
() => ({
|
|
12
|
+
...progress,
|
|
13
|
+
isLive: progress.step === SyncStep.LIVE,
|
|
14
|
+
}),
|
|
15
|
+
[progress],
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineWorld } from "@latticexyz/world";
|
|
2
|
+
|
|
3
|
+
export default defineWorld({
|
|
4
|
+
namespace: "app",
|
|
5
|
+
userTypes: {
|
|
6
|
+
Entity: { type: "bytes32", filePath: "./src/Entity.sol" },
|
|
7
|
+
},
|
|
8
|
+
enums: {
|
|
9
|
+
Direction: ["North", "East", "South", "West"],
|
|
10
|
+
},
|
|
11
|
+
tables: {
|
|
12
|
+
// singletons
|
|
13
|
+
EntityCount: { schema: { count: "uint256" }, key: [] },
|
|
14
|
+
// components
|
|
15
|
+
Owner: { id: "Entity", owner: "address" },
|
|
16
|
+
Position: { id: "Entity", x: "int32", y: "int32" },
|
|
17
|
+
},
|
|
18
|
+
});
|