quake2ts 0.0.96 → 0.0.97

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.
@@ -4232,6 +4232,50 @@ var ClientNetworkHandler = class {
4232
4232
  }
4233
4233
  };
4234
4234
 
4235
+ // src/configStrings.ts
4236
+ var ClientConfigStrings = class {
4237
+ constructor() {
4238
+ this.strings = /* @__PURE__ */ new Map();
4239
+ this.models = [];
4240
+ this.sounds = [];
4241
+ this.images = [];
4242
+ }
4243
+ /**
4244
+ * Called when a config string is received from the server.
4245
+ */
4246
+ set(index, value) {
4247
+ this.strings.set(index, value);
4248
+ if (index >= ConfigStringIndex2.Models && index < ConfigStringIndex2.Models + MAX_MODELS2) {
4249
+ const modelIndex = index - ConfigStringIndex2.Models;
4250
+ this.models[modelIndex] = value;
4251
+ } else if (index >= ConfigStringIndex2.Sounds && index < ConfigStringIndex2.Sounds + MAX_SOUNDS2) {
4252
+ const soundIndex = index - ConfigStringIndex2.Sounds;
4253
+ this.sounds[soundIndex] = value;
4254
+ } else if (index >= ConfigStringIndex2.Images && index < ConfigStringIndex2.Images + MAX_IMAGES2) {
4255
+ const imageIndex = index - ConfigStringIndex2.Images;
4256
+ this.images[imageIndex] = value;
4257
+ }
4258
+ }
4259
+ get(index) {
4260
+ return this.strings.get(index);
4261
+ }
4262
+ getModelName(index) {
4263
+ return this.models[index];
4264
+ }
4265
+ getSoundName(index) {
4266
+ return this.sounds[index];
4267
+ }
4268
+ getImageName(index) {
4269
+ return this.images[index];
4270
+ }
4271
+ clear() {
4272
+ this.strings.clear();
4273
+ this.models.length = 0;
4274
+ this.sounds.length = 0;
4275
+ this.images.length = 0;
4276
+ }
4277
+ };
4278
+
4235
4279
  // src/input/bindings.ts
4236
4280
  var DEFAULT_BINDINGS = [
4237
4281
  { code: "KeyW", command: "+forward" },
@@ -4727,13 +4771,17 @@ function createClient(imports) {
4727
4771
  const messageSystem = new MessageSystem();
4728
4772
  const demoPlayback = new DemoPlaybackController();
4729
4773
  const demoHandler = new ClientNetworkHandler();
4774
+ const configStrings = new ClientConfigStrings();
4730
4775
  demoPlayback.setHandler(demoHandler);
4731
4776
  let latestFrame;
4732
4777
  let lastRendered;
4733
4778
  let lastView;
4734
4779
  let camera;
4735
- return {
4780
+ const clientExports = {
4736
4781
  init(initial) {
4782
+ this.Init(initial);
4783
+ },
4784
+ Init(initial) {
4737
4785
  latestFrame = initial;
4738
4786
  if (initial?.state) {
4739
4787
  prediction.setAuthoritative(initial);
@@ -4779,35 +4827,41 @@ function createClient(imports) {
4779
4827
  fps: 0,
4780
4828
  vertexCount: 0
4781
4829
  };
4782
- const playerState = {
4783
- origin: lastRendered.origin,
4784
- velocity: lastRendered.velocity,
4785
- viewAngles: lastRendered.viewangles,
4786
- onGround: hasPmFlag(lastRendered.pmFlags, PmFlag.OnGround),
4787
- waterLevel: lastRendered.waterlevel,
4788
- mins: { x: -16, y: -16, z: -24 },
4789
- maxs: { x: 16, y: 16, z: 32 },
4790
- damageAlpha: 0,
4791
- damageIndicators: []
4792
- };
4793
4830
  const timeMs = sample.latest?.timeMs ?? 0;
4794
- Draw_Hud(
4795
- imports.engine.renderer,
4796
- playerState,
4797
- lastRendered.client,
4798
- lastRendered.health,
4799
- lastRendered.armor,
4800
- lastRendered.ammo,
4801
- stats,
4802
- messageSystem,
4803
- timeMs
4804
- );
4831
+ this.DrawHUD(stats, timeMs);
4805
4832
  }
4806
- void imports;
4807
- void sample;
4808
4833
  return command;
4809
4834
  },
4835
+ DrawHUD(stats, timeMs) {
4836
+ if (!imports.engine.renderer || !lastRendered || !lastRendered.client) return;
4837
+ const stateAsPlayerState = lastRendered;
4838
+ const playerState = {
4839
+ origin: lastRendered.origin,
4840
+ velocity: lastRendered.velocity,
4841
+ viewAngles: lastRendered.viewangles,
4842
+ onGround: hasPmFlag(lastRendered.pmFlags, PmFlag.OnGround),
4843
+ waterLevel: lastRendered.waterlevel,
4844
+ mins: { x: -16, y: -16, z: -24 },
4845
+ maxs: { x: 16, y: 16, z: 32 },
4846
+ damageAlpha: stateAsPlayerState.damageAlpha ?? 0,
4847
+ damageIndicators: stateAsPlayerState.damageIndicators ?? []
4848
+ };
4849
+ Draw_Hud(
4850
+ imports.engine.renderer,
4851
+ playerState,
4852
+ lastRendered.client,
4853
+ lastRendered.health,
4854
+ lastRendered.armor,
4855
+ lastRendered.ammo,
4856
+ stats,
4857
+ messageSystem,
4858
+ timeMs
4859
+ );
4860
+ },
4810
4861
  shutdown() {
4862
+ this.Shutdown();
4863
+ },
4864
+ Shutdown() {
4811
4865
  latestFrame = void 0;
4812
4866
  lastRendered = void 0;
4813
4867
  },
@@ -4835,10 +4889,16 @@ function createClient(imports) {
4835
4889
  const timeMs = latestFrame?.timeMs ?? 0;
4836
4890
  messageSystem.addNotify(msg, timeMs);
4837
4891
  },
4838
- demoHandler
4892
+ ParseConfigString(index, value) {
4893
+ configStrings.set(index, value);
4894
+ },
4895
+ demoHandler,
4896
+ configStrings
4839
4897
  };
4898
+ return clientExports;
4840
4899
  }
4841
4900
  export {
4901
+ ClientConfigStrings,
4842
4902
  ClientPrediction,
4843
4903
  InputAction,
4844
4904
  InputBindings,