quake2ts 0.0.437 → 0.0.438

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.
@@ -4373,6 +4373,41 @@ var SpatialGrid = class {
4373
4373
  }
4374
4374
  };
4375
4375
 
4376
+ // src/scripting/hooks.ts
4377
+ var ScriptHookRegistry = class {
4378
+ constructor() {
4379
+ this.hooks = {};
4380
+ }
4381
+ register(hooks) {
4382
+ this.hooks = { ...this.hooks, ...hooks };
4383
+ }
4384
+ // Getters for specific hooks to avoid full object access if performance critical
4385
+ get onMapLoad() {
4386
+ return this.hooks.onMapLoad;
4387
+ }
4388
+ get onMapUnload() {
4389
+ return this.hooks.onMapUnload;
4390
+ }
4391
+ get onPlayerSpawn() {
4392
+ return this.hooks.onPlayerSpawn;
4393
+ }
4394
+ get onPlayerDeath() {
4395
+ return this.hooks.onPlayerDeath;
4396
+ }
4397
+ get onEntitySpawn() {
4398
+ return this.hooks.onEntitySpawn;
4399
+ }
4400
+ get onEntityRemove() {
4401
+ return this.hooks.onEntityRemove;
4402
+ }
4403
+ get onDamage() {
4404
+ return this.hooks.onDamage;
4405
+ }
4406
+ get onPickup() {
4407
+ return this.hooks.onPickup;
4408
+ }
4409
+ };
4410
+
4376
4411
  // src/entities/system.ts
4377
4412
  function computeBounds(entity) {
4378
4413
  return {
@@ -4431,6 +4466,7 @@ var EntitySystem = class {
4431
4466
  this.currentTimeSeconds = 0;
4432
4467
  this.frameNumber = 0;
4433
4468
  this.spawnCount = 0;
4469
+ this.scriptHooks = new ScriptHookRegistry();
4434
4470
  // Persistent state for cross-level logic
4435
4471
  this.crossLevelFlags = 0;
4436
4472
  this.crossUnitFlags = 0;
@@ -4533,6 +4569,9 @@ var EntitySystem = class {
4533
4569
  setSpawnRegistry(registry) {
4534
4570
  this.spawnRegistry = registry;
4535
4571
  }
4572
+ registerEntityClass(classname, factory) {
4573
+ this.spawnRegistry?.register(classname, factory);
4574
+ }
4536
4575
  getSpawnFunction(classname) {
4537
4576
  return this.spawnRegistry?.get(classname);
4538
4577
  }
@@ -4583,9 +4622,11 @@ var EntitySystem = class {
4583
4622
  this.spawnCount++;
4584
4623
  ent.spawn_count = this.spawnCount;
4585
4624
  ent.timestamp = this.currentTimeSeconds;
4625
+ this.scriptHooks.onEntitySpawn?.(ent);
4586
4626
  return ent;
4587
4627
  }
4588
4628
  free(entity) {
4629
+ this.scriptHooks.onEntityRemove?.(entity);
4589
4630
  this.unregisterTarget(entity);
4590
4631
  this.thinkScheduler.cancel(entity);
4591
4632
  this.spatialGrid.remove(entity);