quake2ts 0.0.268 → 0.0.269

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.
@@ -3302,6 +3302,9 @@ var EntitySystem = class {
3302
3302
  this.random = createRandomGenerator();
3303
3303
  this.currentTimeSeconds = 0;
3304
3304
  this.frameNumber = 0;
3305
+ // Persistent state for cross-level logic
3306
+ this.crossLevelFlags = 0;
3307
+ this.crossUnitFlags = 0;
3305
3308
  this.pool = new EntityPool(maxEntities);
3306
3309
  this.thinkScheduler = new ThinkScheduler();
3307
3310
  this.engine = engine;
@@ -3627,11 +3630,15 @@ var EntitySystem = class {
3627
3630
  sound2EntityIndex: this.targetAwareness.sound2Entity?.index ?? null,
3628
3631
  sound2EntityFrame: this.targetAwareness.sound2EntityFrame,
3629
3632
  sightClientIndex: this.targetAwareness.sightClient?.index ?? null
3630
- }
3633
+ },
3634
+ crossLevelFlags: this.crossLevelFlags,
3635
+ crossUnitFlags: this.crossUnitFlags
3631
3636
  };
3632
3637
  }
3633
3638
  restore(snapshot, callbackRegistry) {
3634
3639
  this.currentTimeSeconds = snapshot.timeSeconds;
3640
+ this.crossLevelFlags = snapshot.crossLevelFlags ?? 0;
3641
+ this.crossUnitFlags = snapshot.crossUnitFlags ?? 0;
3635
3642
  this.pool.restore(snapshot.pool);
3636
3643
  const indexToEntity = /* @__PURE__ */ new Map();
3637
3644
  for (const entity of this.pool) {
@@ -4832,9 +4839,54 @@ function registerTargetSpawns(registry) {
4832
4839
  entity.svflags |= 1 /* NoClient */;
4833
4840
  });
4834
4841
  registry.register("target_laser", (entity, context) => {
4842
+ entity.think = (self) => target_laser_start(self, context);
4835
4843
  entity.think = (self) => target_laser_start(self, context);
4836
4844
  entity.nextthink = context.entities.timeSeconds + 1;
4837
4845
  });
4846
+ registry.register("target_crosslevel_trigger", (entity, context) => {
4847
+ entity.svflags |= 1 /* NoClient */;
4848
+ entity.use = (self) => {
4849
+ context.entities.crossLevelFlags |= self.spawnflags;
4850
+ context.free(self);
4851
+ };
4852
+ });
4853
+ registry.register("target_crosslevel_target", (entity, context) => {
4854
+ entity.svflags |= 1 /* NoClient */;
4855
+ if (!entity.delay) {
4856
+ entity.delay = 1;
4857
+ }
4858
+ const SFL_CROSS_TRIGGER_MASK = 4294967295;
4859
+ entity.think = (self) => {
4860
+ const flags = self.spawnflags & SFL_CROSS_TRIGGER_MASK;
4861
+ if ((context.entities.crossLevelFlags & flags) === flags) {
4862
+ context.entities.useTargets(self, self);
4863
+ context.free(self);
4864
+ }
4865
+ };
4866
+ context.entities.scheduleThink(entity, context.entities.timeSeconds + entity.delay);
4867
+ });
4868
+ registry.register("target_crossunit_trigger", (entity, context) => {
4869
+ entity.svflags |= 1 /* NoClient */;
4870
+ entity.use = (self) => {
4871
+ context.entities.crossUnitFlags |= self.spawnflags;
4872
+ context.free(self);
4873
+ };
4874
+ });
4875
+ registry.register("target_crossunit_target", (entity, context) => {
4876
+ entity.svflags |= 1 /* NoClient */;
4877
+ if (!entity.delay) {
4878
+ entity.delay = 1;
4879
+ }
4880
+ const SFL_CROSS_TRIGGER_MASK = 4294967295;
4881
+ entity.think = (self) => {
4882
+ const flags = self.spawnflags & SFL_CROSS_TRIGGER_MASK;
4883
+ if ((context.entities.crossUnitFlags & flags) === flags) {
4884
+ context.entities.useTargets(self, self);
4885
+ context.free(self);
4886
+ }
4887
+ };
4888
+ context.entities.scheduleThink(entity, context.entities.timeSeconds + entity.delay);
4889
+ });
4838
4890
  }
4839
4891
 
4840
4892
  // src/entities/triggers.ts
@@ -14898,7 +14950,9 @@ function parseEntitySnapshot(raw) {
14898
14950
  pool: parsePool(snapshot.pool),
14899
14951
  entities: parseEntities(snapshot.entities),
14900
14952
  thinks: parseThinkEntries(snapshot.thinks),
14901
- awareness: parseAwareness(snapshot.awareness)
14953
+ awareness: parseAwareness(snapshot.awareness),
14954
+ crossLevelFlags: ensureNumberOrDefault(snapshot.crossLevelFlags, "entities.crossLevelFlags", 0),
14955
+ crossUnitFlags: ensureNumberOrDefault(snapshot.crossUnitFlags, "entities.crossUnitFlags", 0)
14902
14956
  };
14903
14957
  }
14904
14958
  function parseCvars(raw) {
@@ -15259,7 +15313,9 @@ function buildEntitySnapshot(entities, levelTimeSeconds, capacityHint) {
15259
15313
  pool: { capacity, activeOrder, freeList, pendingFree: [] },
15260
15314
  entities: serialized,
15261
15315
  thinks: [],
15262
- awareness: dummyAwareness
15316
+ awareness: dummyAwareness,
15317
+ crossLevelFlags: 0,
15318
+ crossUnitFlags: 0
15263
15319
  };
15264
15320
  }
15265
15321
  function buildLevelState(level) {