hytopia 0.1.75 → 0.1.77

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.
@@ -98,8 +98,8 @@ function onPlayerJoin(world: World, player: Player) {
98
98
  playerEntity.spawn(world, GAME_CONFIG.POSITIONS.PLAYER_SPAWN);
99
99
 
100
100
  playerEntity.setCollisionGroupsForSolidColliders({
101
- belongsTo: [CollisionGroup.ENTITY, CollisionGroup.PLAYER],
102
- collidesWith: [CollisionGroup.BLOCK, CollisionGroup.ENTITY_SENSOR, GAME_CONFIG.WALL_COLLISION_GROUP],
101
+ belongsTo: [CollisionGroup.PLAYER],
102
+ collidesWith: [CollisionGroup.BLOCK, CollisionGroup.ENTITY, CollisionGroup.ENTITY_SENSOR, GAME_CONFIG.WALL_COLLISION_GROUP],
103
103
  });
104
104
 
105
105
  playerEntity.setCollisionGroupsForSensorColliders({
@@ -115,7 +115,7 @@ function onPlayerJoin(world: World, player: Player) {
115
115
  }
116
116
 
117
117
  function onPlayerLeave(world: World, player: Player) {
118
- world.entityManager.getAllPlayerEntities(player).forEach(entity => {
118
+ world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => {
119
119
  removePlayerFromQueue(entity);
120
120
  killPlayer(entity);
121
121
  entity.despawn();
@@ -109,7 +109,7 @@ startServer(world => {
109
109
 
110
110
  // Despawn all player entities when a player leaves the game.
111
111
  world.onPlayerLeave = player => {
112
- world.entityManager.getAllPlayerEntities(player).forEach(entity => entity.despawn());
112
+ world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => entity.despawn());
113
113
  };
114
114
 
115
115
  // Play some music on game start
@@ -151,7 +151,7 @@ startServer(world => { // Perform our game setup logic in the startServer init c
151
151
  // We apply a translation prior to despawn because of a bug in the RAPIER
152
152
  // physics engine we use where entities despawned to not trigger a collision
153
153
  // event for leaving a sensor. This is a workaround till a better solution is found.
154
- world.entityManager.getAllPlayerEntities(player).forEach(entity => {
154
+ world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => {
155
155
  entity.setPosition({ x: 0, y: 100, z: 0 });
156
156
  setTimeout(() => entity.despawn(), 50); // Despawn after a short delay so we step the physics after translating it so leaving the sensor registers.
157
157
  });
@@ -277,7 +277,7 @@ function onPlayerJoin(world: World, player: Player) {
277
277
  * cleanup when they leave the game.
278
278
  */
279
279
  function onPlayerLeave(world: World, player: Player) {
280
- world.entityManager.getAllPlayerEntities(player).forEach(entity => {
280
+ world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => {
281
281
  endGame(entity); // explicitly end their game if they leave
282
282
  entity.despawn(); // despawn their entity
283
283
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.1.75",
3
+ "version": "0.1.77",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.api.json CHANGED
@@ -7626,7 +7626,7 @@
7626
7626
  {
7627
7627
  "kind": "Method",
7628
7628
  "canonicalReference": "server!Collider#setRelativePosition:member(1)",
7629
- "docComment": "/**\n * Sets the relative position of the collider to its parent rigid body.\n *\n * @param position - The relative position of the collider.\n */\n",
7629
+ "docComment": "/**\n * Sets the position of the collider relative to its parent rigid body or the world origin.\n *\n * @remarks\n *\n * Colliders can be added as a child of a rigid body, or to the world directly. This position is relative to the parent rigid body or the world origin.\n *\n * @param position - The relative position of the collider.\n */\n",
7630
7630
  "excerptTokens": [
7631
7631
  {
7632
7632
  "kind": "Content",
@@ -7675,7 +7675,7 @@
7675
7675
  {
7676
7676
  "kind": "Method",
7677
7677
  "canonicalReference": "server!Collider#setRelativeRotation:member(1)",
7678
- "docComment": "/**\n * Sets the relative rotation of the collider.\n *\n * @param rotation - The relative rotation of the collider.\n */\n",
7678
+ "docComment": "/**\n * Sets the relative rotation of the collider to its parent rigid body or the world origin.\n *\n * @remarks\n *\n * Colliders can be added as a child of a rigid body, or to the world directly. This rotation is relative to the parent rigid body or the world origin.\n *\n * @param rotation - The relative rotation of the collider.\n */\n",
7679
7679
  "excerptTokens": [
7680
7680
  {
7681
7681
  "kind": "Content",
@@ -12080,20 +12080,11 @@
12080
12080
  {
12081
12081
  "kind": "Method",
12082
12082
  "canonicalReference": "server!EntityManager#getAllPlayerEntities:member(1)",
12083
- "docComment": "/**\n * Gets all spawned entities in the world assigned to a player.\n *\n * @param player - The player to get the entities for.\n *\n * @returns All spawned entities in the world assigned to the player.\n */\n",
12083
+ "docComment": "/**\n * Gets all spawned player entities in the world.\n *\n * @returns All spawned player entities in the world.\n */\n",
12084
12084
  "excerptTokens": [
12085
12085
  {
12086
12086
  "kind": "Content",
12087
- "text": "getAllPlayerEntities(player: "
12088
- },
12089
- {
12090
- "kind": "Reference",
12091
- "text": "Player",
12092
- "canonicalReference": "server!Player:class"
12093
- },
12094
- {
12095
- "kind": "Content",
12096
- "text": "): "
12087
+ "text": "getAllPlayerEntities(): "
12097
12088
  },
12098
12089
  {
12099
12090
  "kind": "Reference",
@@ -12111,22 +12102,13 @@
12111
12102
  ],
12112
12103
  "isStatic": false,
12113
12104
  "returnTypeTokenRange": {
12114
- "startIndex": 3,
12115
- "endIndex": 5
12105
+ "startIndex": 1,
12106
+ "endIndex": 3
12116
12107
  },
12117
12108
  "releaseTag": "Public",
12118
12109
  "isProtected": false,
12119
12110
  "overloadIndex": 1,
12120
- "parameters": [
12121
- {
12122
- "parameterName": "player",
12123
- "parameterTypeTokenRange": {
12124
- "startIndex": 1,
12125
- "endIndex": 2
12126
- },
12127
- "isOptional": false
12128
- }
12129
- ],
12111
+ "parameters": [],
12130
12112
  "isOptional": false,
12131
12113
  "isAbstract": false,
12132
12114
  "name": "getAllPlayerEntities"
@@ -12307,6 +12289,60 @@
12307
12289
  "isAbstract": false,
12308
12290
  "name": "getEntity"
12309
12291
  },
12292
+ {
12293
+ "kind": "Method",
12294
+ "canonicalReference": "server!EntityManager#getPlayerEntitiesByPlayer:member(1)",
12295
+ "docComment": "/**\n * Gets all spawned entities in the world assigned to the provided player.\n *\n * @param player - The player to get the entities for.\n *\n * @returns All spawned entities in the world assigned to the player.\n */\n",
12296
+ "excerptTokens": [
12297
+ {
12298
+ "kind": "Content",
12299
+ "text": "getPlayerEntitiesByPlayer(player: "
12300
+ },
12301
+ {
12302
+ "kind": "Reference",
12303
+ "text": "Player",
12304
+ "canonicalReference": "server!Player:class"
12305
+ },
12306
+ {
12307
+ "kind": "Content",
12308
+ "text": "): "
12309
+ },
12310
+ {
12311
+ "kind": "Reference",
12312
+ "text": "PlayerEntity",
12313
+ "canonicalReference": "server!PlayerEntity:class"
12314
+ },
12315
+ {
12316
+ "kind": "Content",
12317
+ "text": "[]"
12318
+ },
12319
+ {
12320
+ "kind": "Content",
12321
+ "text": ";"
12322
+ }
12323
+ ],
12324
+ "isStatic": false,
12325
+ "returnTypeTokenRange": {
12326
+ "startIndex": 3,
12327
+ "endIndex": 5
12328
+ },
12329
+ "releaseTag": "Public",
12330
+ "isProtected": false,
12331
+ "overloadIndex": 1,
12332
+ "parameters": [
12333
+ {
12334
+ "parameterName": "player",
12335
+ "parameterTypeTokenRange": {
12336
+ "startIndex": 1,
12337
+ "endIndex": 2
12338
+ },
12339
+ "isOptional": false
12340
+ }
12341
+ ],
12342
+ "isOptional": false,
12343
+ "isAbstract": false,
12344
+ "name": "getPlayerEntitiesByPlayer"
12345
+ },
12310
12346
  {
12311
12347
  "kind": "Property",
12312
12348
  "canonicalReference": "server!EntityManager#world:member",
@@ -16956,7 +16992,7 @@
16956
16992
  {
16957
16993
  "kind": "Property",
16958
16994
  "canonicalReference": "server!Player#id:member",
16959
- "docComment": "/**\n * The unique identifier for the player.\n */\n",
16995
+ "docComment": "/**\n * The unique HYTOPIA UUID for the player.\n */\n",
16960
16996
  "excerptTokens": [
16961
16997
  {
16962
16998
  "kind": "Content",
@@ -16964,7 +17000,7 @@
16964
17000
  },
16965
17001
  {
16966
17002
  "kind": "Content",
16967
- "text": "number"
17003
+ "text": "string"
16968
17004
  },
16969
17005
  {
16970
17006
  "kind": "Content",
@@ -17128,7 +17164,7 @@
17128
17164
  {
17129
17165
  "kind": "Property",
17130
17166
  "canonicalReference": "server!Player#username:member",
17131
- "docComment": "/**\n * The username for the player.\n */\n",
17167
+ "docComment": "/**\n * The unique HYTOPIA username for the player.\n */\n",
17132
17168
  "excerptTokens": [
17133
17169
  {
17134
17170
  "kind": "Content",
@@ -21212,6 +21248,60 @@
21212
21248
  "isAbstract": false,
21213
21249
  "name": "getConnectedPlayers"
21214
21250
  },
21251
+ {
21252
+ "kind": "Method",
21253
+ "canonicalReference": "server!PlayerManager#getConnectedPlayersByWorld:member(1)",
21254
+ "docComment": "/**\n * Get all connected players in a specific world.\n *\n * @param world - The world to get connected players for.\n *\n * @returns An array of all connected players in the world.\n */\n",
21255
+ "excerptTokens": [
21256
+ {
21257
+ "kind": "Content",
21258
+ "text": "getConnectedPlayersByWorld(world: "
21259
+ },
21260
+ {
21261
+ "kind": "Reference",
21262
+ "text": "World",
21263
+ "canonicalReference": "server!World:class"
21264
+ },
21265
+ {
21266
+ "kind": "Content",
21267
+ "text": "): "
21268
+ },
21269
+ {
21270
+ "kind": "Reference",
21271
+ "text": "Player",
21272
+ "canonicalReference": "server!Player:class"
21273
+ },
21274
+ {
21275
+ "kind": "Content",
21276
+ "text": "[]"
21277
+ },
21278
+ {
21279
+ "kind": "Content",
21280
+ "text": ";"
21281
+ }
21282
+ ],
21283
+ "isStatic": false,
21284
+ "returnTypeTokenRange": {
21285
+ "startIndex": 3,
21286
+ "endIndex": 5
21287
+ },
21288
+ "releaseTag": "Public",
21289
+ "isProtected": false,
21290
+ "overloadIndex": 1,
21291
+ "parameters": [
21292
+ {
21293
+ "parameterName": "world",
21294
+ "parameterTypeTokenRange": {
21295
+ "startIndex": 1,
21296
+ "endIndex": 2
21297
+ },
21298
+ "isOptional": false
21299
+ }
21300
+ ],
21301
+ "isOptional": false,
21302
+ "isAbstract": false,
21303
+ "name": "getConnectedPlayersByWorld"
21304
+ },
21215
21305
  {
21216
21306
  "kind": "Property",
21217
21307
  "canonicalReference": "server!PlayerManager.instance:member",
@@ -28037,6 +28127,59 @@
28037
28127
  "isAbstract": false,
28038
28128
  "name": "getAllSceneUIs"
28039
28129
  },
28130
+ {
28131
+ "kind": "Method",
28132
+ "canonicalReference": "server!SceneUIManager#getSceneUIById:member(1)",
28133
+ "docComment": "/**\n * Retrieves a SceneUI instance by its unique identifier (id).\n *\n * @param id - The unique identifier (id) of the SceneUI to retrieve.\n *\n * @returns The SceneUI instance if found, otherwise undefined.\n */\n",
28134
+ "excerptTokens": [
28135
+ {
28136
+ "kind": "Content",
28137
+ "text": "getSceneUIById(id: "
28138
+ },
28139
+ {
28140
+ "kind": "Content",
28141
+ "text": "number"
28142
+ },
28143
+ {
28144
+ "kind": "Content",
28145
+ "text": "): "
28146
+ },
28147
+ {
28148
+ "kind": "Reference",
28149
+ "text": "SceneUI",
28150
+ "canonicalReference": "server!SceneUI:class"
28151
+ },
28152
+ {
28153
+ "kind": "Content",
28154
+ "text": " | undefined"
28155
+ },
28156
+ {
28157
+ "kind": "Content",
28158
+ "text": ";"
28159
+ }
28160
+ ],
28161
+ "isStatic": false,
28162
+ "returnTypeTokenRange": {
28163
+ "startIndex": 3,
28164
+ "endIndex": 5
28165
+ },
28166
+ "releaseTag": "Public",
28167
+ "isProtected": false,
28168
+ "overloadIndex": 1,
28169
+ "parameters": [
28170
+ {
28171
+ "parameterName": "id",
28172
+ "parameterTypeTokenRange": {
28173
+ "startIndex": 1,
28174
+ "endIndex": 2
28175
+ },
28176
+ "isOptional": false
28177
+ }
28178
+ ],
28179
+ "isOptional": false,
28180
+ "isAbstract": false,
28181
+ "name": "getSceneUIById"
28182
+ },
28040
28183
  {
28041
28184
  "kind": "Method",
28042
28185
  "canonicalReference": "server!SceneUIManager#unloadEntityAttachedSceneUIs:member(1)",
package/server.d.ts CHANGED
@@ -983,12 +983,22 @@ export declare class Collider {
983
983
  */
984
984
  setOnCollision(callback: CollisionCallback | undefined): void;
985
985
  /**
986
- * Sets the relative rotation of the collider.
986
+ * Sets the relative rotation of the collider to its parent rigid body or the world origin.
987
+ *
988
+ * @remarks
989
+ * Colliders can be added as a child of a rigid body, or to the world directly. This rotation
990
+ * is relative to the parent rigid body or the world origin.
991
+ *
987
992
  * @param rotation - The relative rotation of the collider.
988
993
  */
989
994
  setRelativeRotation(rotation: QuaternionLike): void;
990
995
  /**
991
- * Sets the relative position of the collider to its parent rigid body.
996
+ * Sets the position of the collider relative to its parent rigid body or the world origin.
997
+ *
998
+ * @remarks
999
+ * Colliders can be added as a child of a rigid body, or to the world directly. This position
1000
+ * is relative to the parent rigid body or the world origin.
1001
+ *
992
1002
  * @param position - The relative position of the collider.
993
1003
  */
994
1004
  setRelativePosition(position: Vector3Like): void;
@@ -1564,11 +1574,16 @@ export declare class EntityManager {
1564
1574
  */
1565
1575
  getAllEntities(): Entity[];
1566
1576
  /**
1567
- * Gets all spawned entities in the world assigned to a player.
1577
+ * Gets all spawned player entities in the world.
1578
+ * @returns All spawned player entities in the world.
1579
+ */
1580
+ getAllPlayerEntities(): PlayerEntity[];
1581
+ /**
1582
+ * Gets all spawned entities in the world assigned to the provided player.
1568
1583
  * @param player - The player to get the entities for.
1569
1584
  * @returns All spawned entities in the world assigned to the player.
1570
1585
  */
1571
- getAllPlayerEntities(player: Player): PlayerEntity[];
1586
+ getPlayerEntitiesByPlayer(player: Player): PlayerEntity[];
1572
1587
  /**
1573
1588
  * Gets a spawned entity in the world by its id.
1574
1589
  * @param id - The id of the entity to get.
@@ -2157,9 +2172,9 @@ export declare type MoveOptions = {
2157
2172
  * @public
2158
2173
  */
2159
2174
  export declare class Player {
2160
- /** The unique identifier for the player. */
2161
- readonly id: number;
2162
- /** The username for the player. */
2175
+ /** The unique HYTOPIA UUID for the player. */
2176
+ readonly id: string;
2177
+ /** The unique HYTOPIA username for the player. */
2163
2178
  readonly username: string;
2164
2179
  /** The camera for the player. */
2165
2180
  readonly camera: PlayerCamera;
@@ -2640,6 +2655,12 @@ export declare class PlayerManager {
2640
2655
  * @returns An array of all connected players.
2641
2656
  */
2642
2657
  getConnectedPlayers(): Player[];
2658
+ /**
2659
+ * Get all connected players in a specific world.
2660
+ * @param world - The world to get connected players for.
2661
+ * @returns An array of all connected players in the world.
2662
+ */
2663
+ getConnectedPlayersByWorld(world: World): Player[];
2643
2664
  /**
2644
2665
  * Get a connected player by their username (case insensitive).
2645
2666
  * @param username - The username of the player to get.
@@ -3438,6 +3459,13 @@ export declare class SceneUIManager {
3438
3459
  * @returns An array of SceneUI instances.
3439
3460
  */
3440
3461
  getAllEntityAttachedSceneUIs(entity: Entity): SceneUI[];
3462
+ /**
3463
+ * Retrieves a SceneUI instance by its unique identifier (id).
3464
+ *
3465
+ * @param id - The unique identifier (id) of the SceneUI to retrieve.
3466
+ * @returns The SceneUI instance if found, otherwise undefined.
3467
+ */
3468
+ getSceneUIById(id: number): SceneUI | undefined;
3441
3469
 
3442
3470
  /**
3443
3471
  * Unloads and unregisters all SceneUI instances attached to a specific entity.