hytopia 0.1.97 → 0.1.99

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.
Files changed (76) hide show
  1. package/docs/server.entity.height.md +13 -0
  2. package/docs/server.entity.md +22 -1
  3. package/docs/server.entity.opacity.md +1 -1
  4. package/docs/server.modelregistry.getheight.md +55 -0
  5. package/docs/server.modelregistry.md +14 -0
  6. package/examples/ai-agents/package.json +2 -2
  7. package/examples/big-world/package.json +2 -2
  8. package/examples/block-entity/package.json +2 -2
  9. package/examples/child-entity/package.json +2 -2
  10. package/examples/custom-ui/package.json +2 -2
  11. package/examples/entity-spawn/package.json +1 -1
  12. package/examples/hole-in-wall-game/package.json +2 -2
  13. package/examples/lighting/package.json +3 -2
  14. package/examples/pathfinding/index.ts +4 -4
  15. package/examples/pathfinding/package.json +2 -2
  16. package/examples/payload-game/index.ts +12 -10
  17. package/examples/payload-game/package.json +3 -2
  18. package/examples/wall-dodge-game/package.json +2 -2
  19. package/examples/zombies-fps/assets/audio/music/bg.mp3 +0 -0
  20. package/examples/zombies-fps/assets/audio/sfx/pistol-reload.mp3 +0 -0
  21. package/examples/zombies-fps/assets/audio/sfx/pistol-shoot.mp3 +0 -0
  22. package/examples/zombies-fps/assets/audio/sfx/player-hurt.mp3 +0 -0
  23. package/examples/zombies-fps/assets/audio/sfx/purchase.mp3 +0 -0
  24. package/examples/zombies-fps/assets/audio/sfx/rifle-reload.mp3 +0 -0
  25. package/examples/zombies-fps/assets/audio/sfx/rifle-shoot.mp3 +0 -0
  26. package/examples/zombies-fps/assets/audio/sfx/ripper-idle.mp3 +0 -0
  27. package/examples/zombies-fps/assets/audio/sfx/roulette.mp3 +0 -0
  28. package/examples/zombies-fps/assets/audio/sfx/shotgun-reload.mp3 +0 -0
  29. package/examples/zombies-fps/assets/audio/sfx/shotgun-shoot.mp3 +0 -0
  30. package/examples/zombies-fps/assets/audio/sfx/wave-start.mp3 +0 -0
  31. package/examples/zombies-fps/assets/audio/sfx/zombie-idle.mp3 +0 -0
  32. package/examples/zombies-fps/assets/icons/ak-47.png +0 -0
  33. package/examples/zombies-fps/assets/icons/ar-15.png +0 -0
  34. package/examples/zombies-fps/assets/icons/auto-pistol.png +0 -0
  35. package/examples/zombies-fps/assets/icons/auto-shotgun.png +0 -0
  36. package/examples/zombies-fps/assets/icons/heart.png +0 -0
  37. package/examples/zombies-fps/assets/icons/pistol.png +0 -0
  38. package/examples/zombies-fps/assets/icons/shotgun.png +0 -0
  39. package/examples/zombies-fps/assets/models/environment/bombbox.gltf +1 -0
  40. package/examples/zombies-fps/assets/models/environment/bullet-hole.gltf +1 -0
  41. package/examples/zombies-fps/assets/models/environment/healthkit.gltf +1 -0
  42. package/examples/zombies-fps/assets/models/environment/muzzle-flash.gltf +1 -0
  43. package/examples/zombies-fps/assets/models/items/ak-47.glb +0 -0
  44. package/examples/zombies-fps/assets/models/items/ar-15.glb +0 -0
  45. package/examples/zombies-fps/assets/models/items/auto-pistol.glb +0 -0
  46. package/examples/zombies-fps/assets/models/items/auto-shotgun.glb +0 -0
  47. package/examples/zombies-fps/assets/models/items/shotgun.glb +0 -0
  48. package/examples/zombies-fps/assets/models/npcs/ripper-boss.gltf +1 -0
  49. package/examples/zombies-fps/assets/models/players/soldier-player.gltf +1 -1
  50. package/examples/zombies-fps/assets/models/projectiles/bullet-trace.gltf +1 -0
  51. package/examples/zombies-fps/assets/ui/index.html +620 -27
  52. package/examples/zombies-fps/classes/EnemyEntity.ts +183 -4
  53. package/examples/zombies-fps/classes/GameManager.ts +165 -0
  54. package/examples/zombies-fps/classes/GamePlayerEntity.ts +263 -14
  55. package/examples/zombies-fps/classes/GunEntity.ts +225 -13
  56. package/examples/zombies-fps/classes/InteractableEntity.ts +9 -0
  57. package/examples/zombies-fps/classes/PurchaseBarrierEntity.ts +70 -17
  58. package/examples/zombies-fps/classes/WeaponCrateEntity.ts +173 -0
  59. package/examples/zombies-fps/classes/enemies/RipperEntity.ts +67 -0
  60. package/examples/zombies-fps/classes/enemies/ZombieEntity.ts +30 -0
  61. package/examples/zombies-fps/classes/guns/AK47Entity.ts +43 -0
  62. package/examples/zombies-fps/classes/guns/AR15Entity.ts +32 -0
  63. package/examples/zombies-fps/classes/guns/AutoPistolEntity.ts +36 -0
  64. package/examples/zombies-fps/classes/guns/AutoShotgunEntity.ts +37 -0
  65. package/examples/zombies-fps/classes/guns/PistolEntity.ts +23 -15
  66. package/examples/zombies-fps/classes/guns/ShotgunEntity.ts +92 -0
  67. package/examples/zombies-fps/gameConfig.ts +125 -21
  68. package/examples/zombies-fps/index.ts +14 -31
  69. package/examples/zombies-fps/package.json +2 -2
  70. package/package.json +1 -1
  71. package/server.api.json +79 -1
  72. package/server.d.ts +12 -1
  73. package/server.js +91 -89
  74. package/examples/zombies-fps/assets/audio/sfx/pistol-shoot-1.mp3 +0 -0
  75. package/examples/zombies-fps/assets/audio/sfx/pistol-shoot-2.mp3 +0 -0
  76. package/examples/zombies-fps/classes/guns/BulletEntity.ts +0 -0
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [Entity](./server.entity.md) &gt; [height](./server.entity.height.md)
4
+
5
+ ## Entity.height property
6
+
7
+ The height of the entity's model or block entity's y\*2 half extents.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ get height(): number;
13
+ ```
@@ -164,6 +164,27 @@ The URI or path to the texture to be used, if this is set, the entity is a block
164
164
  The controller for the entity.
165
165
 
166
166
 
167
+ </td></tr>
168
+ <tr><td>
169
+
170
+ [height](./server.entity.height.md)
171
+
172
+
173
+ </td><td>
174
+
175
+ `readonly`
176
+
177
+
178
+ </td><td>
179
+
180
+ number
181
+
182
+
183
+ </td><td>
184
+
185
+ The height of the entity's model or block entity's y\*2 half extents.
186
+
187
+
167
188
  </td></tr>
168
189
  <tr><td>
169
190
 
@@ -520,7 +541,7 @@ _(Optional)_ A function that is called every tick.
520
541
 
521
542
  </td><td>
522
543
 
523
- number \| undefined
544
+ number
524
545
 
525
546
 
526
547
  </td><td>
@@ -9,5 +9,5 @@ The opacity of the entity between 0 and 1. 0 is fully transparent, 1 is fully op
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- get opacity(): number | undefined;
12
+ get opacity(): number;
13
13
  ```
@@ -0,0 +1,55 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [ModelRegistry](./server.modelregistry.md) &gt; [getHeight](./server.modelregistry.getheight.md)
4
+
5
+ ## ModelRegistry.getHeight() method
6
+
7
+ Retrieves the Y-axis height of a model for a scale of 1.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ getHeight(modelUri: string): number;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ modelUri
36
+
37
+
38
+ </td><td>
39
+
40
+ string
41
+
42
+
43
+ </td><td>
44
+
45
+ The URI of the model to retrieve the height for.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+ **Returns:**
51
+
52
+ number
53
+
54
+ The height of the model.
55
+
@@ -107,6 +107,20 @@ Description
107
107
  Retrieves the bounding box of a model.
108
108
 
109
109
 
110
+ </td></tr>
111
+ <tr><td>
112
+
113
+ [getHeight(modelUri)](./server.modelregistry.getheight.md)
114
+
115
+
116
+ </td><td>
117
+
118
+
119
+ </td><td>
120
+
121
+ Retrieves the Y-axis height of a model for a scale of 1.
122
+
123
+
110
124
  </td></tr>
111
125
  <tr><td>
112
126
 
@@ -9,8 +9,8 @@
9
9
  "typescript": "^5.0.0"
10
10
  },
11
11
  "dependencies": {
12
- "@hytopia.com/assets": "^0.2.5",
13
- "hytopia": "^0.1.86",
12
+ "@hytopia.com/assets": "latest",
13
+ "hytopia": "latest",
14
14
  "openai": "^4.77.3"
15
15
  }
16
16
  }
@@ -9,7 +9,7 @@
9
9
  "author": "",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@hytopia.com/assets": "^0.2.5",
13
- "hytopia": "^0.1.86"
12
+ "@hytopia.com/assets": "latest",
13
+ "hytopia": "latest"
14
14
  }
15
15
  }
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@hytopia.com/assets": "^0.2.5",
14
- "hytopia": "^0.1.86"
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
15
  }
16
16
  }
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@hytopia.com/assets": "^0.2.5",
14
- "hytopia": "^0.1.86"
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
15
  }
16
16
  }
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@hytopia.com/assets": "^0.2.5",
14
- "hytopia": "^0.1.86"
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
15
  }
16
16
  }
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@hytopia.com/assets": "^0.2.5",
13
+ "@hytopia.com/assets": "latest",
14
14
  "hytopia": "latest"
15
15
  }
16
16
  }
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@hytopia.com/assets": "^0.2.5",
14
- "hytopia": "^0.1.86"
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
15
  }
16
16
  }
@@ -10,7 +10,8 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@hytopia.com/assets": "^0.2.5",
14
- "hytopia": "^0.1.86"
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
+
15
16
  }
16
17
  }
@@ -47,9 +47,9 @@ startServer(world => {
47
47
  // .pathfind() is synchronous and returns immediately soon as a path is found or not, but before the entity has reached the target.
48
48
  const succeeded = pathfindingController.pathfind(playerPosition, 3, { // all possible options for example
49
49
  debug: true, // Setting true will console log pathfinding result info
50
- maxFall: 10, // The maximum fall distance (in blocks) the entity can fall when considering a path.
51
- maxJump: 1, // The maximum height (in blocks) the entity will jump when considering a path, the controller will apply the jumps automatically while pathfinding.
52
- maxOpenSetIterations: 100, // A performance optimization value. A lower value will make pathfinding faster but may fail for longer paths, a higher value can make pathfinding take longer but will work better for longer paths.
50
+ maxFall: 5, // The maximum fall distance (in blocks) the entity can fall when considering a path.
51
+ maxJump: 2, // The maximum height (in blocks) the entity will jump when considering a path, the controller will apply the jumps automatically while pathfinding.
52
+ maxOpenSetIterations: 400, // A performance optimization value. A lower value will make pathfinding faster but may fail for longer paths, a higher value can make pathfinding take longer but will work better for longer paths.
53
53
  verticalPenalty: -1, // A behavior control. The more negative the value, the more the entity will prefer taking a route that requires jumping and falling, even going out of its way to do so. A more positive value will prefer avoiding jumps and falls unless absolutely necessary.
54
54
  pathfindAbortCallback: () => { // Invoked when maxOpenSetIterations is reached and pathfinding aborts.
55
55
  console.log('Pathfinding aborted');
@@ -85,7 +85,7 @@ startServer(world => {
85
85
  },
86
86
  });
87
87
 
88
- pathfindMarker.spawn(world, { x: waypoint.x, y: waypoint.y + 0.25, z: waypoint.z });
88
+ pathfindMarker.spawn(world, waypoint);
89
89
 
90
90
  pathfindMarkers.push(pathfindMarker);
91
91
  });
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@hytopia.com/assets": "^0.2.5",
14
- "hytopia": "^0.1.86"
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
15
  }
16
16
  }
@@ -147,13 +147,8 @@ startServer(world => { // Perform our game setup logic in the startServer init c
147
147
 
148
148
  // Setup Player Leave & Despawn Controlled Entity
149
149
  world.onPlayerLeave = player => {
150
- // Despawn all player entities for the player that left
151
- // We apply a translation prior to despawn because of a bug in the RAPIER
152
- // physics engine we use where entities despawned to not trigger a collision
153
- // event for leaving a sensor. This is a workaround till a better solution is found.
154
150
  world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => {
155
- entity.setPosition({ x: 0, y: 100, z: 0 });
156
- setTimeout(() => entity.despawn(), 50); // Despawn after a short delay so we step the physics after translating it so leaving the sensor registers.
151
+ entity.despawn();
157
152
  });
158
153
 
159
154
  playerCount--;
@@ -225,6 +220,12 @@ function spawnBullet(world: World, coordinate: Vector3Like, direction: Vector3Li
225
220
  z: direction.z * BULLET_SPEED,
226
221
  },
227
222
  rotation: getRotationFromDirection(direction), // Get the rotation from the direction vector so it's facing the right way we shot it
223
+ colliders: [
224
+ {
225
+ ...Collider.optionsFromModelUri('models/bullet.gltf', 0.3),
226
+ isSensor: true,
227
+ }
228
+ ]
228
229
  },
229
230
  });
230
231
 
@@ -255,9 +256,8 @@ function spawnBullet(world: World, coordinate: Vector3Like, direction: Vector3Li
255
256
  });
256
257
 
257
258
  if (enemyHealth[otherEntity.id!] <= 0) {
258
- // YEET the spider before despawning it so it registers leaving the sensor
259
- otherEntity.setPosition({ x: 0, y: 100, z: 0 });
260
- setTimeout(() => { otherEntity.despawn(); }, 50); // Despawn after a short delay so we step the physics after translating it so leaving the sensor registers.
259
+ console.log('bullet killed spider, despawning spider..');
260
+ otherEntity.despawn();
261
261
  }
262
262
 
263
263
  bullet.despawn();
@@ -306,8 +306,10 @@ function spawnPayloadEntity(world: World) {
306
306
  onCollision: (other: BlockType | Entity, started: boolean) => {
307
307
  if (other instanceof PlayerEntity) {
308
308
  started ? payloadPlayerEntityCount++ : payloadPlayerEntityCount--;
309
- } else if (other instanceof Entity) {
309
+ console.log('player count change', payloadPlayerEntityCount, started, other.name);
310
+ } else if (other instanceof Entity && other.name === 'Spider') {
310
311
  started ? payloadPlayerEntityCount-- : payloadPlayerEntityCount++;
312
+ console.log('ENTITY count change', payloadPlayerEntityCount, started, other.name);
311
313
  }
312
314
  },
313
315
  },
@@ -10,7 +10,8 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@hytopia.com/assets": "^0.2.5",
14
- "hytopia": "^0.1.86"
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
+
15
16
  }
16
17
  }
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@hytopia.com/assets": "^0.2.5",
14
- "hytopia": "^0.1.86"
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
15
  }
16
16
  }