hytopia 0.1.15 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. package/bin/scripts.js +28 -9
  2. package/docs/server.hytopia.md +1 -1
  3. package/docs/server.hytopia.port.md +2 -2
  4. package/docs/server.hytopia.supported_input_keys.md +1 -1
  5. package/docs/server.md +1 -1
  6. package/docs/server.port.md +2 -2
  7. package/docs/server.supported_input_keys.md +1 -1
  8. package/examples/character-controller/MyCharacterController.ts +230 -0
  9. package/examples/character-controller/README.md +15 -0
  10. package/examples/character-controller/assets/audio/sfx/damage.wav +0 -0
  11. package/examples/character-controller/assets/audio/sfx/step.wav +0 -0
  12. package/examples/character-controller/assets/certs/README.md +11 -0
  13. package/examples/character-controller/assets/certs/localhost.crt +20 -0
  14. package/examples/character-controller/assets/certs/localhost.key +27 -0
  15. package/examples/character-controller/assets/cubemaps/skybox/+x.png +0 -0
  16. package/examples/character-controller/assets/cubemaps/skybox/+y.png +0 -0
  17. package/examples/character-controller/assets/cubemaps/skybox/+z.png +0 -0
  18. package/examples/character-controller/assets/cubemaps/skybox/-x.png +0 -0
  19. package/examples/character-controller/assets/cubemaps/skybox/-y.png +0 -0
  20. package/examples/character-controller/assets/cubemaps/skybox/-z.png +0 -0
  21. package/examples/character-controller/assets/map.json +2623 -0
  22. package/examples/character-controller/assets/models/player.gltf +1 -0
  23. package/examples/character-controller/assets/textures/bricks.png +0 -0
  24. package/examples/character-controller/assets/textures/clay.png +0 -0
  25. package/examples/character-controller/assets/textures/diamond_ore.png +0 -0
  26. package/examples/character-controller/assets/textures/dirt.png +0 -0
  27. package/examples/character-controller/assets/textures/dragons_stone.png +0 -0
  28. package/examples/character-controller/assets/textures/glass.png +0 -0
  29. package/examples/character-controller/assets/textures/grass/+x.png +0 -0
  30. package/examples/character-controller/assets/textures/grass/+y.png +0 -0
  31. package/examples/character-controller/assets/textures/grass/+z.png +0 -0
  32. package/examples/character-controller/assets/textures/grass/-x.png +0 -0
  33. package/examples/character-controller/assets/textures/grass/-y.png +0 -0
  34. package/examples/character-controller/assets/textures/grass/-z.png +0 -0
  35. package/examples/character-controller/assets/textures/grass.png +0 -0
  36. package/examples/character-controller/assets/textures/gravel.png +0 -0
  37. package/examples/character-controller/assets/textures/ice.png +0 -0
  38. package/examples/character-controller/assets/textures/infected_shadowrock.png +0 -0
  39. package/examples/character-controller/assets/textures/log_side.png +0 -0
  40. package/examples/character-controller/assets/textures/log_top.png +0 -0
  41. package/examples/character-controller/assets/textures/mossy_coblestone.png +0 -0
  42. package/examples/character-controller/assets/textures/nuit.png +0 -0
  43. package/examples/character-controller/assets/textures/oak_leaves.png +0 -0
  44. package/examples/character-controller/assets/textures/oak_planks.png +0 -0
  45. package/examples/character-controller/assets/textures/sand.png +0 -0
  46. package/examples/character-controller/assets/textures/shadowrock.png +0 -0
  47. package/examples/character-controller/assets/textures/stone.png +0 -0
  48. package/examples/character-controller/assets/textures/stone_bricks.png +0 -0
  49. package/examples/character-controller/assets/textures/void_sand.png +0 -0
  50. package/examples/character-controller/assets/textures/water_still.png +0 -0
  51. package/examples/character-controller/bun.lockb +0 -0
  52. package/examples/character-controller/index.ts +43 -0
  53. package/examples/character-controller/package.json +14 -0
  54. package/examples/character-controller/tsconfig.json +27 -0
  55. package/examples/entity-spawn/README.md +15 -0
  56. package/examples/entity-spawn/assets/certs/README.md +11 -0
  57. package/examples/entity-spawn/assets/certs/localhost.crt +20 -0
  58. package/examples/entity-spawn/assets/certs/localhost.key +27 -0
  59. package/examples/entity-spawn/assets/cubemaps/skybox/+x.png +0 -0
  60. package/examples/entity-spawn/assets/cubemaps/skybox/+y.png +0 -0
  61. package/examples/entity-spawn/assets/cubemaps/skybox/+z.png +0 -0
  62. package/examples/entity-spawn/assets/cubemaps/skybox/-x.png +0 -0
  63. package/examples/entity-spawn/assets/cubemaps/skybox/-y.png +0 -0
  64. package/examples/entity-spawn/assets/cubemaps/skybox/-z.png +0 -0
  65. package/examples/entity-spawn/assets/map.json +2623 -0
  66. package/examples/entity-spawn/assets/models/player.gltf +1 -0
  67. package/examples/entity-spawn/assets/models/spider.gltf +1 -0
  68. package/examples/entity-spawn/assets/textures/bricks.png +0 -0
  69. package/examples/entity-spawn/assets/textures/clay.png +0 -0
  70. package/examples/entity-spawn/assets/textures/diamond_ore.png +0 -0
  71. package/examples/entity-spawn/assets/textures/dirt.png +0 -0
  72. package/examples/entity-spawn/assets/textures/dragons_stone.png +0 -0
  73. package/examples/entity-spawn/assets/textures/glass.png +0 -0
  74. package/examples/entity-spawn/assets/textures/grass/+x.png +0 -0
  75. package/examples/entity-spawn/assets/textures/grass/+y.png +0 -0
  76. package/examples/entity-spawn/assets/textures/grass/+z.png +0 -0
  77. package/examples/entity-spawn/assets/textures/grass/-x.png +0 -0
  78. package/examples/entity-spawn/assets/textures/grass/-y.png +0 -0
  79. package/examples/entity-spawn/assets/textures/grass/-z.png +0 -0
  80. package/examples/entity-spawn/assets/textures/grass.png +0 -0
  81. package/examples/entity-spawn/assets/textures/gravel.png +0 -0
  82. package/examples/entity-spawn/assets/textures/ice.png +0 -0
  83. package/examples/entity-spawn/assets/textures/infected_shadowrock.png +0 -0
  84. package/examples/entity-spawn/assets/textures/log_side.png +0 -0
  85. package/examples/entity-spawn/assets/textures/log_top.png +0 -0
  86. package/examples/entity-spawn/assets/textures/mossy_coblestone.png +0 -0
  87. package/examples/entity-spawn/assets/textures/nuit.png +0 -0
  88. package/examples/entity-spawn/assets/textures/oak_leaves.png +0 -0
  89. package/examples/entity-spawn/assets/textures/oak_planks.png +0 -0
  90. package/examples/entity-spawn/assets/textures/sand.png +0 -0
  91. package/examples/entity-spawn/assets/textures/shadowrock.png +0 -0
  92. package/examples/entity-spawn/assets/textures/stone.png +0 -0
  93. package/examples/entity-spawn/assets/textures/stone_bricks.png +0 -0
  94. package/examples/entity-spawn/assets/textures/void_sand.png +0 -0
  95. package/examples/entity-spawn/assets/textures/water_still.png +0 -0
  96. package/examples/entity-spawn/bun.lockb +0 -0
  97. package/examples/entity-spawn/index.ts +93 -0
  98. package/examples/entity-spawn/package.json +14 -0
  99. package/examples/entity-spawn/tsconfig.json +27 -0
  100. package/examples/payload-game/README.md +15 -0
  101. package/examples/payload-game/assets/certs/README.md +11 -0
  102. package/examples/payload-game/assets/certs/localhost.crt +20 -0
  103. package/examples/payload-game/assets/certs/localhost.key +27 -0
  104. package/examples/payload-game/bun.lockb +0 -0
  105. package/examples/payload-game/index.ts +12 -3
  106. package/examples/payload-game/package.json +14 -0
  107. package/examples/payload-game/tsconfig.json +27 -0
  108. package/package.json +1 -1
  109. package/server.api.json +6 -6
  110. package/server.d.ts +10 -3
  111. package/server.js +1 -1
  112. package/tsconfig.json +1 -4
@@ -0,0 +1,43 @@
1
+ import {
2
+ startServer,
3
+ GameServer,
4
+ PlayerEntity,
5
+ } from 'hytopia';
6
+
7
+ import MyCharacterController from './MyCharacterController';
8
+
9
+ import worldMap from './assets/map.json';
10
+
11
+ startServer(world => {
12
+ GameServer.instance.webServer.enableLocalSSL();
13
+ world.simulation.enableDebugRendering(true);
14
+ world.loadMap(worldMap);
15
+
16
+ world.onPlayerJoin = player => {
17
+ const playerEntity = new PlayerEntity({
18
+ player,
19
+ name: 'Player',
20
+ modelUri: 'models/player.gltf',
21
+ modelLoopedAnimations: [ 'idle' ],
22
+ modelScale: 0.5,
23
+ });
24
+
25
+ // Assign a custom character controller factory to the player entity.
26
+ // This must be assigned before spawning the entity.
27
+ // createCustomCharacterController if set will be handled internally when
28
+ // .spawn() is called.
29
+ playerEntity.createCustomCharacterController = () => {
30
+ console.log('Creating custom player entity character controller...');
31
+
32
+ return new MyCharacterController(playerEntity);
33
+ }
34
+
35
+ playerEntity.spawn(world, { x: 0, y: 10, z: 0 });
36
+ console.log('Spawned player entity!');
37
+
38
+ };
39
+
40
+ world.onPlayerLeave = player => {
41
+ world.entityManager.getAllPlayerEntities(player).forEach(entity => entity.despawn());
42
+ };
43
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "character-controller",
3
+ "module": "index.ts",
4
+ "type": "module",
5
+ "devDependencies": {
6
+ "@types/bun": "latest"
7
+ },
8
+ "peerDependencies": {
9
+ "typescript": "^5.0.0"
10
+ },
11
+ "dependencies": {
12
+ "hytopia": "^0.1.15"
13
+ }
14
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+
22
+ // Some stricter flags (disabled by default)
23
+ "noUnusedLocals": false,
24
+ "noUnusedParameters": false,
25
+ "noPropertyAccessFromIndexSignature": false
26
+ }
27
+ }
@@ -0,0 +1,15 @@
1
+ # entity-spawn
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run index.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.1.26. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
@@ -0,0 +1,11 @@
1
+ For local development self-signed certs are stored here.
2
+ The server when GameServer.instance.webServer.enableLocalSSL();
3
+ is used, will look for assets/certs/localhost.key and
4
+ assets/certs/localhost.cert and use those for SSL.
5
+
6
+ We use these self-signed certs to allow https://localhost
7
+ & wss://localhost support. Without this, play.hytopia.com
8
+ requires a bunch of funky browser flag workarounds in
9
+ order to connect to your local server. This is only used
10
+ for local development and will be ignored when your game
11
+ is deployed to HYTOPIA servers.
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDRjCCAi6gAwIBAgIFOTEzNTIwDQYJKoZIhvcNAQELBQAwWDE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