@hytopia.com/examples 1.0.6 → 1.0.8

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.
@@ -72,6 +72,7 @@ export default class GamePlayer {
72
72
  private _globalExperience: number = 0;
73
73
  private _health: number = 100;
74
74
  private _isDead: boolean = false;
75
+ private _saveTimeout: NodeJS.Timeout | undefined;
75
76
  private _skillExperience: Map<SkillId, number> = new Map();
76
77
 
77
78
  private constructor(player: Player) {
@@ -384,7 +385,10 @@ export default class GamePlayer {
384
385
  }
385
386
 
386
387
  public save(): void {
387
- this.player.setPersistedData(this._serialize());
388
+ clearTimeout(this._saveTimeout);
389
+ this._saveTimeout = setTimeout(() => { // prevent spamming the server with save requests
390
+ this.player.setPersistedData(this._serialize());
391
+ }, 500);
388
392
  }
389
393
 
390
394
  public showNotification(message: string, notificationType: NotificationType): void {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/examples",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -1,39 +0,0 @@
1
- {
2
- "health": 100,
3
- "currentRegionId": "stalkhaven",
4
- "skillExperience": [],
5
- "backpack": {
6
- "items": []
7
- },
8
- "hotbar": {
9
- "items": [
10
- {
11
- "position": 0,
12
- "itemId": "toy_sword"
13
- }
14
- ]
15
- },
16
- "questLog": {
17
- "quests": [
18
- {
19
- "questId": "welcome-to-stalkhaven",
20
- "state": "active",
21
- "objectiveProgress": {
22
- "talk-to-mark": 0
23
- }
24
- }
25
- ]
26
- },
27
- "storage": {
28
- "items": []
29
- },
30
- "wearables": {
31
- "items": []
32
- },
33
- "currentRegionSpawnFacingAngle": 90,
34
- "currentRegionSpawnPoint": {
35
- "x": 32,
36
- "y": 2,
37
- "z": 1
38
- }
39
- }