quake2ts 0.0.292 → 0.0.294

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.
@@ -8372,28 +8372,48 @@ var DemoPlaybackController = class {
8372
8372
  setFrameDuration(ms) {
8373
8373
  this.frameDuration = ms;
8374
8374
  }
8375
+ setSpeed(speed) {
8376
+ this.playbackSpeed = Math.max(0.1, Math.min(speed, 16));
8377
+ }
8378
+ getSpeed() {
8379
+ return this.playbackSpeed;
8380
+ }
8375
8381
  update(dt) {
8376
8382
  if (this.state !== 1 || !this.reader) {
8377
8383
  return;
8378
8384
  }
8379
8385
  this.accumulatedTime += dt * 1e3 * this.playbackSpeed;
8380
8386
  while (this.accumulatedTime >= this.frameDuration) {
8381
- if (!this.reader.hasMore()) {
8382
- this.state = 3;
8383
- return;
8384
- }
8385
- const block = this.reader.readNextBlock();
8386
- if (!block) {
8387
- this.state = 3;
8387
+ const hasMore = this.processNextFrame();
8388
+ if (!hasMore) {
8388
8389
  return;
8389
8390
  }
8390
- const parser = new NetworkMessageParser(block.data, this.handler);
8391
- parser.setProtocolVersion(this.currentProtocolVersion);
8392
- parser.parseMessage();
8393
- this.currentProtocolVersion = parser.getProtocolVersion();
8394
8391
  this.accumulatedTime -= this.frameDuration;
8395
8392
  }
8396
8393
  }
8394
+ stepForward() {
8395
+ if (!this.reader) return;
8396
+ this.processNextFrame();
8397
+ }
8398
+ stepBackward() {
8399
+ console.warn("stepBackward not implemented");
8400
+ }
8401
+ processNextFrame() {
8402
+ if (!this.reader || !this.reader.hasMore()) {
8403
+ this.state = 3;
8404
+ return false;
8405
+ }
8406
+ const block = this.reader.readNextBlock();
8407
+ if (!block) {
8408
+ this.state = 3;
8409
+ return false;
8410
+ }
8411
+ const parser = new NetworkMessageParser(block.data, this.handler);
8412
+ parser.setProtocolVersion(this.currentProtocolVersion);
8413
+ parser.parseMessage();
8414
+ this.currentProtocolVersion = parser.getProtocolVersion();
8415
+ return true;
8416
+ }
8397
8417
  getState() {
8398
8418
  return this.state;
8399
8419
  }