quake2ts 0.0.481 → 0.0.483

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 (26) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +16 -16
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +79 -1
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +80 -2
  7. package/packages/client/dist/esm/index.js.map +1 -1
  8. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  9. package/packages/client/dist/types/session.d.ts +21 -1
  10. package/packages/client/dist/types/session.d.ts.map +1 -1
  11. package/packages/game/dist/browser/index.global.js +4 -4
  12. package/packages/game/dist/browser/index.global.js.map +1 -1
  13. package/packages/game/dist/cjs/index.cjs +1867 -2058
  14. package/packages/game/dist/cjs/index.cjs.map +1 -1
  15. package/packages/game/dist/esm/index.js +1547 -1745
  16. package/packages/game/dist/esm/index.js.map +1 -1
  17. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  18. package/packages/game/dist/types/combat/weapons/animation.d.ts +0 -7
  19. package/packages/game/dist/types/combat/weapons/animation.d.ts.map +1 -1
  20. package/packages/game/dist/types/combat/weapons/common.d.ts +7 -0
  21. package/packages/game/dist/types/combat/weapons/common.d.ts.map +1 -1
  22. package/packages/game/dist/types/combat/weapons/grenadelauncher.d.ts.map +1 -1
  23. package/packages/game/dist/types/combat/weapons/switching.d.ts +1 -0
  24. package/packages/game/dist/types/combat/weapons/switching.d.ts.map +1 -1
  25. package/packages/game/dist/types/inventory/playerInventory.d.ts +1 -0
  26. package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
@@ -15108,7 +15108,7 @@ import {
15108
15108
  import { ViewEffects as ViewEffects3 } from "@quake2ts/cgame";
15109
15109
 
15110
15110
  // src/session.ts
15111
- import { createGame } from "@quake2ts/game";
15111
+ import { createGame, SaveStorage } from "@quake2ts/game";
15112
15112
  var GameSession = class {
15113
15113
  constructor(options) {
15114
15114
  this.client = null;
@@ -15118,6 +15118,7 @@ var GameSession = class {
15118
15118
  this.options = options;
15119
15119
  this.engine = options.engine;
15120
15120
  this.inputController = new InputController();
15121
+ this.saveStorage = new SaveStorage();
15121
15122
  }
15122
15123
  startNewGame(mapName, skill = 1) {
15123
15124
  if (this.host) {
@@ -15177,7 +15178,6 @@ var GameSession = class {
15177
15178
  surfaceFlags: tr.surfaceFlags ?? 0,
15178
15179
  contents: tr.contents ?? 0,
15179
15180
  ent: null
15180
- // Engine trace does not return Entity
15181
15181
  };
15182
15182
  },
15183
15183
  pointcontents: (p) => {
@@ -15231,6 +15231,81 @@ var GameSession = class {
15231
15231
  this.host.commands.execute(`map ${mapName}`);
15232
15232
  }
15233
15233
  }
15234
+ // 4.3.1 Save Game API
15235
+ async saveGame(slotName) {
15236
+ if (!this.game) {
15237
+ throw new Error("Game not running");
15238
+ }
15239
+ const playtime = this.game.time;
15240
+ const difficulty = this.game.skill;
15241
+ const mapName = this.getMapName();
15242
+ const saveData = this.game.createSave(mapName, difficulty, playtime);
15243
+ await this.saveStorage.save(slotName, saveData);
15244
+ return saveData;
15245
+ }
15246
+ getSaveMetadata(saveData) {
15247
+ return {
15248
+ timestamp: saveData.timestamp,
15249
+ mapName: saveData.map,
15250
+ playtimeSeconds: saveData.playtimeSeconds,
15251
+ difficulty: saveData.difficulty
15252
+ };
15253
+ }
15254
+ // 4.3.2 Load Game API
15255
+ async loadGame(saveData) {
15256
+ try {
15257
+ this.loadSavedGame(saveData);
15258
+ if (this._onLoadComplete) {
15259
+ this._onLoadComplete();
15260
+ }
15261
+ } catch (e) {
15262
+ if (this._onLoadError) {
15263
+ this._onLoadError(e);
15264
+ }
15265
+ throw e;
15266
+ }
15267
+ }
15268
+ set onLoadComplete(handler) {
15269
+ this._onLoadComplete = handler;
15270
+ }
15271
+ get onLoadComplete() {
15272
+ return this._onLoadComplete;
15273
+ }
15274
+ set onLoadError(handler) {
15275
+ this._onLoadError = handler;
15276
+ }
15277
+ get onLoadError() {
15278
+ return this._onLoadError;
15279
+ }
15280
+ // 4.3.3 Quick Save/Load
15281
+ async quickSave() {
15282
+ if (!this.game) {
15283
+ throw new Error("Game not running");
15284
+ }
15285
+ const playtime = this.game.time;
15286
+ const difficulty = this.game.skill;
15287
+ const mapName = this.getMapName();
15288
+ const saveData = this.game.createSave(mapName, difficulty, playtime);
15289
+ await this.saveStorage.quickSave(saveData);
15290
+ }
15291
+ async quickLoad() {
15292
+ try {
15293
+ const saveData = await this.saveStorage.quickLoad();
15294
+ this.loadSavedGame(saveData);
15295
+ if (this._onLoadComplete) {
15296
+ this._onLoadComplete();
15297
+ }
15298
+ } catch (e) {
15299
+ if (this._onLoadError) {
15300
+ this._onLoadError(e);
15301
+ }
15302
+ throw e;
15303
+ }
15304
+ }
15305
+ async hasQuickSave() {
15306
+ const saves = await this.saveStorage.list();
15307
+ return saves.some((s) => s.id === "quicksave");
15308
+ }
15234
15309
  loadSavedGame(saveData) {
15235
15310
  if (this.host) {
15236
15311
  this.shutdown();
@@ -15361,6 +15436,9 @@ var GameSession = class {
15361
15436
  getHost() {
15362
15437
  return this.host;
15363
15438
  }
15439
+ getSaveStorage() {
15440
+ return this.saveStorage;
15441
+ }
15364
15442
  bindInputSource(source) {
15365
15443
  this.inputController.bindInputSource(source);
15366
15444
  }