quake2ts 0.0.431 → 0.0.433

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.
Files changed (55) hide show
  1. package/package.json +1 -1
  2. package/packages/cgame/dist/index.cjs +27 -17
  3. package/packages/cgame/dist/index.cjs.map +1 -1
  4. package/packages/cgame/dist/index.d.cts +2 -0
  5. package/packages/cgame/dist/index.d.ts +2 -0
  6. package/packages/cgame/dist/index.js +27 -17
  7. package/packages/cgame/dist/index.js.map +1 -1
  8. package/packages/client/dist/browser/index.global.js +16 -16
  9. package/packages/client/dist/browser/index.global.js.map +1 -1
  10. package/packages/client/dist/cjs/index.cjs +9 -0
  11. package/packages/client/dist/cjs/index.cjs.map +1 -1
  12. package/packages/client/dist/esm/index.js +9 -0
  13. package/packages/client/dist/esm/index.js.map +1 -1
  14. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  15. package/packages/client/dist/types/index.d.ts.map +1 -1
  16. package/packages/client/dist/types/net/serverBrowser.d.ts +6 -0
  17. package/packages/client/dist/types/net/serverBrowser.d.ts.map +1 -1
  18. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  19. package/packages/engine/dist/types/render/debug.d.ts +1 -0
  20. package/packages/engine/dist/types/render/debug.d.ts.map +1 -1
  21. package/packages/engine/dist/types/render/renderer.d.ts.map +1 -1
  22. package/packages/game/dist/browser/index.global.js +4 -4
  23. package/packages/game/dist/browser/index.global.js.map +1 -1
  24. package/packages/game/dist/cjs/index.cjs +248 -77
  25. package/packages/game/dist/cjs/index.cjs.map +1 -1
  26. package/packages/game/dist/esm/index.js +248 -77
  27. package/packages/game/dist/esm/index.js.map +1 -1
  28. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  29. package/packages/game/dist/types/combat/weapons/chaingun.d.ts.map +1 -1
  30. package/packages/game/dist/types/combat/weapons/firing.d.ts +9 -0
  31. package/packages/game/dist/types/combat/weapons/firing.d.ts.map +1 -1
  32. package/packages/game/dist/types/combat/weapons/supershotgun.d.ts.map +1 -1
  33. package/packages/game/dist/types/entities/player.d.ts.map +1 -1
  34. package/packages/game/dist/types/entities/system.d.ts.map +1 -1
  35. package/packages/game/dist/types/imports.d.ts +2 -0
  36. package/packages/game/dist/types/imports.d.ts.map +1 -1
  37. package/packages/game/dist/types/index.d.ts +1 -0
  38. package/packages/game/dist/types/index.d.ts.map +1 -1
  39. package/packages/game/dist/types/inventory/playerInventory.d.ts +1 -0
  40. package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
  41. package/packages/game/dist/types/modes/ctf/capture.d.ts +7 -0
  42. package/packages/game/dist/types/modes/ctf/capture.d.ts.map +1 -0
  43. package/packages/game/dist/types/modes/ctf/drop.d.ts +8 -0
  44. package/packages/game/dist/types/modes/ctf/drop.d.ts.map +1 -0
  45. package/packages/game/dist/types/modes/ctf/flag.d.ts.map +1 -1
  46. package/packages/game/dist/types/modes/ctf/integration.d.ts +4 -0
  47. package/packages/game/dist/types/modes/ctf/integration.d.ts.map +1 -0
  48. package/packages/game/dist/types/modes/ctf/pickup.d.ts +6 -0
  49. package/packages/game/dist/types/modes/ctf/pickup.d.ts.map +1 -0
  50. package/packages/game/dist/types/modes/ctf/state.d.ts +15 -0
  51. package/packages/game/dist/types/modes/ctf/state.d.ts.map +1 -0
  52. package/packages/server/dist/index.cjs +122 -1
  53. package/packages/server/dist/index.d.cts +4 -0
  54. package/packages/server/dist/index.d.ts +4 -0
  55. package/packages/server/dist/index.js +122 -1
@@ -121,11 +121,13 @@ declare class ClientPrediction {
121
121
  private readonly settings;
122
122
  private readonly trace;
123
123
  private readonly pointContents;
124
+ private enabled;
124
125
  private baseFrame;
125
126
  private commands;
126
127
  private predicted;
127
128
  private predictionError;
128
129
  constructor(trace: PmoveTraceFn, pointContents: (p: Vec3) => number, settings?: Partial<PredictionSettings>);
130
+ setPredictionEnabled(enabled: boolean): void;
129
131
  setAuthoritative(frame: GameFrameResult<PredictionState>): PredictionState;
130
132
  getPredictionError(): Vec3;
131
133
  decayError(frametime: number): void;
@@ -121,11 +121,13 @@ declare class ClientPrediction {
121
121
  private readonly settings;
122
122
  private readonly trace;
123
123
  private readonly pointContents;
124
+ private enabled;
124
125
  private baseFrame;
125
126
  private commands;
126
127
  private predicted;
127
128
  private predictionError;
128
129
  constructor(trace: PmoveTraceFn, pointContents: (p: Vec3) => number, settings?: Partial<PredictionSettings>);
130
+ setPredictionEnabled(enabled: boolean): void;
129
131
  setAuthoritative(frame: GameFrameResult<PredictionState>): PredictionState;
130
132
  getPredictionError(): Vec3;
131
133
  decayError(frametime: number): void;
@@ -1053,6 +1053,7 @@ function simulateCommand(state, cmd, settings, trace, pointContents) {
1053
1053
  }
1054
1054
  var ClientPrediction = class {
1055
1055
  constructor(trace, pointContents, settings = {}) {
1056
+ this.enabled = true;
1056
1057
  this.baseFrame = {
1057
1058
  frame: 0,
1058
1059
  timeMs: 0,
@@ -1066,27 +1067,34 @@ var ClientPrediction = class {
1066
1067
  this.pointContents = pointContents;
1067
1068
  this.predicted = this.baseFrame.state ?? defaultPredictionState();
1068
1069
  }
1070
+ setPredictionEnabled(enabled) {
1071
+ this.enabled = enabled;
1072
+ }
1069
1073
  setAuthoritative(frame) {
1070
1074
  const normalized = normalizeState(frame.state);
1071
1075
  if (frame.frame <= this.baseFrame.frame) {
1072
1076
  return this.predicted;
1073
1077
  }
1074
- let predictedAtFrame;
1075
- const relevantCommands = this.commands.filter((c) => c.sequence <= frame.frame && c.sequence > this.baseFrame.frame);
1076
- if (relevantCommands.length > 0 || this.baseFrame.frame === frame.frame) {
1077
- let tempState = normalizeState(this.baseFrame.state);
1078
- for (const cmd of relevantCommands) {
1079
- tempState = simulateCommand(tempState, cmd, this.settings, this.trace, this.pointContents);
1078
+ if (this.enabled) {
1079
+ let predictedAtFrame;
1080
+ const relevantCommands = this.commands.filter((c) => c.sequence <= frame.frame && c.sequence > this.baseFrame.frame);
1081
+ if (relevantCommands.length > 0 || this.baseFrame.frame === frame.frame) {
1082
+ let tempState = normalizeState(this.baseFrame.state);
1083
+ for (const cmd of relevantCommands) {
1084
+ tempState = simulateCommand(tempState, cmd, this.settings, this.trace, this.pointContents);
1085
+ }
1086
+ predictedAtFrame = tempState;
1080
1087
  }
1081
- predictedAtFrame = tempState;
1082
- }
1083
- if (predictedAtFrame) {
1084
- const error = subtractVec3(predictedAtFrame.origin, normalized.origin);
1085
- const errorLen = lengthVec3(error);
1086
- if (errorLen > this.settings.errorSnapThreshold) {
1087
- this.predictionError = ZERO_VEC32;
1088
- } else if (errorLen > this.settings.errorTolerance) {
1089
- this.predictionError = error;
1088
+ if (predictedAtFrame) {
1089
+ const error = subtractVec3(predictedAtFrame.origin, normalized.origin);
1090
+ const errorLen = lengthVec3(error);
1091
+ if (errorLen > this.settings.errorSnapThreshold) {
1092
+ this.predictionError = ZERO_VEC32;
1093
+ } else if (errorLen > this.settings.errorTolerance) {
1094
+ this.predictionError = error;
1095
+ } else {
1096
+ this.predictionError = ZERO_VEC32;
1097
+ }
1090
1098
  } else {
1091
1099
  this.predictionError = ZERO_VEC32;
1092
1100
  }
@@ -1124,8 +1132,10 @@ var ClientPrediction = class {
1124
1132
  }
1125
1133
  recompute() {
1126
1134
  let state = normalizeState(this.baseFrame.state);
1127
- for (const cmd of this.commands) {
1128
- state = simulateCommand(state, cmd, this.settings, this.trace, this.pointContents);
1135
+ if (this.enabled) {
1136
+ for (const cmd of this.commands) {
1137
+ state = simulateCommand(state, cmd, this.settings, this.trace, this.pointContents);
1138
+ }
1129
1139
  }
1130
1140
  this.predicted = state;
1131
1141
  return state;