quake2ts 0.0.417 → 0.0.418

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.
@@ -13938,6 +13938,33 @@ var ClientEffectSystem = class {
13938
13938
  }
13939
13939
  };
13940
13940
 
13941
+ // src/blend.ts
13942
+ var createBlendState = () => ({
13943
+ damageAlpha: 0,
13944
+ bonusAlpha: 0,
13945
+ lastFlashes: 0
13946
+ });
13947
+ var updateBlend = (state, ps, dt, damageIntensity = 0) => {
13948
+ state.damageAlpha -= dt;
13949
+ if (state.damageAlpha < 0) state.damageAlpha = 0;
13950
+ if (damageIntensity > 0) {
13951
+ state.damageAlpha = damageIntensity;
13952
+ }
13953
+ state.bonusAlpha -= dt;
13954
+ if (state.bonusAlpha < 0) state.bonusAlpha = 0;
13955
+ const flashes = ps.stats ? ps.stats[PlayerStat.STAT_FLASHES] ?? 0 : 0;
13956
+ if (flashes !== state.lastFlashes) {
13957
+ state.bonusAlpha = 0.6;
13958
+ state.lastFlashes = flashes;
13959
+ }
13960
+ if (state.bonusAlpha > 0) {
13961
+ return [1, 1, 0, state.bonusAlpha * 0.3];
13962
+ } else if (state.damageAlpha > 0) {
13963
+ return [1, 0, 0, state.damageAlpha * 0.5];
13964
+ }
13965
+ return [0, 0, 0, 0];
13966
+ };
13967
+
13941
13968
  // src/input/bindings.ts
13942
13969
  var DEFAULT_BINDINGS = [
13943
13970
  { code: "KeyW", command: "+forward" },
@@ -14635,6 +14662,9 @@ function createClient(imports) {
14635
14662
  let pauseMenuFactory;
14636
14663
  let optionsFactory;
14637
14664
  const configStrings = new ClientConfigStrings();
14665
+ const blendState = createBlendState();
14666
+ let currentBlend = [0, 0, 0, 0];
14667
+ let pendingDamage = 0;
14638
14668
  let latestFrame;
14639
14669
  let lastRenderTime = 0;
14640
14670
  let clientInAutoDemo = false;
@@ -14706,6 +14736,9 @@ function createClient(imports) {
14706
14736
  if (pos) {
14707
14737
  effectSystem.onTempEntity(type, pos, time);
14708
14738
  }
14739
+ },
14740
+ onDamage: (indicators) => {
14741
+ pendingDamage = 0.5;
14709
14742
  }
14710
14743
  });
14711
14744
  demoPlayback.setHandler(demoHandler);
@@ -15016,7 +15049,16 @@ function createClient(imports) {
15016
15049
  }
15017
15050
  }
15018
15051
  const frameTimeMs = sample.latest && sample.previous ? Math.max(0, sample.latest.timeMs - sample.previous.timeMs) : 0;
15052
+ if (frameTimeMs > 0) {
15053
+ prediction.decayError(frameTimeMs / 1e3);
15054
+ }
15019
15055
  lastView = view.sample(lastRendered, frameTimeMs);
15056
+ if (lastRendered) {
15057
+ currentBlend = updateBlend(blendState, lastRendered, frameTimeMs / 1e3, pendingDamage);
15058
+ pendingDamage = 0;
15059
+ } else {
15060
+ currentBlend = [0, 0, 0, 0];
15061
+ }
15020
15062
  const command = {};
15021
15063
  const timeSeconds = sample.nowMs / 1e3;
15022
15064
  dlightManager.update(timeSeconds);
@@ -15111,7 +15153,7 @@ function createClient(imports) {
15111
15153
  maxs: { x: 16, y: 16, z: 32 },
15112
15154
  damageAlpha: lastRendered.damageAlpha ?? 0,
15113
15155
  damageIndicators: lastRendered.damageIndicators ?? [],
15114
- blend: lastRendered.blend ?? [0, 0, 0, 0],
15156
+ blend: currentBlend,
15115
15157
  pickupIcon: lastRendered.pickupIcon,
15116
15158
  centerPrint: void 0,
15117
15159
  // Handled by CGame MessageSystem now