@hytopia.com/examples 1.0.54 → 1.0.56

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.
@@ -195,7 +195,8 @@ class BotStubPlayer extends EventRouter {
195
195
  export default class BotPlayerEntity extends GamePlayerEntity {
196
196
  private static readonly _botsByWorld: Map<number, Set<BotPlayerEntity>> = new Map();
197
197
  private static readonly _activeWorlds: Set<number> = new Set();
198
- private static readonly _maxBots = 5 + Math.floor(Math.random() * 4); // 5-8 inclusive
198
+ private static readonly _maxBots = 3;
199
+ private static readonly _humanPlayersBeforeBotRemoval = 5;
199
200
 
200
201
  public static ensureForWorld(world: World): void {
201
202
  const bots = this._botsByWorld.get(world.id) ?? new Set<BotPlayerEntity>();
@@ -204,7 +205,13 @@ export default class BotPlayerEntity extends GamePlayerEntity {
204
205
  this._botsByWorld.set(world.id, bots);
205
206
  }
206
207
 
207
- const desiredBots = this._maxBots;
208
+ const humanPlayers = world.entityManager
209
+ .getAllPlayerEntities()
210
+ .filter(entity => !(entity instanceof BotPlayerEntity))
211
+ .length;
212
+
213
+ const playersAboveThreshold = Math.max(0, humanPlayers - this._humanPlayersBeforeBotRemoval);
214
+ const desiredBots = Math.max(0, Math.min(this._maxBots, this._maxBots - playersAboveThreshold));
208
215
 
209
216
  while (bots.size < desiredBots) {
210
217
  const botName = this._generateRandomBotName();
@@ -176,6 +176,7 @@ export default class GameManager {
176
176
  player.ui.sendData({
177
177
  type: 'leaderboard-sync',
178
178
  killCounts: this.getKillCounts(),
179
+ localPlayer: player.username,
179
180
  });
180
181
  }
181
182
 
@@ -428,6 +429,7 @@ export default class GameManager {
428
429
  type: 'leaderboard-update',
429
430
  username,
430
431
  killCount,
432
+ localPlayer: player.username,
431
433
  });
432
434
  });
433
435
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/examples",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",