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.
- package/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +16 -16
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +79 -1
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +80 -2
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/session.d.ts +21 -1
- package/packages/client/dist/types/session.d.ts.map +1 -1
- package/packages/game/dist/browser/index.global.js +4 -4
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +1867 -2058
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +1547 -1745
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/combat/weapons/animation.d.ts +0 -7
- package/packages/game/dist/types/combat/weapons/animation.d.ts.map +1 -1
- package/packages/game/dist/types/combat/weapons/common.d.ts +7 -0
- package/packages/game/dist/types/combat/weapons/common.d.ts.map +1 -1
- package/packages/game/dist/types/combat/weapons/grenadelauncher.d.ts.map +1 -1
- package/packages/game/dist/types/combat/weapons/switching.d.ts +1 -0
- package/packages/game/dist/types/combat/weapons/switching.d.ts.map +1 -1
- package/packages/game/dist/types/inventory/playerInventory.d.ts +1 -0
- package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
|
@@ -15151,6 +15151,7 @@ var GameSession = class {
|
|
|
15151
15151
|
this.options = options;
|
|
15152
15152
|
this.engine = options.engine;
|
|
15153
15153
|
this.inputController = new InputController();
|
|
15154
|
+
this.saveStorage = new import_game5.SaveStorage();
|
|
15154
15155
|
}
|
|
15155
15156
|
startNewGame(mapName, skill = 1) {
|
|
15156
15157
|
if (this.host) {
|
|
@@ -15210,7 +15211,6 @@ var GameSession = class {
|
|
|
15210
15211
|
surfaceFlags: tr.surfaceFlags ?? 0,
|
|
15211
15212
|
contents: tr.contents ?? 0,
|
|
15212
15213
|
ent: null
|
|
15213
|
-
// Engine trace does not return Entity
|
|
15214
15214
|
};
|
|
15215
15215
|
},
|
|
15216
15216
|
pointcontents: (p) => {
|
|
@@ -15264,6 +15264,81 @@ var GameSession = class {
|
|
|
15264
15264
|
this.host.commands.execute(`map ${mapName}`);
|
|
15265
15265
|
}
|
|
15266
15266
|
}
|
|
15267
|
+
// 4.3.1 Save Game API
|
|
15268
|
+
async saveGame(slotName) {
|
|
15269
|
+
if (!this.game) {
|
|
15270
|
+
throw new Error("Game not running");
|
|
15271
|
+
}
|
|
15272
|
+
const playtime = this.game.time;
|
|
15273
|
+
const difficulty = this.game.skill;
|
|
15274
|
+
const mapName = this.getMapName();
|
|
15275
|
+
const saveData = this.game.createSave(mapName, difficulty, playtime);
|
|
15276
|
+
await this.saveStorage.save(slotName, saveData);
|
|
15277
|
+
return saveData;
|
|
15278
|
+
}
|
|
15279
|
+
getSaveMetadata(saveData) {
|
|
15280
|
+
return {
|
|
15281
|
+
timestamp: saveData.timestamp,
|
|
15282
|
+
mapName: saveData.map,
|
|
15283
|
+
playtimeSeconds: saveData.playtimeSeconds,
|
|
15284
|
+
difficulty: saveData.difficulty
|
|
15285
|
+
};
|
|
15286
|
+
}
|
|
15287
|
+
// 4.3.2 Load Game API
|
|
15288
|
+
async loadGame(saveData) {
|
|
15289
|
+
try {
|
|
15290
|
+
this.loadSavedGame(saveData);
|
|
15291
|
+
if (this._onLoadComplete) {
|
|
15292
|
+
this._onLoadComplete();
|
|
15293
|
+
}
|
|
15294
|
+
} catch (e) {
|
|
15295
|
+
if (this._onLoadError) {
|
|
15296
|
+
this._onLoadError(e);
|
|
15297
|
+
}
|
|
15298
|
+
throw e;
|
|
15299
|
+
}
|
|
15300
|
+
}
|
|
15301
|
+
set onLoadComplete(handler) {
|
|
15302
|
+
this._onLoadComplete = handler;
|
|
15303
|
+
}
|
|
15304
|
+
get onLoadComplete() {
|
|
15305
|
+
return this._onLoadComplete;
|
|
15306
|
+
}
|
|
15307
|
+
set onLoadError(handler) {
|
|
15308
|
+
this._onLoadError = handler;
|
|
15309
|
+
}
|
|
15310
|
+
get onLoadError() {
|
|
15311
|
+
return this._onLoadError;
|
|
15312
|
+
}
|
|
15313
|
+
// 4.3.3 Quick Save/Load
|
|
15314
|
+
async quickSave() {
|
|
15315
|
+
if (!this.game) {
|
|
15316
|
+
throw new Error("Game not running");
|
|
15317
|
+
}
|
|
15318
|
+
const playtime = this.game.time;
|
|
15319
|
+
const difficulty = this.game.skill;
|
|
15320
|
+
const mapName = this.getMapName();
|
|
15321
|
+
const saveData = this.game.createSave(mapName, difficulty, playtime);
|
|
15322
|
+
await this.saveStorage.quickSave(saveData);
|
|
15323
|
+
}
|
|
15324
|
+
async quickLoad() {
|
|
15325
|
+
try {
|
|
15326
|
+
const saveData = await this.saveStorage.quickLoad();
|
|
15327
|
+
this.loadSavedGame(saveData);
|
|
15328
|
+
if (this._onLoadComplete) {
|
|
15329
|
+
this._onLoadComplete();
|
|
15330
|
+
}
|
|
15331
|
+
} catch (e) {
|
|
15332
|
+
if (this._onLoadError) {
|
|
15333
|
+
this._onLoadError(e);
|
|
15334
|
+
}
|
|
15335
|
+
throw e;
|
|
15336
|
+
}
|
|
15337
|
+
}
|
|
15338
|
+
async hasQuickSave() {
|
|
15339
|
+
const saves = await this.saveStorage.list();
|
|
15340
|
+
return saves.some((s) => s.id === "quicksave");
|
|
15341
|
+
}
|
|
15267
15342
|
loadSavedGame(saveData) {
|
|
15268
15343
|
if (this.host) {
|
|
15269
15344
|
this.shutdown();
|
|
@@ -15394,6 +15469,9 @@ var GameSession = class {
|
|
|
15394
15469
|
getHost() {
|
|
15395
15470
|
return this.host;
|
|
15396
15471
|
}
|
|
15472
|
+
getSaveStorage() {
|
|
15473
|
+
return this.saveStorage;
|
|
15474
|
+
}
|
|
15397
15475
|
bindInputSource(source) {
|
|
15398
15476
|
this.inputController.bindInputSource(source);
|
|
15399
15477
|
}
|