quake2ts 0.0.427 → 0.0.430
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/cgame/dist/index.cjs +1 -1
- package/packages/cgame/dist/index.cjs.map +1 -1
- package/packages/cgame/dist/index.js +1 -1
- package/packages/cgame/dist/index.js.map +1 -1
- package/packages/client/dist/browser/index.global.js +12 -12
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +133 -2
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +133 -2
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/browser/index.global.js +9 -9
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +162 -2
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +159 -2
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/commands.d.ts +7 -0
- package/packages/engine/dist/types/commands.d.ts.map +1 -1
- package/packages/engine/dist/types/demo/analyzer.d.ts +6 -1
- package/packages/engine/dist/types/demo/analyzer.d.ts.map +1 -1
- package/packages/engine/dist/types/demo/camera.d.ts +17 -0
- package/packages/engine/dist/types/demo/camera.d.ts.map +1 -0
- package/packages/engine/dist/types/demo/playback.d.ts +13 -1
- package/packages/engine/dist/types/demo/playback.d.ts.map +1 -1
- package/packages/engine/dist/types/host.d.ts.map +1 -1
- package/packages/engine/dist/types/index.d.ts +5 -0
- package/packages/engine/dist/types/index.d.ts.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -1850,6 +1850,9 @@ var Command = class {
|
|
|
1850
1850
|
var CommandRegistry = class {
|
|
1851
1851
|
constructor() {
|
|
1852
1852
|
this.commands = /* @__PURE__ */ new Map();
|
|
1853
|
+
this.history = [];
|
|
1854
|
+
this.historyLimit = 64;
|
|
1855
|
+
this.autocompleteProviders = [];
|
|
1853
1856
|
}
|
|
1854
1857
|
register(name, callback, description) {
|
|
1855
1858
|
const command = new Command(name, callback, description);
|
|
@@ -1859,10 +1862,23 @@ var CommandRegistry = class {
|
|
|
1859
1862
|
registerCommand(name, callback) {
|
|
1860
1863
|
this.register(name, callback);
|
|
1861
1864
|
}
|
|
1865
|
+
registerAutocompleteProvider(provider) {
|
|
1866
|
+
this.autocompleteProviders.push(provider);
|
|
1867
|
+
}
|
|
1862
1868
|
get(name) {
|
|
1863
1869
|
return this.commands.get(name);
|
|
1864
1870
|
}
|
|
1865
1871
|
execute(commandString) {
|
|
1872
|
+
const trimmed = commandString.trim();
|
|
1873
|
+
if (trimmed.length === 0) {
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1876
|
+
if (this.history.length === 0 || this.history[this.history.length - 1] !== trimmed) {
|
|
1877
|
+
this.history.push(trimmed);
|
|
1878
|
+
if (this.history.length > this.historyLimit) {
|
|
1879
|
+
this.history.shift();
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1866
1882
|
const parts = this.tokenize(commandString);
|
|
1867
1883
|
if (parts.length === 0) {
|
|
1868
1884
|
return false;
|
|
@@ -1880,6 +1896,26 @@ var CommandRegistry = class {
|
|
|
1880
1896
|
executeCommand(cmd) {
|
|
1881
1897
|
this.execute(cmd);
|
|
1882
1898
|
}
|
|
1899
|
+
getHistory() {
|
|
1900
|
+
return [...this.history];
|
|
1901
|
+
}
|
|
1902
|
+
getSuggestions(prefix) {
|
|
1903
|
+
const suggestions = /* @__PURE__ */ new Set();
|
|
1904
|
+
for (const name of this.commands.keys()) {
|
|
1905
|
+
if (name.startsWith(prefix)) {
|
|
1906
|
+
suggestions.add(name);
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
for (const provider of this.autocompleteProviders) {
|
|
1910
|
+
const providerSuggestions = provider();
|
|
1911
|
+
for (const suggestion of providerSuggestions) {
|
|
1912
|
+
if (suggestion.startsWith(prefix)) {
|
|
1913
|
+
suggestions.add(suggestion);
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
return Array.from(suggestions).sort();
|
|
1918
|
+
}
|
|
1883
1919
|
tokenize(text) {
|
|
1884
1920
|
const args = [];
|
|
1885
1921
|
let currentArg = "";
|
|
@@ -3065,6 +3101,9 @@ var EngineHost = class {
|
|
|
3065
3101
|
},
|
|
3066
3102
|
{ ...options.loop, startTimeMs: this.startTimeMs }
|
|
3067
3103
|
);
|
|
3104
|
+
this.commands.registerAutocompleteProvider(() => {
|
|
3105
|
+
return this.cvars.list().map((cvar) => cvar.name);
|
|
3106
|
+
});
|
|
3068
3107
|
}
|
|
3069
3108
|
start() {
|
|
3070
3109
|
if (this.started) return;
|
|
@@ -8964,6 +9003,7 @@ var DemoAnalyzer = class {
|
|
|
8964
9003
|
this.statistics = null;
|
|
8965
9004
|
this.playerStats = /* @__PURE__ */ new Map();
|
|
8966
9005
|
this.weaponStats = /* @__PURE__ */ new Map();
|
|
9006
|
+
this.activeEntities = /* @__PURE__ */ new Set();
|
|
8967
9007
|
this.buffer = buffer;
|
|
8968
9008
|
}
|
|
8969
9009
|
analyze() {
|
|
@@ -8999,9 +9039,28 @@ var DemoAnalyzer = class {
|
|
|
8999
9039
|
onSpawnBaseline: (entity) => {
|
|
9000
9040
|
},
|
|
9001
9041
|
onFrame: (frame) => {
|
|
9042
|
+
const currentFrameEntities = /* @__PURE__ */ new Set();
|
|
9043
|
+
if (frame.packetEntities && frame.packetEntities.entities) {
|
|
9044
|
+
for (const ent of frame.packetEntities.entities) {
|
|
9045
|
+
currentFrameEntities.add(ent.number);
|
|
9046
|
+
if (!this.activeEntities.has(ent.number)) {
|
|
9047
|
+
this.recordEvent({
|
|
9048
|
+
type: 5,
|
|
9049
|
+
frame: currentFrameIndex,
|
|
9050
|
+
time: currentTime,
|
|
9051
|
+
entityId: ent.number,
|
|
9052
|
+
position: { x: ent.origin.x, y: ent.origin.y, z: ent.origin.z },
|
|
9053
|
+
description: `Entity ${ent.number} spawned`
|
|
9054
|
+
});
|
|
9055
|
+
}
|
|
9056
|
+
}
|
|
9057
|
+
}
|
|
9058
|
+
this.activeEntities = currentFrameEntities;
|
|
9059
|
+
if (frame.playerState && this.header) {
|
|
9060
|
+
}
|
|
9002
9061
|
},
|
|
9003
9062
|
onPrint: (level, msg) => {
|
|
9004
|
-
if (msg.includes("died") || msg.includes("killed")) {
|
|
9063
|
+
if (msg.includes("died") || msg.includes("killed") || msg.includes("suicide")) {
|
|
9005
9064
|
this.summary.totalDeaths++;
|
|
9006
9065
|
this.recordEvent({
|
|
9007
9066
|
type: 4,
|
|
@@ -9010,6 +9069,14 @@ var DemoAnalyzer = class {
|
|
|
9010
9069
|
description: msg.trim()
|
|
9011
9070
|
});
|
|
9012
9071
|
}
|
|
9072
|
+
if (msg.startsWith("You got the ")) {
|
|
9073
|
+
this.recordEvent({
|
|
9074
|
+
type: 3,
|
|
9075
|
+
frame: currentFrameIndex,
|
|
9076
|
+
time: currentTime,
|
|
9077
|
+
description: msg.trim()
|
|
9078
|
+
});
|
|
9079
|
+
}
|
|
9013
9080
|
},
|
|
9014
9081
|
onCenterPrint: () => {
|
|
9015
9082
|
},
|
|
@@ -9050,6 +9117,10 @@ var DemoAnalyzer = class {
|
|
|
9050
9117
|
description: `Took ${ind.damage} damage`
|
|
9051
9118
|
});
|
|
9052
9119
|
this.summary.damageReceived += ind.damage;
|
|
9120
|
+
if (this.header) {
|
|
9121
|
+
const pStats = this.getOrCreatePlayerStats(this.header.playerNum);
|
|
9122
|
+
pStats.damageReceived += ind.damage;
|
|
9123
|
+
}
|
|
9053
9124
|
}
|
|
9054
9125
|
}
|
|
9055
9126
|
};
|
|
@@ -9077,7 +9148,9 @@ var DemoAnalyzer = class {
|
|
|
9077
9148
|
header: this.header,
|
|
9078
9149
|
configStrings: this.configStrings,
|
|
9079
9150
|
serverInfo: this.serverInfo,
|
|
9080
|
-
statistics: this.statistics
|
|
9151
|
+
statistics: this.statistics,
|
|
9152
|
+
playerStats: this.playerStats,
|
|
9153
|
+
weaponStats: this.weaponStats
|
|
9081
9154
|
};
|
|
9082
9155
|
}
|
|
9083
9156
|
handleWeaponFire(ent, weapon, frame, time) {
|
|
@@ -9091,6 +9164,8 @@ var DemoAnalyzer = class {
|
|
|
9091
9164
|
});
|
|
9092
9165
|
const count = this.summary.weaponUsage.get(weapon) || 0;
|
|
9093
9166
|
this.summary.weaponUsage.set(weapon, count + 1);
|
|
9167
|
+
const wStats = this.getOrCreateWeaponStat(ent, weapon);
|
|
9168
|
+
wStats.shotsFired++;
|
|
9094
9169
|
}
|
|
9095
9170
|
recordEvent(event) {
|
|
9096
9171
|
this.events.push(event);
|
|
@@ -9103,6 +9178,33 @@ var DemoAnalyzer = class {
|
|
|
9103
9178
|
}
|
|
9104
9179
|
}
|
|
9105
9180
|
}
|
|
9181
|
+
getOrCreatePlayerStats(playerNum) {
|
|
9182
|
+
let stats = this.playerStats.get(playerNum);
|
|
9183
|
+
if (!stats) {
|
|
9184
|
+
stats = {
|
|
9185
|
+
kills: 0,
|
|
9186
|
+
deaths: 0,
|
|
9187
|
+
damageDealt: 0,
|
|
9188
|
+
damageReceived: 0,
|
|
9189
|
+
suicides: 0
|
|
9190
|
+
};
|
|
9191
|
+
this.playerStats.set(playerNum, stats);
|
|
9192
|
+
}
|
|
9193
|
+
return stats;
|
|
9194
|
+
}
|
|
9195
|
+
getOrCreateWeaponStat(entityId, weaponId) {
|
|
9196
|
+
let statsList = this.weaponStats.get(entityId);
|
|
9197
|
+
if (!statsList) {
|
|
9198
|
+
statsList = [];
|
|
9199
|
+
this.weaponStats.set(entityId, statsList);
|
|
9200
|
+
}
|
|
9201
|
+
let stat = statsList.find((s) => s.weaponId === weaponId);
|
|
9202
|
+
if (!stat) {
|
|
9203
|
+
stat = { weaponId, shotsFired: 0, hits: 0, kills: 0 };
|
|
9204
|
+
statsList.push(stat);
|
|
9205
|
+
}
|
|
9206
|
+
return stat;
|
|
9207
|
+
}
|
|
9106
9208
|
};
|
|
9107
9209
|
var PlaybackState = /* @__PURE__ */ ((PlaybackState22) => {
|
|
9108
9210
|
PlaybackState22[PlaybackState22["Stopped"] = 0] = "Stopped";
|
|
@@ -9130,6 +9232,11 @@ var DemoPlaybackController = class {
|
|
|
9130
9232
|
this.cachedConfigStrings = null;
|
|
9131
9233
|
this.cachedServerInfo = null;
|
|
9132
9234
|
this.cachedStatistics = null;
|
|
9235
|
+
this.cachedPlayerStats = null;
|
|
9236
|
+
this.cachedWeaponStats = null;
|
|
9237
|
+
this.cameraMode = 0;
|
|
9238
|
+
this.thirdPersonDistance = 80;
|
|
9239
|
+
this.thirdPersonOffset = { x: 0, y: 0, z: 0 };
|
|
9133
9240
|
}
|
|
9134
9241
|
setHandler(handler) {
|
|
9135
9242
|
this.handler = handler;
|
|
@@ -9155,6 +9262,8 @@ var DemoPlaybackController = class {
|
|
|
9155
9262
|
this.cachedConfigStrings = null;
|
|
9156
9263
|
this.cachedServerInfo = null;
|
|
9157
9264
|
this.cachedStatistics = null;
|
|
9265
|
+
this.cachedPlayerStats = null;
|
|
9266
|
+
this.cachedWeaponStats = null;
|
|
9158
9267
|
}
|
|
9159
9268
|
play() {
|
|
9160
9269
|
if (this.reader && this.state !== 1) {
|
|
@@ -9521,6 +9630,14 @@ var DemoPlaybackController = class {
|
|
|
9521
9630
|
this.ensureAnalysis();
|
|
9522
9631
|
return this.cachedStatistics;
|
|
9523
9632
|
}
|
|
9633
|
+
getPlayerStatistics(playerIndex) {
|
|
9634
|
+
this.ensureAnalysis();
|
|
9635
|
+
return this.cachedPlayerStats?.get(playerIndex) || null;
|
|
9636
|
+
}
|
|
9637
|
+
getWeaponStatistics(entityId) {
|
|
9638
|
+
this.ensureAnalysis();
|
|
9639
|
+
return this.cachedWeaponStats?.get(entityId) || null;
|
|
9640
|
+
}
|
|
9524
9641
|
ensureAnalysis() {
|
|
9525
9642
|
if (!this.cachedEvents && this.buffer) {
|
|
9526
9643
|
const analyzer = new DemoAnalyzer(this.buffer);
|
|
@@ -9531,8 +9648,22 @@ var DemoPlaybackController = class {
|
|
|
9531
9648
|
this.cachedConfigStrings = result.configStrings;
|
|
9532
9649
|
this.cachedServerInfo = result.serverInfo;
|
|
9533
9650
|
this.cachedStatistics = result.statistics;
|
|
9651
|
+
this.cachedPlayerStats = result.playerStats;
|
|
9652
|
+
this.cachedWeaponStats = result.weaponStats;
|
|
9534
9653
|
}
|
|
9535
9654
|
}
|
|
9655
|
+
setCameraMode(mode) {
|
|
9656
|
+
this.cameraMode = mode;
|
|
9657
|
+
}
|
|
9658
|
+
getCameraMode() {
|
|
9659
|
+
return this.cameraMode;
|
|
9660
|
+
}
|
|
9661
|
+
setThirdPersonDistance(distance2) {
|
|
9662
|
+
this.thirdPersonDistance = distance2;
|
|
9663
|
+
}
|
|
9664
|
+
setThirdPersonOffset(offset) {
|
|
9665
|
+
this.thirdPersonOffset = offset;
|
|
9666
|
+
}
|
|
9536
9667
|
};
|
|
9537
9668
|
var DemoRecorder = class {
|
|
9538
9669
|
// -1 means start of demo
|