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
|
@@ -1815,6 +1815,9 @@ var Command = class {
|
|
|
1815
1815
|
var CommandRegistry = class {
|
|
1816
1816
|
constructor() {
|
|
1817
1817
|
this.commands = /* @__PURE__ */ new Map();
|
|
1818
|
+
this.history = [];
|
|
1819
|
+
this.historyLimit = 64;
|
|
1820
|
+
this.autocompleteProviders = [];
|
|
1818
1821
|
}
|
|
1819
1822
|
register(name, callback, description) {
|
|
1820
1823
|
const command = new Command(name, callback, description);
|
|
@@ -1824,10 +1827,23 @@ var CommandRegistry = class {
|
|
|
1824
1827
|
registerCommand(name, callback) {
|
|
1825
1828
|
this.register(name, callback);
|
|
1826
1829
|
}
|
|
1830
|
+
registerAutocompleteProvider(provider) {
|
|
1831
|
+
this.autocompleteProviders.push(provider);
|
|
1832
|
+
}
|
|
1827
1833
|
get(name) {
|
|
1828
1834
|
return this.commands.get(name);
|
|
1829
1835
|
}
|
|
1830
1836
|
execute(commandString) {
|
|
1837
|
+
const trimmed = commandString.trim();
|
|
1838
|
+
if (trimmed.length === 0) {
|
|
1839
|
+
return false;
|
|
1840
|
+
}
|
|
1841
|
+
if (this.history.length === 0 || this.history[this.history.length - 1] !== trimmed) {
|
|
1842
|
+
this.history.push(trimmed);
|
|
1843
|
+
if (this.history.length > this.historyLimit) {
|
|
1844
|
+
this.history.shift();
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1831
1847
|
const parts = this.tokenize(commandString);
|
|
1832
1848
|
if (parts.length === 0) {
|
|
1833
1849
|
return false;
|
|
@@ -1845,6 +1861,26 @@ var CommandRegistry = class {
|
|
|
1845
1861
|
executeCommand(cmd) {
|
|
1846
1862
|
this.execute(cmd);
|
|
1847
1863
|
}
|
|
1864
|
+
getHistory() {
|
|
1865
|
+
return [...this.history];
|
|
1866
|
+
}
|
|
1867
|
+
getSuggestions(prefix) {
|
|
1868
|
+
const suggestions = /* @__PURE__ */ new Set();
|
|
1869
|
+
for (const name of this.commands.keys()) {
|
|
1870
|
+
if (name.startsWith(prefix)) {
|
|
1871
|
+
suggestions.add(name);
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
for (const provider of this.autocompleteProviders) {
|
|
1875
|
+
const providerSuggestions = provider();
|
|
1876
|
+
for (const suggestion of providerSuggestions) {
|
|
1877
|
+
if (suggestion.startsWith(prefix)) {
|
|
1878
|
+
suggestions.add(suggestion);
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
return Array.from(suggestions).sort();
|
|
1883
|
+
}
|
|
1848
1884
|
tokenize(text) {
|
|
1849
1885
|
const args = [];
|
|
1850
1886
|
let currentArg = "";
|
|
@@ -3030,6 +3066,9 @@ var EngineHost = class {
|
|
|
3030
3066
|
},
|
|
3031
3067
|
{ ...options.loop, startTimeMs: this.startTimeMs }
|
|
3032
3068
|
);
|
|
3069
|
+
this.commands.registerAutocompleteProvider(() => {
|
|
3070
|
+
return this.cvars.list().map((cvar) => cvar.name);
|
|
3071
|
+
});
|
|
3033
3072
|
}
|
|
3034
3073
|
start() {
|
|
3035
3074
|
if (this.started) return;
|
|
@@ -8929,6 +8968,7 @@ var DemoAnalyzer = class {
|
|
|
8929
8968
|
this.statistics = null;
|
|
8930
8969
|
this.playerStats = /* @__PURE__ */ new Map();
|
|
8931
8970
|
this.weaponStats = /* @__PURE__ */ new Map();
|
|
8971
|
+
this.activeEntities = /* @__PURE__ */ new Set();
|
|
8932
8972
|
this.buffer = buffer;
|
|
8933
8973
|
}
|
|
8934
8974
|
analyze() {
|
|
@@ -8964,9 +9004,28 @@ var DemoAnalyzer = class {
|
|
|
8964
9004
|
onSpawnBaseline: (entity) => {
|
|
8965
9005
|
},
|
|
8966
9006
|
onFrame: (frame) => {
|
|
9007
|
+
const currentFrameEntities = /* @__PURE__ */ new Set();
|
|
9008
|
+
if (frame.packetEntities && frame.packetEntities.entities) {
|
|
9009
|
+
for (const ent of frame.packetEntities.entities) {
|
|
9010
|
+
currentFrameEntities.add(ent.number);
|
|
9011
|
+
if (!this.activeEntities.has(ent.number)) {
|
|
9012
|
+
this.recordEvent({
|
|
9013
|
+
type: 5,
|
|
9014
|
+
frame: currentFrameIndex,
|
|
9015
|
+
time: currentTime,
|
|
9016
|
+
entityId: ent.number,
|
|
9017
|
+
position: { x: ent.origin.x, y: ent.origin.y, z: ent.origin.z },
|
|
9018
|
+
description: `Entity ${ent.number} spawned`
|
|
9019
|
+
});
|
|
9020
|
+
}
|
|
9021
|
+
}
|
|
9022
|
+
}
|
|
9023
|
+
this.activeEntities = currentFrameEntities;
|
|
9024
|
+
if (frame.playerState && this.header) {
|
|
9025
|
+
}
|
|
8967
9026
|
},
|
|
8968
9027
|
onPrint: (level, msg) => {
|
|
8969
|
-
if (msg.includes("died") || msg.includes("killed")) {
|
|
9028
|
+
if (msg.includes("died") || msg.includes("killed") || msg.includes("suicide")) {
|
|
8970
9029
|
this.summary.totalDeaths++;
|
|
8971
9030
|
this.recordEvent({
|
|
8972
9031
|
type: 4,
|
|
@@ -8975,6 +9034,14 @@ var DemoAnalyzer = class {
|
|
|
8975
9034
|
description: msg.trim()
|
|
8976
9035
|
});
|
|
8977
9036
|
}
|
|
9037
|
+
if (msg.startsWith("You got the ")) {
|
|
9038
|
+
this.recordEvent({
|
|
9039
|
+
type: 3,
|
|
9040
|
+
frame: currentFrameIndex,
|
|
9041
|
+
time: currentTime,
|
|
9042
|
+
description: msg.trim()
|
|
9043
|
+
});
|
|
9044
|
+
}
|
|
8978
9045
|
},
|
|
8979
9046
|
onCenterPrint: () => {
|
|
8980
9047
|
},
|
|
@@ -9015,6 +9082,10 @@ var DemoAnalyzer = class {
|
|
|
9015
9082
|
description: `Took ${ind.damage} damage`
|
|
9016
9083
|
});
|
|
9017
9084
|
this.summary.damageReceived += ind.damage;
|
|
9085
|
+
if (this.header) {
|
|
9086
|
+
const pStats = this.getOrCreatePlayerStats(this.header.playerNum);
|
|
9087
|
+
pStats.damageReceived += ind.damage;
|
|
9088
|
+
}
|
|
9018
9089
|
}
|
|
9019
9090
|
}
|
|
9020
9091
|
};
|
|
@@ -9042,7 +9113,9 @@ var DemoAnalyzer = class {
|
|
|
9042
9113
|
header: this.header,
|
|
9043
9114
|
configStrings: this.configStrings,
|
|
9044
9115
|
serverInfo: this.serverInfo,
|
|
9045
|
-
statistics: this.statistics
|
|
9116
|
+
statistics: this.statistics,
|
|
9117
|
+
playerStats: this.playerStats,
|
|
9118
|
+
weaponStats: this.weaponStats
|
|
9046
9119
|
};
|
|
9047
9120
|
}
|
|
9048
9121
|
handleWeaponFire(ent, weapon, frame, time) {
|
|
@@ -9056,6 +9129,8 @@ var DemoAnalyzer = class {
|
|
|
9056
9129
|
});
|
|
9057
9130
|
const count = this.summary.weaponUsage.get(weapon) || 0;
|
|
9058
9131
|
this.summary.weaponUsage.set(weapon, count + 1);
|
|
9132
|
+
const wStats = this.getOrCreateWeaponStat(ent, weapon);
|
|
9133
|
+
wStats.shotsFired++;
|
|
9059
9134
|
}
|
|
9060
9135
|
recordEvent(event) {
|
|
9061
9136
|
this.events.push(event);
|
|
@@ -9068,6 +9143,33 @@ var DemoAnalyzer = class {
|
|
|
9068
9143
|
}
|
|
9069
9144
|
}
|
|
9070
9145
|
}
|
|
9146
|
+
getOrCreatePlayerStats(playerNum) {
|
|
9147
|
+
let stats = this.playerStats.get(playerNum);
|
|
9148
|
+
if (!stats) {
|
|
9149
|
+
stats = {
|
|
9150
|
+
kills: 0,
|
|
9151
|
+
deaths: 0,
|
|
9152
|
+
damageDealt: 0,
|
|
9153
|
+
damageReceived: 0,
|
|
9154
|
+
suicides: 0
|
|
9155
|
+
};
|
|
9156
|
+
this.playerStats.set(playerNum, stats);
|
|
9157
|
+
}
|
|
9158
|
+
return stats;
|
|
9159
|
+
}
|
|
9160
|
+
getOrCreateWeaponStat(entityId, weaponId) {
|
|
9161
|
+
let statsList = this.weaponStats.get(entityId);
|
|
9162
|
+
if (!statsList) {
|
|
9163
|
+
statsList = [];
|
|
9164
|
+
this.weaponStats.set(entityId, statsList);
|
|
9165
|
+
}
|
|
9166
|
+
let stat = statsList.find((s) => s.weaponId === weaponId);
|
|
9167
|
+
if (!stat) {
|
|
9168
|
+
stat = { weaponId, shotsFired: 0, hits: 0, kills: 0 };
|
|
9169
|
+
statsList.push(stat);
|
|
9170
|
+
}
|
|
9171
|
+
return stat;
|
|
9172
|
+
}
|
|
9071
9173
|
};
|
|
9072
9174
|
var PlaybackState = /* @__PURE__ */ ((PlaybackState22) => {
|
|
9073
9175
|
PlaybackState22[PlaybackState22["Stopped"] = 0] = "Stopped";
|
|
@@ -9095,6 +9197,11 @@ var DemoPlaybackController = class {
|
|
|
9095
9197
|
this.cachedConfigStrings = null;
|
|
9096
9198
|
this.cachedServerInfo = null;
|
|
9097
9199
|
this.cachedStatistics = null;
|
|
9200
|
+
this.cachedPlayerStats = null;
|
|
9201
|
+
this.cachedWeaponStats = null;
|
|
9202
|
+
this.cameraMode = 0;
|
|
9203
|
+
this.thirdPersonDistance = 80;
|
|
9204
|
+
this.thirdPersonOffset = { x: 0, y: 0, z: 0 };
|
|
9098
9205
|
}
|
|
9099
9206
|
setHandler(handler) {
|
|
9100
9207
|
this.handler = handler;
|
|
@@ -9120,6 +9227,8 @@ var DemoPlaybackController = class {
|
|
|
9120
9227
|
this.cachedConfigStrings = null;
|
|
9121
9228
|
this.cachedServerInfo = null;
|
|
9122
9229
|
this.cachedStatistics = null;
|
|
9230
|
+
this.cachedPlayerStats = null;
|
|
9231
|
+
this.cachedWeaponStats = null;
|
|
9123
9232
|
}
|
|
9124
9233
|
play() {
|
|
9125
9234
|
if (this.reader && this.state !== 1) {
|
|
@@ -9486,6 +9595,14 @@ var DemoPlaybackController = class {
|
|
|
9486
9595
|
this.ensureAnalysis();
|
|
9487
9596
|
return this.cachedStatistics;
|
|
9488
9597
|
}
|
|
9598
|
+
getPlayerStatistics(playerIndex) {
|
|
9599
|
+
this.ensureAnalysis();
|
|
9600
|
+
return this.cachedPlayerStats?.get(playerIndex) || null;
|
|
9601
|
+
}
|
|
9602
|
+
getWeaponStatistics(entityId) {
|
|
9603
|
+
this.ensureAnalysis();
|
|
9604
|
+
return this.cachedWeaponStats?.get(entityId) || null;
|
|
9605
|
+
}
|
|
9489
9606
|
ensureAnalysis() {
|
|
9490
9607
|
if (!this.cachedEvents && this.buffer) {
|
|
9491
9608
|
const analyzer = new DemoAnalyzer(this.buffer);
|
|
@@ -9496,8 +9613,22 @@ var DemoPlaybackController = class {
|
|
|
9496
9613
|
this.cachedConfigStrings = result.configStrings;
|
|
9497
9614
|
this.cachedServerInfo = result.serverInfo;
|
|
9498
9615
|
this.cachedStatistics = result.statistics;
|
|
9616
|
+
this.cachedPlayerStats = result.playerStats;
|
|
9617
|
+
this.cachedWeaponStats = result.weaponStats;
|
|
9499
9618
|
}
|
|
9500
9619
|
}
|
|
9620
|
+
setCameraMode(mode) {
|
|
9621
|
+
this.cameraMode = mode;
|
|
9622
|
+
}
|
|
9623
|
+
getCameraMode() {
|
|
9624
|
+
return this.cameraMode;
|
|
9625
|
+
}
|
|
9626
|
+
setThirdPersonDistance(distance2) {
|
|
9627
|
+
this.thirdPersonDistance = distance2;
|
|
9628
|
+
}
|
|
9629
|
+
setThirdPersonOffset(offset) {
|
|
9630
|
+
this.thirdPersonOffset = offset;
|
|
9631
|
+
}
|
|
9501
9632
|
};
|
|
9502
9633
|
var DemoRecorder = class {
|
|
9503
9634
|
// -1 means start of demo
|