quake2ts 0.0.568 → 0.0.570
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 +13 -13
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/demo/optimalClipFinder.d.ts +35 -0
- package/packages/engine/dist/types/demo/optimalClipFinder.d.ts.map +1 -0
- package/packages/engine/dist/types/demo/types.d.ts +9 -0
- package/packages/engine/dist/types/demo/types.d.ts.map +1 -1
- package/packages/game/dist/browser/index.global.js +5 -5
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +127 -0
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +124 -0
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/entities/index.d.ts +1 -1
- package/packages/game/dist/types/entities/index.d.ts.map +1 -1
- package/packages/test-utils/dist/index.cjs +358 -71
- package/packages/test-utils/dist/index.cjs.map +1 -1
- package/packages/test-utils/dist/index.d.cts +72 -3
- package/packages/test-utils/dist/index.d.ts +72 -3
- package/packages/test-utils/dist/index.js +346 -68
- package/packages/test-utils/dist/index.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Entity, type DieCallback, type EntityFieldDescriptor, type EntityFieldType, type PainCallback, type ThinkCallback, type TouchCallback, type UseCallback, type MonsterInfo, type MonsterMove, type MonsterFrame, MoveType, Solid, ServerFlags, DeadFlag, ENTITY_FIELD_METADATA, } from './entity.js';
|
|
1
|
+
export { Entity, type DieCallback, type EntityFieldDescriptor, type EntityFieldType, type PainCallback, type ThinkCallback, type TouchCallback, type UseCallback, type MonsterInfo, type MonsterMove, type MonsterFrame, type MonsterAction, type AIAction, MoveType, Solid, ServerFlags, DeadFlag, EntityFlags, EntityEffects, MuzzleFlash, ENTITY_FIELD_METADATA, } from './entity.js';
|
|
2
2
|
export { EntitySystem, type EntitySystemSnapshot, type SerializedEntityState, type SerializedTargetAwareness, type LevelState } from './system.js';
|
|
3
3
|
export { type EntityPoolSnapshot } from './pool.js';
|
|
4
4
|
export { type ThinkScheduleEntry } from './thinkScheduler.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,QAAQ,EACR,KAAK,EACL,WAAW,EACX,QAAQ,EACR,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,KAAK,yBAAyB,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACnJ,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtD,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,QAAQ,EACR,KAAK,EACL,WAAW,EACX,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,KAAK,yBAAyB,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACnJ,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtD,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
@@ -41,27 +41,35 @@ __export(index_exports, {
|
|
|
41
41
|
compareScreenshots: () => compareScreenshots,
|
|
42
42
|
createBinaryStreamMock: () => createBinaryStreamMock,
|
|
43
43
|
createBinaryWriterMock: () => createBinaryWriterMock,
|
|
44
|
+
createCombatTestContext: () => createCombatTestContext,
|
|
44
45
|
createControlledTimer: () => createControlledTimer,
|
|
45
46
|
createCustomNetworkCondition: () => createCustomNetworkCondition,
|
|
46
47
|
createDeltaSnapshot: () => createDeltaSnapshot,
|
|
47
48
|
createEntity: () => createEntity,
|
|
49
|
+
createEntityFactory: () => createEntityFactory,
|
|
48
50
|
createEntityStateFactory: () => createEntityStateFactory,
|
|
49
51
|
createGameStateSnapshotFactory: () => createGameStateSnapshotFactory,
|
|
52
|
+
createItemEntityFactory: () => createItemEntityFactory,
|
|
53
|
+
createMockAI: () => createMockAI,
|
|
50
54
|
createMockAudioContext: () => createMockAudioContext,
|
|
51
55
|
createMockCanvas: () => createMockCanvas,
|
|
52
56
|
createMockCanvasContext2D: () => createMockCanvasContext2D,
|
|
53
57
|
createMockConnection: () => createMockConnection,
|
|
58
|
+
createMockDamageInfo: () => createMockDamageInfo,
|
|
54
59
|
createMockEngine: () => createMockEngine,
|
|
55
60
|
createMockGPUAdapter: () => createMockGPUAdapter,
|
|
56
61
|
createMockGPUCanvasContext: () => createMockGPUCanvasContext,
|
|
57
62
|
createMockGPUDevice: () => createMockGPUDevice,
|
|
58
63
|
createMockGame: () => createMockGame,
|
|
64
|
+
createMockGameExports: () => createMockGameExports,
|
|
59
65
|
createMockGameState: () => createMockGameState,
|
|
60
66
|
createMockHandshake: () => createMockHandshake,
|
|
61
67
|
createMockImage: () => createMockImage,
|
|
62
68
|
createMockImageData: () => createMockImageData,
|
|
63
69
|
createMockIndexedDB: () => createMockIndexedDB,
|
|
64
70
|
createMockLocalStorage: () => createMockLocalStorage,
|
|
71
|
+
createMockMonsterAI: () => createMockMonsterAI,
|
|
72
|
+
createMockMonsterMove: () => createMockMonsterMove,
|
|
65
73
|
createMockNetDriver: () => createMockNetDriver,
|
|
66
74
|
createMockNetworkAddress: () => createMockNetworkAddress,
|
|
67
75
|
createMockPerformance: () => createMockPerformance,
|
|
@@ -76,15 +84,21 @@ __export(index_exports, {
|
|
|
76
84
|
createMockTransport: () => createMockTransport,
|
|
77
85
|
createMockUDPSocket: () => createMockUDPSocket,
|
|
78
86
|
createMockUserInfo: () => createMockUserInfo,
|
|
87
|
+
createMockWeapon: () => createMockWeapon,
|
|
79
88
|
createMockWebGL2Context: () => createMockWebGL2Context,
|
|
89
|
+
createMonsterEntityFactory: () => createMonsterEntityFactory,
|
|
80
90
|
createMultiplayerTestScenario: () => createMultiplayerTestScenario,
|
|
81
91
|
createNetChanMock: () => createNetChanMock,
|
|
92
|
+
createPhysicsTestContext: () => createPhysicsTestContext,
|
|
93
|
+
createPlayerEntityFactory: () => createPlayerEntityFactory,
|
|
82
94
|
createPlayerStateFactory: () => createPlayerStateFactory,
|
|
83
95
|
createPlaywrightTestClient: () => createPlaywrightTestClient,
|
|
96
|
+
createProjectileEntityFactory: () => createProjectileEntityFactory,
|
|
84
97
|
createServerSnapshot: () => createServerSnapshot,
|
|
85
|
-
|
|
98
|
+
createSpawnTestContext: () => createSpawnTestContext,
|
|
86
99
|
createStorageTestScenario: () => createStorageTestScenario,
|
|
87
100
|
createTestContext: () => createTestContext,
|
|
101
|
+
createTriggerEntityFactory: () => createTriggerEntityFactory,
|
|
88
102
|
createVisualTestScenario: () => createVisualTestScenario,
|
|
89
103
|
intersects: () => import_shared3.intersects,
|
|
90
104
|
ladderTrace: () => import_shared3.ladderTrace,
|
|
@@ -95,6 +109,7 @@ __export(index_exports, {
|
|
|
95
109
|
makeLeafModel: () => makeLeafModel,
|
|
96
110
|
makeNode: () => makeNode,
|
|
97
111
|
makePlane: () => makePlane,
|
|
112
|
+
mockMonsterAttacks: () => mockMonsterAttacks,
|
|
98
113
|
serializeUserInfo: () => serializeUserInfo,
|
|
99
114
|
setupBrowserEnvironment: () => setupBrowserEnvironment,
|
|
100
115
|
setupMockAudioContext: () => setupMockAudioContext,
|
|
@@ -268,6 +283,7 @@ function makeBrushFromMinsMaxs(mins, maxs, contents = import_shared.CONTENTS_SOL
|
|
|
268
283
|
}
|
|
269
284
|
|
|
270
285
|
// src/game/factories.ts
|
|
286
|
+
var import_game = require("@quake2ts/game");
|
|
271
287
|
var createPlayerStateFactory = (overrides) => ({
|
|
272
288
|
pm_type: 0,
|
|
273
289
|
pm_time: 0,
|
|
@@ -350,10 +366,77 @@ var createGameStateSnapshotFactory = (overrides) => ({
|
|
|
350
366
|
pm_type: 0,
|
|
351
367
|
...overrides
|
|
352
368
|
});
|
|
369
|
+
function createEntityFactory(overrides = {}) {
|
|
370
|
+
const ent = new import_game.Entity(1);
|
|
371
|
+
Object.assign(ent, {
|
|
372
|
+
classname: "info_null",
|
|
373
|
+
health: 0,
|
|
374
|
+
max_health: 0,
|
|
375
|
+
takedamage: false,
|
|
376
|
+
deadflag: import_game.DeadFlag.Alive,
|
|
377
|
+
solid: import_game.Solid.Not,
|
|
378
|
+
movetype: import_game.MoveType.None,
|
|
379
|
+
flags: 0,
|
|
380
|
+
svflags: 0,
|
|
381
|
+
...overrides
|
|
382
|
+
});
|
|
383
|
+
return ent;
|
|
384
|
+
}
|
|
385
|
+
function createPlayerEntityFactory(overrides = {}) {
|
|
386
|
+
return createEntityFactory({
|
|
387
|
+
classname: "player",
|
|
388
|
+
health: 100,
|
|
389
|
+
max_health: 100,
|
|
390
|
+
takedamage: true,
|
|
391
|
+
solid: import_game.Solid.BoundingBox,
|
|
392
|
+
movetype: import_game.MoveType.Walk,
|
|
393
|
+
svflags: import_game.ServerFlags.Player,
|
|
394
|
+
viewheight: 22,
|
|
395
|
+
...overrides
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
function createMonsterEntityFactory(classname, overrides = {}) {
|
|
399
|
+
return createEntityFactory({
|
|
400
|
+
classname,
|
|
401
|
+
health: 100,
|
|
402
|
+
max_health: 100,
|
|
403
|
+
takedamage: true,
|
|
404
|
+
solid: import_game.Solid.BoundingBox,
|
|
405
|
+
movetype: import_game.MoveType.Step,
|
|
406
|
+
svflags: import_game.ServerFlags.Monster,
|
|
407
|
+
deadflag: import_game.DeadFlag.Alive,
|
|
408
|
+
...overrides
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
function createItemEntityFactory(classname, overrides = {}) {
|
|
412
|
+
return createEntityFactory({
|
|
413
|
+
classname,
|
|
414
|
+
solid: import_game.Solid.Trigger,
|
|
415
|
+
movetype: import_game.MoveType.Toss,
|
|
416
|
+
...overrides
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
function createProjectileEntityFactory(classname, overrides = {}) {
|
|
420
|
+
return createEntityFactory({
|
|
421
|
+
classname,
|
|
422
|
+
solid: import_game.Solid.Bsp,
|
|
423
|
+
movetype: import_game.MoveType.FlyMissile,
|
|
424
|
+
svflags: import_game.ServerFlags.Projectile,
|
|
425
|
+
...overrides
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function createTriggerEntityFactory(classname, overrides = {}) {
|
|
429
|
+
return createEntityFactory({
|
|
430
|
+
classname,
|
|
431
|
+
solid: import_game.Solid.Trigger,
|
|
432
|
+
movetype: import_game.MoveType.None,
|
|
433
|
+
...overrides
|
|
434
|
+
});
|
|
435
|
+
}
|
|
353
436
|
|
|
354
437
|
// src/game/helpers.ts
|
|
355
438
|
var import_vitest2 = require("vitest");
|
|
356
|
-
var
|
|
439
|
+
var import_game2 = require("@quake2ts/game");
|
|
357
440
|
var import_shared2 = require("@quake2ts/shared");
|
|
358
441
|
var import_shared3 = require("@quake2ts/shared");
|
|
359
442
|
var createMockEngine = () => ({
|
|
@@ -363,8 +446,8 @@ var createMockEngine = () => ({
|
|
|
363
446
|
centerprintf: import_vitest2.vi.fn()
|
|
364
447
|
});
|
|
365
448
|
var createMockGame = (seed = 12345) => {
|
|
366
|
-
const spawnRegistry = new
|
|
367
|
-
const hooks = new
|
|
449
|
+
const spawnRegistry = new import_game2.SpawnRegistry();
|
|
450
|
+
const hooks = new import_game2.ScriptHookRegistry();
|
|
368
451
|
const game = {
|
|
369
452
|
random: (0, import_shared2.createRandomGenerator)({ seed }),
|
|
370
453
|
registerEntitySpawn: import_vitest2.vi.fn((classname, spawnFunc) => {
|
|
@@ -406,7 +489,7 @@ function createTestContext(options) {
|
|
|
406
489
|
const hooks = game.hooks;
|
|
407
490
|
const entities = {
|
|
408
491
|
spawn: import_vitest2.vi.fn(() => {
|
|
409
|
-
const ent = new
|
|
492
|
+
const ent = new import_game2.Entity(entityList.length + 1);
|
|
410
493
|
entityList.push(ent);
|
|
411
494
|
hooks.onEntitySpawn(ent);
|
|
412
495
|
return ent;
|
|
@@ -485,7 +568,7 @@ function createTestContext(options) {
|
|
|
485
568
|
deathmatch: false,
|
|
486
569
|
coop: false,
|
|
487
570
|
activeCount: entityList.length,
|
|
488
|
-
world: entityList.find((e) => e.classname === "worldspawn") || new
|
|
571
|
+
world: entityList.find((e) => e.classname === "worldspawn") || new import_game2.Entity(0)
|
|
489
572
|
// ... other EntitySystem properties would go here
|
|
490
573
|
};
|
|
491
574
|
return {
|
|
@@ -502,14 +585,115 @@ function createTestContext(options) {
|
|
|
502
585
|
precacheImage: import_vitest2.vi.fn()
|
|
503
586
|
};
|
|
504
587
|
}
|
|
505
|
-
function
|
|
588
|
+
function createSpawnTestContext(mapName) {
|
|
589
|
+
const ctx = createTestContext();
|
|
590
|
+
if (mapName) {
|
|
591
|
+
ctx.game.spawnWorld();
|
|
592
|
+
}
|
|
593
|
+
return ctx;
|
|
594
|
+
}
|
|
595
|
+
function createCombatTestContext() {
|
|
596
|
+
return createTestContext();
|
|
597
|
+
}
|
|
598
|
+
function createPhysicsTestContext() {
|
|
506
599
|
return createTestContext();
|
|
507
600
|
}
|
|
508
601
|
function createEntity() {
|
|
509
|
-
return new
|
|
602
|
+
return new import_game2.Entity(1);
|
|
510
603
|
}
|
|
511
604
|
|
|
605
|
+
// src/game/mocks/ai.ts
|
|
606
|
+
var import_vitest3 = require("vitest");
|
|
607
|
+
function createMockAI(overrides = {}) {
|
|
608
|
+
return {
|
|
609
|
+
checkAttack: import_vitest3.vi.fn(() => false),
|
|
610
|
+
findTarget: import_vitest3.vi.fn(() => null),
|
|
611
|
+
visible: import_vitest3.vi.fn(() => true),
|
|
612
|
+
infront: import_vitest3.vi.fn(() => true),
|
|
613
|
+
...overrides
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function createMockMonsterAI(overrides = {}) {
|
|
617
|
+
return {
|
|
618
|
+
stand: import_vitest3.vi.fn(),
|
|
619
|
+
walk: import_vitest3.vi.fn(),
|
|
620
|
+
run: import_vitest3.vi.fn(),
|
|
621
|
+
dodge: import_vitest3.vi.fn(),
|
|
622
|
+
attack: import_vitest3.vi.fn(),
|
|
623
|
+
melee: import_vitest3.vi.fn(),
|
|
624
|
+
sight: import_vitest3.vi.fn(),
|
|
625
|
+
idle: import_vitest3.vi.fn(),
|
|
626
|
+
...overrides
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
function createMockMonsterMove(first, last, think, action) {
|
|
630
|
+
const frames = [];
|
|
631
|
+
for (let i = first; i <= last; i++) {
|
|
632
|
+
frames.push({
|
|
633
|
+
ai: action,
|
|
634
|
+
dist: 0,
|
|
635
|
+
think
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
return {
|
|
639
|
+
firstframe: first,
|
|
640
|
+
lastframe: last,
|
|
641
|
+
frames,
|
|
642
|
+
endfunc: null
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// src/game/mocks/combat.ts
|
|
647
|
+
var import_vitest4 = require("vitest");
|
|
648
|
+
var import_game3 = require("@quake2ts/game");
|
|
649
|
+
function createMockDamageInfo(overrides = {}) {
|
|
650
|
+
return {
|
|
651
|
+
damage: 10,
|
|
652
|
+
mod: import_game3.DamageMod.UNKNOWN,
|
|
653
|
+
knockback: 0,
|
|
654
|
+
attacker: null,
|
|
655
|
+
inflictor: null,
|
|
656
|
+
dir: null,
|
|
657
|
+
point: null,
|
|
658
|
+
...overrides
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
var WEAPON_NAMES = {
|
|
662
|
+
"weapon_blaster": "Blaster",
|
|
663
|
+
"weapon_shotgun": "Shotgun",
|
|
664
|
+
"weapon_supershotgun": "Super Shotgun",
|
|
665
|
+
"weapon_machinegun": "Machinegun",
|
|
666
|
+
"weapon_chaingun": "Chaingun",
|
|
667
|
+
"weapon_grenadelauncher": "Grenade Launcher",
|
|
668
|
+
"weapon_rocketlauncher": "Rocket Launcher",
|
|
669
|
+
"weapon_hyperblaster": "HyperBlaster",
|
|
670
|
+
"weapon_railgun": "Railgun",
|
|
671
|
+
"weapon_bfg": "BFG10K"
|
|
672
|
+
};
|
|
673
|
+
function createMockWeapon(name = "Mock Weapon") {
|
|
674
|
+
const displayName = WEAPON_NAMES[name] || name;
|
|
675
|
+
return {
|
|
676
|
+
name: displayName,
|
|
677
|
+
ammoType: "bullets",
|
|
678
|
+
ammoUse: 1,
|
|
679
|
+
selection: import_vitest4.vi.fn(),
|
|
680
|
+
think: import_vitest4.vi.fn(),
|
|
681
|
+
command: import_vitest4.vi.fn()
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
var mockMonsterAttacks = {
|
|
685
|
+
fireBlaster: import_vitest4.vi.fn(),
|
|
686
|
+
fireRocket: import_vitest4.vi.fn(),
|
|
687
|
+
fireGrenade: import_vitest4.vi.fn(),
|
|
688
|
+
fireHeat: import_vitest4.vi.fn(),
|
|
689
|
+
fireBullet: import_vitest4.vi.fn(),
|
|
690
|
+
fireShotgun: import_vitest4.vi.fn(),
|
|
691
|
+
fireRailgun: import_vitest4.vi.fn(),
|
|
692
|
+
fireBFG: import_vitest4.vi.fn()
|
|
693
|
+
};
|
|
694
|
+
|
|
512
695
|
// src/game/mocks.ts
|
|
696
|
+
var import_vitest5 = require("vitest");
|
|
513
697
|
function createMockGameState(overrides) {
|
|
514
698
|
return {
|
|
515
699
|
levelName: "test_level",
|
|
@@ -519,9 +703,97 @@ function createMockGameState(overrides) {
|
|
|
519
703
|
...overrides
|
|
520
704
|
};
|
|
521
705
|
}
|
|
706
|
+
function createMockGameExports(overrides) {
|
|
707
|
+
return {
|
|
708
|
+
init: import_vitest5.vi.fn(),
|
|
709
|
+
shutdown: import_vitest5.vi.fn(),
|
|
710
|
+
spawnWorld: import_vitest5.vi.fn(),
|
|
711
|
+
frame: import_vitest5.vi.fn().mockReturnValue({ state: {} }),
|
|
712
|
+
clientConnect: import_vitest5.vi.fn().mockReturnValue(true),
|
|
713
|
+
clientBegin: import_vitest5.vi.fn().mockReturnValue({ index: 1, origin: { x: 0, y: 0, z: 0 } }),
|
|
714
|
+
clientDisconnect: import_vitest5.vi.fn(),
|
|
715
|
+
clientThink: import_vitest5.vi.fn(),
|
|
716
|
+
// clientUserInfoChanged is not in GameExports
|
|
717
|
+
// clientCommand is not in GameExports (it's serverCommand?) No, clientCommand might be missing from interface but present in impl or legacy.
|
|
718
|
+
// Checking GameExports interface in src/index.ts:
|
|
719
|
+
/*
|
|
720
|
+
clientConnect(ent: Entity | null, userInfo: string): string | true;
|
|
721
|
+
clientBegin(client: PlayerClient): Entity;
|
|
722
|
+
clientDisconnect(ent: Entity): void;
|
|
723
|
+
clientThink(ent: Entity, cmd: UserCommand): void;
|
|
724
|
+
respawn(ent: Entity): void;
|
|
725
|
+
...
|
|
726
|
+
configstring(index: number, value: string): void;
|
|
727
|
+
serverCommand(cmd: string): void;
|
|
728
|
+
*/
|
|
729
|
+
respawn: import_vitest5.vi.fn(),
|
|
730
|
+
entities: {
|
|
731
|
+
getByIndex: import_vitest5.vi.fn(),
|
|
732
|
+
forEachEntity: import_vitest5.vi.fn(),
|
|
733
|
+
findByRadius: import_vitest5.vi.fn(),
|
|
734
|
+
find: import_vitest5.vi.fn(),
|
|
735
|
+
checkAnyCollision: import_vitest5.vi.fn(),
|
|
736
|
+
trace: import_vitest5.vi.fn(),
|
|
737
|
+
pointcontents: import_vitest5.vi.fn(),
|
|
738
|
+
link: import_vitest5.vi.fn(),
|
|
739
|
+
// linkentity mapped to link in EntitySystem? No, linkentity in imports, link/unlink in System.
|
|
740
|
+
unlink: import_vitest5.vi.fn(),
|
|
741
|
+
spawn: import_vitest5.vi.fn(),
|
|
742
|
+
free: import_vitest5.vi.fn(),
|
|
743
|
+
activeCount: 0,
|
|
744
|
+
world: { classname: "worldspawn" }
|
|
745
|
+
},
|
|
746
|
+
multicast: import_vitest5.vi.fn(),
|
|
747
|
+
unicast: import_vitest5.vi.fn(),
|
|
748
|
+
configstring: import_vitest5.vi.fn(),
|
|
749
|
+
serverCommand: import_vitest5.vi.fn(),
|
|
750
|
+
sound: import_vitest5.vi.fn(),
|
|
751
|
+
soundIndex: import_vitest5.vi.fn(),
|
|
752
|
+
centerprintf: import_vitest5.vi.fn(),
|
|
753
|
+
trace: import_vitest5.vi.fn(),
|
|
754
|
+
time: 0,
|
|
755
|
+
deathmatch: false,
|
|
756
|
+
skill: 1,
|
|
757
|
+
rogue: false,
|
|
758
|
+
xatrix: false,
|
|
759
|
+
coop: false,
|
|
760
|
+
friendlyFire: false,
|
|
761
|
+
random: {
|
|
762
|
+
next: import_vitest5.vi.fn(),
|
|
763
|
+
nextFloat: import_vitest5.vi.fn(),
|
|
764
|
+
range: import_vitest5.vi.fn(),
|
|
765
|
+
crandom: import_vitest5.vi.fn(),
|
|
766
|
+
getState: import_vitest5.vi.fn(),
|
|
767
|
+
setState: import_vitest5.vi.fn()
|
|
768
|
+
},
|
|
769
|
+
createSave: import_vitest5.vi.fn(),
|
|
770
|
+
loadSave: import_vitest5.vi.fn(),
|
|
771
|
+
serialize: import_vitest5.vi.fn(),
|
|
772
|
+
loadState: import_vitest5.vi.fn(),
|
|
773
|
+
setGodMode: import_vitest5.vi.fn(),
|
|
774
|
+
setNoclip: import_vitest5.vi.fn(),
|
|
775
|
+
setNotarget: import_vitest5.vi.fn(),
|
|
776
|
+
giveItem: import_vitest5.vi.fn(),
|
|
777
|
+
damage: import_vitest5.vi.fn(),
|
|
778
|
+
teleport: import_vitest5.vi.fn(),
|
|
779
|
+
registerHooks: import_vitest5.vi.fn(),
|
|
780
|
+
hooks: {
|
|
781
|
+
onMapLoad: import_vitest5.vi.fn(),
|
|
782
|
+
onMapUnload: import_vitest5.vi.fn(),
|
|
783
|
+
onPlayerSpawn: import_vitest5.vi.fn(),
|
|
784
|
+
onPlayerDeath: import_vitest5.vi.fn(),
|
|
785
|
+
register: import_vitest5.vi.fn()
|
|
786
|
+
},
|
|
787
|
+
setSpectator: import_vitest5.vi.fn(),
|
|
788
|
+
registerEntitySpawn: import_vitest5.vi.fn(),
|
|
789
|
+
unregisterEntitySpawn: import_vitest5.vi.fn(),
|
|
790
|
+
getCustomEntities: import_vitest5.vi.fn(),
|
|
791
|
+
...overrides
|
|
792
|
+
};
|
|
793
|
+
}
|
|
522
794
|
|
|
523
795
|
// src/server/mocks/transport.ts
|
|
524
|
-
var
|
|
796
|
+
var import_vitest6 = require("vitest");
|
|
525
797
|
var MockTransport = class {
|
|
526
798
|
constructor() {
|
|
527
799
|
this.address = "127.0.0.1";
|
|
@@ -529,11 +801,11 @@ var MockTransport = class {
|
|
|
529
801
|
this.sentMessages = [];
|
|
530
802
|
this.receivedMessages = [];
|
|
531
803
|
this.listening = false;
|
|
532
|
-
this.listenSpy =
|
|
804
|
+
this.listenSpy = import_vitest6.vi.fn().mockImplementation(async (port) => {
|
|
533
805
|
this.port = port;
|
|
534
806
|
this.listening = true;
|
|
535
807
|
});
|
|
536
|
-
this.closeSpy =
|
|
808
|
+
this.closeSpy = import_vitest6.vi.fn().mockImplementation(() => {
|
|
537
809
|
this.listening = false;
|
|
538
810
|
});
|
|
539
811
|
}
|
|
@@ -589,11 +861,11 @@ var MockTransport = class {
|
|
|
589
861
|
};
|
|
590
862
|
function createMockUDPSocket(overrides) {
|
|
591
863
|
const socket = {
|
|
592
|
-
send:
|
|
593
|
-
on:
|
|
594
|
-
close:
|
|
595
|
-
bind:
|
|
596
|
-
address:
|
|
864
|
+
send: import_vitest6.vi.fn(),
|
|
865
|
+
on: import_vitest6.vi.fn(),
|
|
866
|
+
close: import_vitest6.vi.fn(),
|
|
867
|
+
bind: import_vitest6.vi.fn(),
|
|
868
|
+
address: import_vitest6.vi.fn().mockReturnValue({ address: "127.0.0.1", family: "IPv4", port: 0 }),
|
|
597
869
|
...overrides
|
|
598
870
|
};
|
|
599
871
|
return socket;
|
|
@@ -610,13 +882,13 @@ function createMockTransport(address = "127.0.0.1", port = 27910, overrides) {
|
|
|
610
882
|
}
|
|
611
883
|
function createMockNetDriver(overrides) {
|
|
612
884
|
return {
|
|
613
|
-
connect:
|
|
614
|
-
disconnect:
|
|
615
|
-
send:
|
|
616
|
-
onMessage:
|
|
617
|
-
onClose:
|
|
618
|
-
onError:
|
|
619
|
-
isConnected:
|
|
885
|
+
connect: import_vitest6.vi.fn().mockResolvedValue(void 0),
|
|
886
|
+
disconnect: import_vitest6.vi.fn(),
|
|
887
|
+
send: import_vitest6.vi.fn(),
|
|
888
|
+
onMessage: import_vitest6.vi.fn(),
|
|
889
|
+
onClose: import_vitest6.vi.fn(),
|
|
890
|
+
onError: import_vitest6.vi.fn(),
|
|
891
|
+
isConnected: import_vitest6.vi.fn().mockReturnValue(true),
|
|
620
892
|
...overrides
|
|
621
893
|
};
|
|
622
894
|
}
|
|
@@ -624,7 +896,7 @@ function createMockNetDriver(overrides) {
|
|
|
624
896
|
// src/server/mocks/state.ts
|
|
625
897
|
var import_server = require("@quake2ts/server");
|
|
626
898
|
var import_shared4 = require("@quake2ts/shared");
|
|
627
|
-
var
|
|
899
|
+
var import_vitest7 = require("vitest");
|
|
628
900
|
function createMockServerState(overrides) {
|
|
629
901
|
return {
|
|
630
902
|
state: import_server.ServerState.Game,
|
|
@@ -666,13 +938,13 @@ function createMockServerClient(clientNum, overrides) {
|
|
|
666
938
|
incomingSequence: 0,
|
|
667
939
|
outgoingSequence: 0,
|
|
668
940
|
lastReceived: 0,
|
|
669
|
-
process:
|
|
670
|
-
transmit:
|
|
671
|
-
writeReliableByte:
|
|
672
|
-
writeReliableShort:
|
|
673
|
-
writeReliableLong:
|
|
674
|
-
writeReliableString:
|
|
675
|
-
writeReliableData:
|
|
941
|
+
process: import_vitest7.vi.fn(),
|
|
942
|
+
transmit: import_vitest7.vi.fn(),
|
|
943
|
+
writeReliableByte: import_vitest7.vi.fn(),
|
|
944
|
+
writeReliableShort: import_vitest7.vi.fn(),
|
|
945
|
+
writeReliableLong: import_vitest7.vi.fn(),
|
|
946
|
+
writeReliableString: import_vitest7.vi.fn(),
|
|
947
|
+
writeReliableData: import_vitest7.vi.fn()
|
|
676
948
|
},
|
|
677
949
|
// Cast as any because NetChan might be complex to fully mock here
|
|
678
950
|
userInfo: "",
|
|
@@ -714,13 +986,13 @@ function createMockServerClient(clientNum, overrides) {
|
|
|
714
986
|
}
|
|
715
987
|
function createMockServer(overrides) {
|
|
716
988
|
return {
|
|
717
|
-
start:
|
|
718
|
-
stop:
|
|
719
|
-
multicast:
|
|
720
|
-
unicast:
|
|
721
|
-
configstring:
|
|
722
|
-
kickPlayer:
|
|
723
|
-
changeMap:
|
|
989
|
+
start: import_vitest7.vi.fn().mockResolvedValue(void 0),
|
|
990
|
+
stop: import_vitest7.vi.fn(),
|
|
991
|
+
multicast: import_vitest7.vi.fn(),
|
|
992
|
+
unicast: import_vitest7.vi.fn(),
|
|
993
|
+
configstring: import_vitest7.vi.fn(),
|
|
994
|
+
kickPlayer: import_vitest7.vi.fn(),
|
|
995
|
+
changeMap: import_vitest7.vi.fn().mockResolvedValue(void 0),
|
|
724
996
|
...overrides
|
|
725
997
|
};
|
|
726
998
|
}
|
|
@@ -782,19 +1054,19 @@ async function simulateHandshake(client, server) {
|
|
|
782
1054
|
}
|
|
783
1055
|
|
|
784
1056
|
// src/server/mocks/commands.ts
|
|
785
|
-
var
|
|
1057
|
+
var import_vitest8 = require("vitest");
|
|
786
1058
|
function createMockServerConsole(overrides) {
|
|
787
1059
|
const outputBuffer = [];
|
|
788
1060
|
const commandBuffer = [];
|
|
789
1061
|
return {
|
|
790
|
-
exec:
|
|
1062
|
+
exec: import_vitest8.vi.fn((cmd) => {
|
|
791
1063
|
commandBuffer.push(cmd);
|
|
792
1064
|
return `Executed: ${cmd}`;
|
|
793
1065
|
}),
|
|
794
|
-
print:
|
|
1066
|
+
print: import_vitest8.vi.fn((text) => {
|
|
795
1067
|
outputBuffer.push(text);
|
|
796
1068
|
}),
|
|
797
|
-
broadcast:
|
|
1069
|
+
broadcast: import_vitest8.vi.fn((text) => {
|
|
798
1070
|
outputBuffer.push(`Broadcast: ${text}`);
|
|
799
1071
|
}),
|
|
800
1072
|
commandBuffer,
|
|
@@ -807,13 +1079,13 @@ function createMockRConClient(password = "") {
|
|
|
807
1079
|
connected: false,
|
|
808
1080
|
lastCommand: "",
|
|
809
1081
|
lastResponse: "",
|
|
810
|
-
connect:
|
|
1082
|
+
connect: import_vitest8.vi.fn(async (address, port, pwd) => {
|
|
811
1083
|
return pwd === password;
|
|
812
1084
|
}),
|
|
813
|
-
sendCommand:
|
|
1085
|
+
sendCommand: import_vitest8.vi.fn(async (cmd) => {
|
|
814
1086
|
return `RCON Response for: ${cmd}`;
|
|
815
1087
|
}),
|
|
816
|
-
disconnect:
|
|
1088
|
+
disconnect: import_vitest8.vi.fn()
|
|
817
1089
|
};
|
|
818
1090
|
}
|
|
819
1091
|
function simulateServerCommand(server, command) {
|
|
@@ -1456,10 +1728,10 @@ function createMockImage(width, height, src) {
|
|
|
1456
1728
|
}
|
|
1457
1729
|
|
|
1458
1730
|
// src/engine/mocks/webgpu.ts
|
|
1459
|
-
var
|
|
1731
|
+
var import_vitest9 = require("vitest");
|
|
1460
1732
|
function createMockGPUAdapter() {
|
|
1461
1733
|
return {
|
|
1462
|
-
requestDevice:
|
|
1734
|
+
requestDevice: import_vitest9.vi.fn().mockResolvedValue(createMockGPUDevice()),
|
|
1463
1735
|
features: /* @__PURE__ */ new Set(),
|
|
1464
1736
|
limits: {}
|
|
1465
1737
|
};
|
|
@@ -1469,40 +1741,40 @@ function createMockGPUDevice() {
|
|
|
1469
1741
|
features: /* @__PURE__ */ new Set(),
|
|
1470
1742
|
limits: {},
|
|
1471
1743
|
queue: {
|
|
1472
|
-
submit:
|
|
1473
|
-
writeBuffer:
|
|
1474
|
-
writeTexture:
|
|
1475
|
-
copyExternalImageToTexture:
|
|
1476
|
-
},
|
|
1477
|
-
createCommandEncoder:
|
|
1478
|
-
beginRenderPass:
|
|
1479
|
-
setPipeline:
|
|
1480
|
-
draw:
|
|
1481
|
-
end:
|
|
1744
|
+
submit: import_vitest9.vi.fn(),
|
|
1745
|
+
writeBuffer: import_vitest9.vi.fn(),
|
|
1746
|
+
writeTexture: import_vitest9.vi.fn(),
|
|
1747
|
+
copyExternalImageToTexture: import_vitest9.vi.fn()
|
|
1748
|
+
},
|
|
1749
|
+
createCommandEncoder: import_vitest9.vi.fn().mockReturnValue({
|
|
1750
|
+
beginRenderPass: import_vitest9.vi.fn().mockReturnValue({
|
|
1751
|
+
setPipeline: import_vitest9.vi.fn(),
|
|
1752
|
+
draw: import_vitest9.vi.fn(),
|
|
1753
|
+
end: import_vitest9.vi.fn()
|
|
1482
1754
|
}),
|
|
1483
|
-
finish:
|
|
1755
|
+
finish: import_vitest9.vi.fn()
|
|
1484
1756
|
}),
|
|
1485
|
-
createRenderPipeline:
|
|
1486
|
-
createShaderModule:
|
|
1487
|
-
createBindGroup:
|
|
1488
|
-
createBindGroupLayout:
|
|
1489
|
-
createBuffer:
|
|
1490
|
-
createTexture:
|
|
1491
|
-
createSampler:
|
|
1757
|
+
createRenderPipeline: import_vitest9.vi.fn(),
|
|
1758
|
+
createShaderModule: import_vitest9.vi.fn(),
|
|
1759
|
+
createBindGroup: import_vitest9.vi.fn(),
|
|
1760
|
+
createBindGroupLayout: import_vitest9.vi.fn(),
|
|
1761
|
+
createBuffer: import_vitest9.vi.fn(),
|
|
1762
|
+
createTexture: import_vitest9.vi.fn(),
|
|
1763
|
+
createSampler: import_vitest9.vi.fn()
|
|
1492
1764
|
};
|
|
1493
1765
|
}
|
|
1494
1766
|
function createMockGPUCanvasContext() {
|
|
1495
1767
|
return {
|
|
1496
|
-
configure:
|
|
1497
|
-
unconfigure:
|
|
1498
|
-
getCurrentTexture:
|
|
1768
|
+
configure: import_vitest9.vi.fn(),
|
|
1769
|
+
unconfigure: import_vitest9.vi.fn(),
|
|
1770
|
+
getCurrentTexture: import_vitest9.vi.fn()
|
|
1499
1771
|
};
|
|
1500
1772
|
}
|
|
1501
1773
|
function setupWebGPUMocks() {
|
|
1502
1774
|
const mockAdapter = createMockGPUAdapter();
|
|
1503
1775
|
const mockGpu = {
|
|
1504
|
-
requestAdapter:
|
|
1505
|
-
getPreferredCanvasFormat:
|
|
1776
|
+
requestAdapter: import_vitest9.vi.fn().mockResolvedValue(mockAdapter),
|
|
1777
|
+
getPreferredCanvasFormat: import_vitest9.vi.fn().mockReturnValue("bgra8unorm")
|
|
1506
1778
|
};
|
|
1507
1779
|
Object.defineProperty(global.navigator, "gpu", {
|
|
1508
1780
|
value: mockGpu,
|
|
@@ -2119,27 +2391,35 @@ function createVisualTestScenario(page, sceneName) {
|
|
|
2119
2391
|
compareScreenshots,
|
|
2120
2392
|
createBinaryStreamMock,
|
|
2121
2393
|
createBinaryWriterMock,
|
|
2394
|
+
createCombatTestContext,
|
|
2122
2395
|
createControlledTimer,
|
|
2123
2396
|
createCustomNetworkCondition,
|
|
2124
2397
|
createDeltaSnapshot,
|
|
2125
2398
|
createEntity,
|
|
2399
|
+
createEntityFactory,
|
|
2126
2400
|
createEntityStateFactory,
|
|
2127
2401
|
createGameStateSnapshotFactory,
|
|
2402
|
+
createItemEntityFactory,
|
|
2403
|
+
createMockAI,
|
|
2128
2404
|
createMockAudioContext,
|
|
2129
2405
|
createMockCanvas,
|
|
2130
2406
|
createMockCanvasContext2D,
|
|
2131
2407
|
createMockConnection,
|
|
2408
|
+
createMockDamageInfo,
|
|
2132
2409
|
createMockEngine,
|
|
2133
2410
|
createMockGPUAdapter,
|
|
2134
2411
|
createMockGPUCanvasContext,
|
|
2135
2412
|
createMockGPUDevice,
|
|
2136
2413
|
createMockGame,
|
|
2414
|
+
createMockGameExports,
|
|
2137
2415
|
createMockGameState,
|
|
2138
2416
|
createMockHandshake,
|
|
2139
2417
|
createMockImage,
|
|
2140
2418
|
createMockImageData,
|
|
2141
2419
|
createMockIndexedDB,
|
|
2142
2420
|
createMockLocalStorage,
|
|
2421
|
+
createMockMonsterAI,
|
|
2422
|
+
createMockMonsterMove,
|
|
2143
2423
|
createMockNetDriver,
|
|
2144
2424
|
createMockNetworkAddress,
|
|
2145
2425
|
createMockPerformance,
|
|
@@ -2154,15 +2434,21 @@ function createVisualTestScenario(page, sceneName) {
|
|
|
2154
2434
|
createMockTransport,
|
|
2155
2435
|
createMockUDPSocket,
|
|
2156
2436
|
createMockUserInfo,
|
|
2437
|
+
createMockWeapon,
|
|
2157
2438
|
createMockWebGL2Context,
|
|
2439
|
+
createMonsterEntityFactory,
|
|
2158
2440
|
createMultiplayerTestScenario,
|
|
2159
2441
|
createNetChanMock,
|
|
2442
|
+
createPhysicsTestContext,
|
|
2443
|
+
createPlayerEntityFactory,
|
|
2160
2444
|
createPlayerStateFactory,
|
|
2161
2445
|
createPlaywrightTestClient,
|
|
2446
|
+
createProjectileEntityFactory,
|
|
2162
2447
|
createServerSnapshot,
|
|
2163
|
-
|
|
2448
|
+
createSpawnTestContext,
|
|
2164
2449
|
createStorageTestScenario,
|
|
2165
2450
|
createTestContext,
|
|
2451
|
+
createTriggerEntityFactory,
|
|
2166
2452
|
createVisualTestScenario,
|
|
2167
2453
|
intersects,
|
|
2168
2454
|
ladderTrace,
|
|
@@ -2173,6 +2459,7 @@ function createVisualTestScenario(page, sceneName) {
|
|
|
2173
2459
|
makeLeafModel,
|
|
2174
2460
|
makeNode,
|
|
2175
2461
|
makePlane,
|
|
2462
|
+
mockMonsterAttacks,
|
|
2176
2463
|
serializeUserInfo,
|
|
2177
2464
|
setupBrowserEnvironment,
|
|
2178
2465
|
setupMockAudioContext,
|