quake2ts 0.0.417 → 0.0.420
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 +151 -16
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +151 -16
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/blend.d.ts +9 -0
- package/packages/client/dist/types/blend.d.ts.map +1 -0
- package/packages/client/dist/types/index.d.ts.map +1 -1
- package/packages/client/dist/types/net/serverBrowser.d.ts +17 -0
- package/packages/client/dist/types/net/serverBrowser.d.ts.map +1 -0
- package/packages/client/dist/types/session.d.ts +1 -0
- package/packages/client/dist/types/session.d.ts.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/render/debug.d.ts +7 -0
- package/packages/engine/dist/types/render/debug.d.ts.map +1 -1
- package/packages/engine/dist/types/render/frame.d.ts +1 -0
- package/packages/engine/dist/types/render/frame.d.ts.map +1 -1
- package/packages/engine/dist/types/render/gpuProfiler.d.ts +19 -2
- package/packages/engine/dist/types/render/gpuProfiler.d.ts.map +1 -1
- package/packages/engine/dist/types/render/renderer.d.ts +2 -2
- package/packages/engine/dist/types/render/renderer.d.ts.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/server/dist/index.cjs +35 -0
- package/packages/server/dist/index.d.cts +1 -0
- package/packages/server/dist/index.d.ts +1 -0
- package/packages/server/dist/index.js +35 -0
|
@@ -13973,6 +13973,33 @@ var ClientEffectSystem = class {
|
|
|
13973
13973
|
}
|
|
13974
13974
|
};
|
|
13975
13975
|
|
|
13976
|
+
// src/blend.ts
|
|
13977
|
+
var createBlendState = () => ({
|
|
13978
|
+
damageAlpha: 0,
|
|
13979
|
+
bonusAlpha: 0,
|
|
13980
|
+
lastFlashes: 0
|
|
13981
|
+
});
|
|
13982
|
+
var updateBlend = (state, ps, dt, damageIntensity = 0) => {
|
|
13983
|
+
state.damageAlpha -= dt;
|
|
13984
|
+
if (state.damageAlpha < 0) state.damageAlpha = 0;
|
|
13985
|
+
if (damageIntensity > 0) {
|
|
13986
|
+
state.damageAlpha = damageIntensity;
|
|
13987
|
+
}
|
|
13988
|
+
state.bonusAlpha -= dt;
|
|
13989
|
+
if (state.bonusAlpha < 0) state.bonusAlpha = 0;
|
|
13990
|
+
const flashes = ps.stats ? ps.stats[PlayerStat.STAT_FLASHES] ?? 0 : 0;
|
|
13991
|
+
if (flashes !== state.lastFlashes) {
|
|
13992
|
+
state.bonusAlpha = 0.6;
|
|
13993
|
+
state.lastFlashes = flashes;
|
|
13994
|
+
}
|
|
13995
|
+
if (state.bonusAlpha > 0) {
|
|
13996
|
+
return [1, 1, 0, state.bonusAlpha * 0.3];
|
|
13997
|
+
} else if (state.damageAlpha > 0) {
|
|
13998
|
+
return [1, 0, 0, state.damageAlpha * 0.5];
|
|
13999
|
+
}
|
|
14000
|
+
return [0, 0, 0, 0];
|
|
14001
|
+
};
|
|
14002
|
+
|
|
13976
14003
|
// src/input/bindings.ts
|
|
13977
14004
|
var DEFAULT_BINDINGS = [
|
|
13978
14005
|
{ code: "KeyW", command: "+forward" },
|
|
@@ -14580,13 +14607,111 @@ var GameSession = class {
|
|
|
14580
14607
|
}
|
|
14581
14608
|
}
|
|
14582
14609
|
loadSavedGame(saveData) {
|
|
14610
|
+
if (this.host) {
|
|
14611
|
+
this.shutdown();
|
|
14612
|
+
}
|
|
14613
|
+
const mapName = saveData.map;
|
|
14614
|
+
const skill = saveData.difficulty;
|
|
14615
|
+
const gameOptions = {
|
|
14616
|
+
gravity: { x: 0, y: 0, z: -800 },
|
|
14617
|
+
skill,
|
|
14618
|
+
deathmatch: false,
|
|
14619
|
+
coop: false
|
|
14620
|
+
};
|
|
14621
|
+
const gameEngineAdapter = {
|
|
14622
|
+
trace: (start, end) => {
|
|
14623
|
+
return this.engine.trace(start, end);
|
|
14624
|
+
},
|
|
14625
|
+
centerprintf: (ent, msg) => {
|
|
14626
|
+
if (this.client) {
|
|
14627
|
+
this.client.ParseCenterPrint(msg);
|
|
14628
|
+
}
|
|
14629
|
+
},
|
|
14630
|
+
configstring: (idx, val) => {
|
|
14631
|
+
if (this.client) {
|
|
14632
|
+
this.client.ParseConfigString(idx, val);
|
|
14633
|
+
}
|
|
14634
|
+
},
|
|
14635
|
+
multicast: () => {
|
|
14636
|
+
},
|
|
14637
|
+
unicast: () => {
|
|
14638
|
+
},
|
|
14639
|
+
serverCommand: () => {
|
|
14640
|
+
}
|
|
14641
|
+
};
|
|
14642
|
+
const gameImports = {
|
|
14643
|
+
trace: (start, mins, maxs, end, passent, contentmask) => {
|
|
14644
|
+
const tr = this.engine.trace(start, end, mins || void 0, maxs || void 0);
|
|
14645
|
+
let plane = null;
|
|
14646
|
+
if (tr.planeNormal) {
|
|
14647
|
+
plane = {
|
|
14648
|
+
normal: tr.planeNormal,
|
|
14649
|
+
dist: 0,
|
|
14650
|
+
type: 0,
|
|
14651
|
+
signbits: 0
|
|
14652
|
+
};
|
|
14653
|
+
}
|
|
14654
|
+
return {
|
|
14655
|
+
allsolid: tr.allsolid,
|
|
14656
|
+
startsolid: tr.startsolid,
|
|
14657
|
+
fraction: tr.fraction,
|
|
14658
|
+
endpos: tr.endpos,
|
|
14659
|
+
plane,
|
|
14660
|
+
surfaceFlags: tr.surfaceFlags ?? 0,
|
|
14661
|
+
contents: tr.contents ?? 0,
|
|
14662
|
+
ent: null
|
|
14663
|
+
};
|
|
14664
|
+
},
|
|
14665
|
+
pointcontents: (p) => {
|
|
14666
|
+
const t = this.engine.trace(p, p, void 0, void 0);
|
|
14667
|
+
return t.contents || 0;
|
|
14668
|
+
},
|
|
14669
|
+
multicast: () => {
|
|
14670
|
+
},
|
|
14671
|
+
unicast: () => {
|
|
14672
|
+
},
|
|
14673
|
+
configstring: (idx, val) => {
|
|
14674
|
+
if (this.client) {
|
|
14675
|
+
this.client.ParseConfigString(idx, val);
|
|
14676
|
+
}
|
|
14677
|
+
},
|
|
14678
|
+
serverCommand: (cmd) => {
|
|
14679
|
+
}
|
|
14680
|
+
};
|
|
14681
|
+
this.game = (0, import_game5.createGame)(gameImports, gameEngineAdapter, gameOptions);
|
|
14682
|
+
const clientProxy = {
|
|
14683
|
+
init: (initial) => this.client?.init(initial),
|
|
14684
|
+
render: (sample) => this.client?.render(sample),
|
|
14685
|
+
shutdown: () => this.client?.shutdown(),
|
|
14686
|
+
get camera() {
|
|
14687
|
+
return this.client?.camera;
|
|
14688
|
+
}
|
|
14689
|
+
};
|
|
14690
|
+
this.host = new EngineHost(this.game, clientProxy);
|
|
14691
|
+
const clientImports = {
|
|
14692
|
+
engine: this.engine,
|
|
14693
|
+
host: this.host
|
|
14694
|
+
};
|
|
14695
|
+
this.client = createClient(clientImports);
|
|
14696
|
+
if (this.engine.cmd) {
|
|
14697
|
+
this.engine.cmd.executeText(`map ${mapName}`);
|
|
14698
|
+
} else if (this.host.commands) {
|
|
14699
|
+
this.host.commands.execute(`map ${mapName}`);
|
|
14700
|
+
}
|
|
14701
|
+
if (this.game) {
|
|
14702
|
+
this.game.loadSave(saveData);
|
|
14703
|
+
}
|
|
14704
|
+
this.host.start();
|
|
14583
14705
|
}
|
|
14584
14706
|
shutdown() {
|
|
14585
14707
|
if (this.host) {
|
|
14586
14708
|
this.host.stop();
|
|
14587
14709
|
this.host = null;
|
|
14588
14710
|
}
|
|
14589
|
-
this.client
|
|
14711
|
+
if (this.client) {
|
|
14712
|
+
this.client.shutdown();
|
|
14713
|
+
this.client = null;
|
|
14714
|
+
}
|
|
14590
14715
|
this.game = null;
|
|
14591
14716
|
}
|
|
14592
14717
|
getClient() {
|
|
@@ -14667,6 +14792,9 @@ function createClient(imports) {
|
|
|
14667
14792
|
let pauseMenuFactory;
|
|
14668
14793
|
let optionsFactory;
|
|
14669
14794
|
const configStrings = new ClientConfigStrings();
|
|
14795
|
+
const blendState = createBlendState();
|
|
14796
|
+
let currentBlend = [0, 0, 0, 0];
|
|
14797
|
+
let pendingDamage = 0;
|
|
14670
14798
|
let latestFrame;
|
|
14671
14799
|
let lastRenderTime = 0;
|
|
14672
14800
|
let clientInAutoDemo = false;
|
|
@@ -14738,6 +14866,9 @@ function createClient(imports) {
|
|
|
14738
14866
|
if (pos) {
|
|
14739
14867
|
effectSystem.onTempEntity(type, pos, time);
|
|
14740
14868
|
}
|
|
14869
|
+
},
|
|
14870
|
+
onDamage: (indicators) => {
|
|
14871
|
+
pendingDamage = 0.5;
|
|
14741
14872
|
}
|
|
14742
14873
|
});
|
|
14743
14874
|
demoPlayback.setHandler(demoHandler);
|
|
@@ -15048,7 +15179,16 @@ function createClient(imports) {
|
|
|
15048
15179
|
}
|
|
15049
15180
|
}
|
|
15050
15181
|
const frameTimeMs = sample.latest && sample.previous ? Math.max(0, sample.latest.timeMs - sample.previous.timeMs) : 0;
|
|
15182
|
+
if (frameTimeMs > 0) {
|
|
15183
|
+
prediction.decayError(frameTimeMs / 1e3);
|
|
15184
|
+
}
|
|
15051
15185
|
lastView = view.sample(lastRendered, frameTimeMs);
|
|
15186
|
+
if (lastRendered) {
|
|
15187
|
+
currentBlend = updateBlend(blendState, lastRendered, frameTimeMs / 1e3, pendingDamage);
|
|
15188
|
+
pendingDamage = 0;
|
|
15189
|
+
} else {
|
|
15190
|
+
currentBlend = [0, 0, 0, 0];
|
|
15191
|
+
}
|
|
15052
15192
|
const command = {};
|
|
15053
15193
|
const timeSeconds = sample.nowMs / 1e3;
|
|
15054
15194
|
dlightManager.update(timeSeconds);
|
|
@@ -15104,23 +15244,18 @@ function createClient(imports) {
|
|
|
15104
15244
|
}, renderEntities);
|
|
15105
15245
|
}
|
|
15106
15246
|
if (imports.engine.renderer && lastRendered && lastRendered.client) {
|
|
15107
|
-
const
|
|
15108
|
-
|
|
15109
|
-
batches:
|
|
15110
|
-
facesDrawn:
|
|
15111
|
-
|
|
15112
|
-
|
|
15113
|
-
viewModelDrawn: false,
|
|
15114
|
-
fps: 0,
|
|
15115
|
-
vertexCount: 0
|
|
15116
|
-
} : {
|
|
15117
|
-
batches: 0,
|
|
15118
|
-
facesDrawn: 0,
|
|
15119
|
-
drawCalls: 0,
|
|
15247
|
+
const perfReport = imports.engine.renderer.getPerformanceReport();
|
|
15248
|
+
const stats = {
|
|
15249
|
+
batches: perfReport.textureBinds,
|
|
15250
|
+
facesDrawn: perfReport.triangles,
|
|
15251
|
+
// approximate
|
|
15252
|
+
drawCalls: perfReport.drawCalls,
|
|
15120
15253
|
skyDrawn: false,
|
|
15254
|
+
// Not exposed in report
|
|
15121
15255
|
viewModelDrawn: false,
|
|
15256
|
+
// Not exposed in report
|
|
15122
15257
|
fps: 0,
|
|
15123
|
-
vertexCount:
|
|
15258
|
+
vertexCount: perfReport.vertices
|
|
15124
15259
|
};
|
|
15125
15260
|
const timeMs = sample.latest?.timeMs ?? 0;
|
|
15126
15261
|
this.DrawHUD(stats, timeMs);
|
|
@@ -15143,7 +15278,7 @@ function createClient(imports) {
|
|
|
15143
15278
|
maxs: { x: 16, y: 16, z: 32 },
|
|
15144
15279
|
damageAlpha: lastRendered.damageAlpha ?? 0,
|
|
15145
15280
|
damageIndicators: lastRendered.damageIndicators ?? [],
|
|
15146
|
-
blend:
|
|
15281
|
+
blend: currentBlend,
|
|
15147
15282
|
pickupIcon: lastRendered.pickupIcon,
|
|
15148
15283
|
centerPrint: void 0,
|
|
15149
15284
|
// Handled by CGame MessageSystem now
|