quake2ts 0.0.268 → 0.0.270

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.
@@ -3136,6 +3136,9 @@ var EntitySystem = class {
3136
3136
  this.random = createRandomGenerator();
3137
3137
  this.currentTimeSeconds = 0;
3138
3138
  this.frameNumber = 0;
3139
+ // Persistent state for cross-level logic
3140
+ this.crossLevelFlags = 0;
3141
+ this.crossUnitFlags = 0;
3139
3142
  this.pool = new EntityPool(maxEntities);
3140
3143
  this.thinkScheduler = new ThinkScheduler();
3141
3144
  this.engine = engine;
@@ -3461,11 +3464,15 @@ var EntitySystem = class {
3461
3464
  sound2EntityIndex: this.targetAwareness.sound2Entity?.index ?? null,
3462
3465
  sound2EntityFrame: this.targetAwareness.sound2EntityFrame,
3463
3466
  sightClientIndex: this.targetAwareness.sightClient?.index ?? null
3464
- }
3467
+ },
3468
+ crossLevelFlags: this.crossLevelFlags,
3469
+ crossUnitFlags: this.crossUnitFlags
3465
3470
  };
3466
3471
  }
3467
3472
  restore(snapshot, callbackRegistry) {
3468
3473
  this.currentTimeSeconds = snapshot.timeSeconds;
3474
+ this.crossLevelFlags = snapshot.crossLevelFlags ?? 0;
3475
+ this.crossUnitFlags = snapshot.crossUnitFlags ?? 0;
3469
3476
  this.pool.restore(snapshot.pool);
3470
3477
  const indexToEntity = /* @__PURE__ */ new Map();
3471
3478
  for (const entity of this.pool) {
@@ -4666,9 +4673,54 @@ function registerTargetSpawns(registry) {
4666
4673
  entity.svflags |= 1 /* NoClient */;
4667
4674
  });
4668
4675
  registry.register("target_laser", (entity, context) => {
4676
+ entity.think = (self) => target_laser_start(self, context);
4669
4677
  entity.think = (self) => target_laser_start(self, context);
4670
4678
  entity.nextthink = context.entities.timeSeconds + 1;
4671
4679
  });
4680
+ registry.register("target_crosslevel_trigger", (entity, context) => {
4681
+ entity.svflags |= 1 /* NoClient */;
4682
+ entity.use = (self) => {
4683
+ context.entities.crossLevelFlags |= self.spawnflags;
4684
+ context.free(self);
4685
+ };
4686
+ });
4687
+ registry.register("target_crosslevel_target", (entity, context) => {
4688
+ entity.svflags |= 1 /* NoClient */;
4689
+ if (!entity.delay) {
4690
+ entity.delay = 1;
4691
+ }
4692
+ const SFL_CROSS_TRIGGER_MASK = 4294967295;
4693
+ entity.think = (self) => {
4694
+ const flags = self.spawnflags & SFL_CROSS_TRIGGER_MASK;
4695
+ if ((context.entities.crossLevelFlags & flags) === flags) {
4696
+ context.entities.useTargets(self, self);
4697
+ context.free(self);
4698
+ }
4699
+ };
4700
+ context.entities.scheduleThink(entity, context.entities.timeSeconds + entity.delay);
4701
+ });
4702
+ registry.register("target_crossunit_trigger", (entity, context) => {
4703
+ entity.svflags |= 1 /* NoClient */;
4704
+ entity.use = (self) => {
4705
+ context.entities.crossUnitFlags |= self.spawnflags;
4706
+ context.free(self);
4707
+ };
4708
+ });
4709
+ registry.register("target_crossunit_target", (entity, context) => {
4710
+ entity.svflags |= 1 /* NoClient */;
4711
+ if (!entity.delay) {
4712
+ entity.delay = 1;
4713
+ }
4714
+ const SFL_CROSS_TRIGGER_MASK = 4294967295;
4715
+ entity.think = (self) => {
4716
+ const flags = self.spawnflags & SFL_CROSS_TRIGGER_MASK;
4717
+ if ((context.entities.crossUnitFlags & flags) === flags) {
4718
+ context.entities.useTargets(self, self);
4719
+ context.free(self);
4720
+ }
4721
+ };
4722
+ context.entities.scheduleThink(entity, context.entities.timeSeconds + entity.delay);
4723
+ });
4672
4724
  }
4673
4725
 
4674
4726
  // src/entities/triggers.ts
@@ -14732,7 +14784,9 @@ function parseEntitySnapshot(raw) {
14732
14784
  pool: parsePool(snapshot.pool),
14733
14785
  entities: parseEntities(snapshot.entities),
14734
14786
  thinks: parseThinkEntries(snapshot.thinks),
14735
- awareness: parseAwareness(snapshot.awareness)
14787
+ awareness: parseAwareness(snapshot.awareness),
14788
+ crossLevelFlags: ensureNumberOrDefault(snapshot.crossLevelFlags, "entities.crossLevelFlags", 0),
14789
+ crossUnitFlags: ensureNumberOrDefault(snapshot.crossUnitFlags, "entities.crossUnitFlags", 0)
14736
14790
  };
14737
14791
  }
14738
14792
  function parseCvars(raw) {
@@ -15093,7 +15147,9 @@ function buildEntitySnapshot(entities, levelTimeSeconds, capacityHint) {
15093
15147
  pool: { capacity, activeOrder, freeList, pendingFree: [] },
15094
15148
  entities: serialized,
15095
15149
  thinks: [],
15096
- awareness: dummyAwareness
15150
+ awareness: dummyAwareness,
15151
+ crossLevelFlags: 0,
15152
+ crossUnitFlags: 0
15097
15153
  };
15098
15154
  }
15099
15155
  function buildLevelState(level) {