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.
- package/boilerplate/index.ts +2 -2
- package/docs/server.collider.md +2 -2
- package/docs/server.collider.setrelativeposition.md +5 -1
- package/docs/server.collider.setrelativerotation.md +5 -1
- package/docs/server.entitymanager.getallplayerentities.md +3 -39
- package/docs/server.entitymanager.getplayerentitiesbyplayer.md +55 -0
- package/docs/server.entitymanager.md +16 -2
- package/docs/server.player.id.md +2 -2
- package/docs/server.player.md +3 -3
- package/docs/server.player.username.md +1 -1
- package/docs/server.playermanager.getconnectedplayersbyworld.md +55 -0
- package/docs/server.playermanager.md +14 -0
- package/docs/server.sceneuimanager.getsceneuibyid.md +55 -0
- package/docs/server.sceneuimanager.md +14 -0
- package/examples/big-world/index.ts +1 -1
- package/examples/block-entity/index.ts +3 -3
- package/examples/custom-ui/assets/ui/index.html +68 -85
- package/examples/custom-ui/index.ts +1 -1
- package/examples/entity-controller/index.ts +1 -1
- package/examples/entity-spawn/index.ts +1 -1
- package/examples/hole-in-wall-game/assets/ui/index.html +2 -1
- package/examples/hole-in-wall-game/index.ts +3 -3
- package/examples/lighting/index.ts +1 -1
- package/examples/payload-game/index.ts +1 -1
- package/examples/wall-dodge-game/index.ts +1 -1
- package/package.json +1 -1
- package/server.api.json +171 -28
- package/server.d.ts +35 -7
- package/server.js +19 -19
package/boilerplate/index.ts
CHANGED
@@ -103,7 +103,7 @@ startServer(world => {
|
|
103
103
|
* instance.
|
104
104
|
*/
|
105
105
|
world.onPlayerLeave = player => {
|
106
|
-
world.entityManager.
|
106
|
+
world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => entity.despawn());
|
107
107
|
};
|
108
108
|
|
109
109
|
/**
|
@@ -111,7 +111,7 @@ startServer(world => {
|
|
111
111
|
* "/rocket" in the game, they'll get launched into the air!
|
112
112
|
*/
|
113
113
|
world.chatManager.registerCommand('/rocket', player => {
|
114
|
-
world.entityManager.
|
114
|
+
world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => {
|
115
115
|
entity.applyImpulse({ x: 0, y: 20, z: 0 });
|
116
116
|
});
|
117
117
|
});
|
package/docs/server.collider.md
CHANGED
@@ -618,7 +618,7 @@ Sets the on collision callback for the collider.
|
|
618
618
|
|
619
619
|
</td><td>
|
620
620
|
|
621
|
-
Sets the
|
621
|
+
Sets the position of the collider relative to its parent rigid body or the world origin.
|
622
622
|
|
623
623
|
|
624
624
|
</td></tr>
|
@@ -632,7 +632,7 @@ Sets the relative position of the collider to its parent rigid body.
|
|
632
632
|
|
633
633
|
</td><td>
|
634
634
|
|
635
|
-
Sets the relative rotation of the collider.
|
635
|
+
Sets the relative rotation of the collider to its parent rigid body or the world origin.
|
636
636
|
|
637
637
|
|
638
638
|
</td></tr>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
## Collider.setRelativePosition() method
|
6
6
|
|
7
|
-
Sets the
|
7
|
+
Sets the position of the collider relative to its parent rigid body or the world origin.
|
8
8
|
|
9
9
|
**Signature:**
|
10
10
|
|
@@ -51,3 +51,7 @@ The relative position of the collider.
|
|
51
51
|
|
52
52
|
void
|
53
53
|
|
54
|
+
## Remarks
|
55
|
+
|
56
|
+
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.
|
57
|
+
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
## Collider.setRelativeRotation() method
|
6
6
|
|
7
|
-
Sets the relative rotation of the collider.
|
7
|
+
Sets the relative rotation of the collider to its parent rigid body or the world origin.
|
8
8
|
|
9
9
|
**Signature:**
|
10
10
|
|
@@ -51,3 +51,7 @@ The relative rotation of the collider.
|
|
51
51
|
|
52
52
|
void
|
53
53
|
|
54
|
+
## Remarks
|
55
|
+
|
56
|
+
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.
|
57
|
+
|
@@ -4,52 +4,16 @@
|
|
4
4
|
|
5
5
|
## EntityManager.getAllPlayerEntities() method
|
6
6
|
|
7
|
-
Gets all spawned entities in the world
|
7
|
+
Gets all spawned player entities in the world.
|
8
8
|
|
9
9
|
**Signature:**
|
10
10
|
|
11
11
|
```typescript
|
12
|
-
getAllPlayerEntities(
|
12
|
+
getAllPlayerEntities(): PlayerEntity[];
|
13
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
|
-
player
|
36
|
-
|
37
|
-
|
38
|
-
</td><td>
|
39
|
-
|
40
|
-
[Player](./server.player.md)
|
41
|
-
|
42
|
-
|
43
|
-
</td><td>
|
44
|
-
|
45
|
-
The player to get the entities for.
|
46
|
-
|
47
|
-
|
48
|
-
</td></tr>
|
49
|
-
</tbody></table>
|
50
14
|
**Returns:**
|
51
15
|
|
52
16
|
[PlayerEntity](./server.playerentity.md)<!-- -->\[\]
|
53
17
|
|
54
|
-
All spawned entities in the world
|
18
|
+
All spawned player entities in the world.
|
55
19
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [EntityManager](./server.entitymanager.md) > [getPlayerEntitiesByPlayer](./server.entitymanager.getplayerentitiesbyplayer.md)
|
4
|
+
|
5
|
+
## EntityManager.getPlayerEntitiesByPlayer() method
|
6
|
+
|
7
|
+
Gets all spawned entities in the world assigned to the provided player.
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
getPlayerEntitiesByPlayer(player: Player): PlayerEntity[];
|
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
|
+
player
|
36
|
+
|
37
|
+
|
38
|
+
</td><td>
|
39
|
+
|
40
|
+
[Player](./server.player.md)
|
41
|
+
|
42
|
+
|
43
|
+
</td><td>
|
44
|
+
|
45
|
+
The player to get the entities for.
|
46
|
+
|
47
|
+
|
48
|
+
</td></tr>
|
49
|
+
</tbody></table>
|
50
|
+
**Returns:**
|
51
|
+
|
52
|
+
[PlayerEntity](./server.playerentity.md)<!-- -->\[\]
|
53
|
+
|
54
|
+
All spawned entities in the world assigned to the player.
|
55
|
+
|
@@ -107,7 +107,7 @@ Gets all spawned entities in the world.
|
|
107
107
|
</td></tr>
|
108
108
|
<tr><td>
|
109
109
|
|
110
|
-
[getAllPlayerEntities(
|
110
|
+
[getAllPlayerEntities()](./server.entitymanager.getallplayerentities.md)
|
111
111
|
|
112
112
|
|
113
113
|
</td><td>
|
@@ -115,7 +115,7 @@ Gets all spawned entities in the world.
|
|
115
115
|
|
116
116
|
</td><td>
|
117
117
|
|
118
|
-
Gets all spawned entities in the world
|
118
|
+
Gets all spawned player entities in the world.
|
119
119
|
|
120
120
|
|
121
121
|
</td></tr>
|
@@ -160,5 +160,19 @@ Gets all spawned entities in the world with a tag that includes a specific subst
|
|
160
160
|
Gets a spawned entity in the world by its id.
|
161
161
|
|
162
162
|
|
163
|
+
</td></tr>
|
164
|
+
<tr><td>
|
165
|
+
|
166
|
+
[getPlayerEntitiesByPlayer(player)](./server.entitymanager.getplayerentitiesbyplayer.md)
|
167
|
+
|
168
|
+
|
169
|
+
</td><td>
|
170
|
+
|
171
|
+
|
172
|
+
</td><td>
|
173
|
+
|
174
|
+
Gets all spawned entities in the world assigned to the provided player.
|
175
|
+
|
176
|
+
|
163
177
|
</td></tr>
|
164
178
|
</tbody></table>
|
package/docs/server.player.id.md
CHANGED
package/docs/server.player.md
CHANGED
@@ -74,12 +74,12 @@ The camera for the player.
|
|
74
74
|
|
75
75
|
</td><td>
|
76
76
|
|
77
|
-
|
77
|
+
string
|
78
78
|
|
79
79
|
|
80
80
|
</td><td>
|
81
81
|
|
82
|
-
The unique
|
82
|
+
The unique HYTOPIA UUID for the player.
|
83
83
|
|
84
84
|
|
85
85
|
</td></tr>
|
@@ -142,7 +142,7 @@ string
|
|
142
142
|
|
143
143
|
</td><td>
|
144
144
|
|
145
|
-
The username for the player.
|
145
|
+
The unique HYTOPIA username for the player.
|
146
146
|
|
147
147
|
|
148
148
|
</td></tr>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [PlayerManager](./server.playermanager.md) > [getConnectedPlayersByWorld](./server.playermanager.getconnectedplayersbyworld.md)
|
4
|
+
|
5
|
+
## PlayerManager.getConnectedPlayersByWorld() method
|
6
|
+
|
7
|
+
Get all connected players in a specific world.
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
getConnectedPlayersByWorld(world: World): Player[];
|
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
|
+
world
|
36
|
+
|
37
|
+
|
38
|
+
</td><td>
|
39
|
+
|
40
|
+
[World](./server.world.md)
|
41
|
+
|
42
|
+
|
43
|
+
</td><td>
|
44
|
+
|
45
|
+
The world to get connected players for.
|
46
|
+
|
47
|
+
|
48
|
+
</td></tr>
|
49
|
+
</tbody></table>
|
50
|
+
**Returns:**
|
51
|
+
|
52
|
+
[Player](./server.player.md)<!-- -->\[\]
|
53
|
+
|
54
|
+
An array of all connected players in the world.
|
55
|
+
|
@@ -121,5 +121,19 @@ Get a connected player by their username (case insensitive).
|
|
121
121
|
Get all connected players.
|
122
122
|
|
123
123
|
|
124
|
+
</td></tr>
|
125
|
+
<tr><td>
|
126
|
+
|
127
|
+
[getConnectedPlayersByWorld(world)](./server.playermanager.getconnectedplayersbyworld.md)
|
128
|
+
|
129
|
+
|
130
|
+
</td><td>
|
131
|
+
|
132
|
+
|
133
|
+
</td><td>
|
134
|
+
|
135
|
+
Get all connected players in a specific world.
|
136
|
+
|
137
|
+
|
124
138
|
</td></tr>
|
125
139
|
</tbody></table>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [SceneUIManager](./server.sceneuimanager.md) > [getSceneUIById](./server.sceneuimanager.getsceneuibyid.md)
|
4
|
+
|
5
|
+
## SceneUIManager.getSceneUIById() method
|
6
|
+
|
7
|
+
Retrieves a SceneUI instance by its unique identifier (id).
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
getSceneUIById(id: number): SceneUI | undefined;
|
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
|
+
id
|
36
|
+
|
37
|
+
|
38
|
+
</td><td>
|
39
|
+
|
40
|
+
number
|
41
|
+
|
42
|
+
|
43
|
+
</td><td>
|
44
|
+
|
45
|
+
The unique identifier (id) of the SceneUI to retrieve.
|
46
|
+
|
47
|
+
|
48
|
+
</td></tr>
|
49
|
+
</tbody></table>
|
50
|
+
**Returns:**
|
51
|
+
|
52
|
+
[SceneUI](./server.sceneui.md) \| undefined
|
53
|
+
|
54
|
+
The SceneUI instance if found, otherwise undefined.
|
55
|
+
|
@@ -109,6 +109,20 @@ Retrieves all loaded SceneUI instances attached to a specific entity.
|
|
109
109
|
Retrieves all loaded SceneUI instances for the world.
|
110
110
|
|
111
111
|
|
112
|
+
</td></tr>
|
113
|
+
<tr><td>
|
114
|
+
|
115
|
+
[getSceneUIById(id)](./server.sceneuimanager.getsceneuibyid.md)
|
116
|
+
|
117
|
+
|
118
|
+
</td><td>
|
119
|
+
|
120
|
+
|
121
|
+
</td><td>
|
122
|
+
|
123
|
+
Retrieves a SceneUI instance by its unique identifier (id).
|
124
|
+
|
125
|
+
|
112
126
|
</td></tr>
|
113
127
|
<tr><td>
|
114
128
|
|
@@ -36,6 +36,6 @@ startServer(world => {
|
|
36
36
|
|
37
37
|
// Despawn all player entities when a player leaves the game.
|
38
38
|
world.onPlayerLeave = player => {
|
39
|
-
world.entityManager.
|
39
|
+
world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => entity.despawn());
|
40
40
|
};
|
41
41
|
});
|
@@ -30,7 +30,7 @@ startServer(world => {
|
|
30
30
|
};
|
31
31
|
|
32
32
|
world.onPlayerLeave = player => {
|
33
|
-
world.entityManager.
|
33
|
+
world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => entity.despawn());
|
34
34
|
};
|
35
35
|
|
36
36
|
/**
|
@@ -41,7 +41,7 @@ startServer(world => {
|
|
41
41
|
blockHalfExtents: { x: 1, y: 0.5, z: 1 },
|
42
42
|
rigidBodyOptions: {
|
43
43
|
type: RigidBodyType.KINEMATIC_VELOCITY, // Kinematic means platform won't be effected by external physics, including gravity
|
44
|
-
linearVelocity: { x: 0, y: 0, z: 3 }, // A starting velocity that won't change because it's kinematic
|
44
|
+
linearVelocity: { x: 0, y: 0, z: 3 }, // A starting velocity that won't change until we change it, because it's kinematic
|
45
45
|
},
|
46
46
|
});
|
47
47
|
|
@@ -162,7 +162,7 @@ startServer(world => {
|
|
162
162
|
const targetPlayer = connectedPlayers[Math.floor(Math.random() * connectedPlayers.length)];
|
163
163
|
|
164
164
|
// get the player's entity
|
165
|
-
const targetPlayerEntity = world.entityManager.
|
165
|
+
const targetPlayerEntity = world.entityManager.getPlayerEntitiesByPlayer(targetPlayer)[0];
|
166
166
|
|
167
167
|
if (!targetPlayerEntity) { return; } // if the player doesn't have an entity, don't pathfind.
|
168
168
|
|
@@ -1,91 +1,74 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<script>
|
2
|
+
// Handle received data from server
|
3
|
+
hytopia.onData(data => {
|
4
|
+
if (data.type === 'playerList') {
|
5
|
+
const { list } = data;
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
with `npm install hytopia-ui` and then import it as
|
10
|
-
`import hytopia from 'hytopia-ui';`
|
11
|
-
-->
|
12
|
-
<script src="https://unpkg.com/hytopia-ui@latest/dist/index.umd.js"></script>
|
7
|
+
// Update player count
|
8
|
+
document.getElementById('player-count').textContent = `Players Connected: ${list.length}`;
|
13
9
|
|
14
|
-
|
15
|
-
document.
|
16
|
-
|
17
|
-
hytopia.ui.onData = data => {
|
18
|
-
if (data.type === 'playerList') {
|
19
|
-
const { list } = data;
|
10
|
+
// Clear and rebuild player list
|
11
|
+
const playerListElement = document.getElementById('player-list');
|
12
|
+
playerListElement.innerHTML = '';
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
// Add each player to the list
|
29
|
-
list.forEach(player => {
|
30
|
-
const pos = player.position;
|
31
|
-
const playerRow = document.createElement('div');
|
32
|
-
playerRow.className = 'player-row';
|
33
|
-
playerRow.textContent = `${player.username}: x:${pos.x.toFixed(1)}, y:${pos.y.toFixed(1)}, z:${pos.z.toFixed(1)}`;
|
34
|
-
playerListElement.appendChild(playerRow);
|
35
|
-
});
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
// Send data to server on teleport btn press
|
40
|
-
document.getElementById('teleport-btn').addEventListener('click', () => {
|
41
|
-
// We can send any arbitrary object to the server. We as the developer define
|
42
|
-
// whatever schema we want to use for data between client and server.
|
43
|
-
// For now we'll just use a "type" property we made up so the server knows
|
44
|
-
// what to do with the data.
|
45
|
-
hytopia.ui.sendData({ type: 'teleport' });
|
46
|
-
});
|
14
|
+
// Add each player to the list
|
15
|
+
list.forEach(player => {
|
16
|
+
const pos = player.position;
|
17
|
+
const playerRow = document.createElement('div');
|
18
|
+
playerRow.className = 'player-row';
|
19
|
+
playerRow.textContent = `${player.username}: x:${pos.x.toFixed(1)}, y:${pos.y.toFixed(1)}, z:${pos.z.toFixed(1)}`;
|
20
|
+
playerListElement.appendChild(playerRow);
|
47
21
|
});
|
48
|
-
|
22
|
+
}
|
23
|
+
});
|
24
|
+
|
25
|
+
// Send data to server on teleport btn press
|
26
|
+
document.getElementById('teleport-btn').addEventListener('click', () => {
|
27
|
+
// We can send any arbitrary object to the server. We as the developer define
|
28
|
+
// whatever schema we want to use for data between client and server.
|
29
|
+
// For now we'll just use a "type" property we made up so the server knows
|
30
|
+
// what to do with the data.
|
31
|
+
hytopia.sendData({ type: 'teleport' });
|
32
|
+
});
|
33
|
+
</script>
|
49
34
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
35
|
+
<div id="player-panel">
|
36
|
+
<div id="player-count">Players Connected: 0</div>
|
37
|
+
<div id="player-list"></div>
|
38
|
+
<button id="teleport-btn">Click to Teleport!</button>
|
39
|
+
</div>
|
55
40
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
</body>
|
91
|
-
</html>
|
41
|
+
<style>
|
42
|
+
#player-panel {
|
43
|
+
position: absolute;
|
44
|
+
right: 20px;
|
45
|
+
top: 20px;
|
46
|
+
background-color: rgba(0, 0, 0, 0.7);
|
47
|
+
color: white;
|
48
|
+
padding: 15px;
|
49
|
+
border-radius: 8px;
|
50
|
+
min-width: 200px;
|
51
|
+
font-family: Arial, sans-serif;
|
52
|
+
letter-spacing: 0.5px;
|
53
|
+
}
|
54
|
+
.player-row {
|
55
|
+
margin: 8px 0;
|
56
|
+
}
|
57
|
+
#teleport-btn {
|
58
|
+
width: 100%;
|
59
|
+
padding: 8px;
|
60
|
+
margin-top: 15px;
|
61
|
+
background-color: #4CAF50;
|
62
|
+
color: white;
|
63
|
+
border: none;
|
64
|
+
border-radius: 4px;
|
65
|
+
cursor: pointer;
|
66
|
+
font-family: Arial, sans-serif;
|
67
|
+
font-weight: bold;
|
68
|
+
text-transform: uppercase;
|
69
|
+
letter-spacing: 1px;
|
70
|
+
}
|
71
|
+
#teleport-btn:hover {
|
72
|
+
background-color: #45a049;
|
73
|
+
}
|
74
|
+
</style>
|
@@ -51,7 +51,7 @@ startServer(world => {
|
|
51
51
|
};
|
52
52
|
|
53
53
|
world.onPlayerLeave = player => {
|
54
|
-
world.entityManager.
|
54
|
+
world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => entity.despawn());
|
55
55
|
// Remove the player entity from our map for our list.
|
56
56
|
playerEntityMap.delete(player);
|
57
57
|
};
|
@@ -33,6 +33,6 @@ startServer(world => {
|
|
33
33
|
};
|
34
34
|
|
35
35
|
world.onPlayerLeave = player => {
|
36
|
-
world.entityManager.
|
36
|
+
world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => entity.despawn());
|
37
37
|
};
|
38
38
|
});
|
@@ -80,6 +80,6 @@ function setup(world: World) {
|
|
80
80
|
|
81
81
|
// Despawn all player entities when a player leaves the game.
|
82
82
|
world.onPlayerLeave = player => {
|
83
|
-
world.entityManager.
|
83
|
+
world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => entity.despawn());
|
84
84
|
};
|
85
85
|
}
|
@@ -62,10 +62,11 @@
|
|
62
62
|
const gameCountdownStartTime = data.gameCountdownStartTime;
|
63
63
|
const countdownSeconds = data.countdown;
|
64
64
|
|
65
|
+
let timeLeft = countdownSeconds;
|
65
66
|
const updateCountdown = () => {
|
66
67
|
if (timeLeft > 0 && gameState === 'starting') {
|
67
68
|
const now = Date.now();
|
68
|
-
|
69
|
+
timeLeft = Math.max(0, Math.ceil((gameCountdownStartTime + (countdownSeconds * 1000) - now) / 1000));
|
69
70
|
updateGameStatus(`GAME STARTING IN ${timeLeft}...`);
|
70
71
|
setTimeout(updateCountdown, 1000);
|
71
72
|
}
|