determinism work

This commit is contained in:
Brandon Johnson
2026-01-31 14:09:07 -05:00
parent d30e0622cf
commit d5e5eeea6c

View File

@@ -336,6 +336,8 @@ export class Game {
public inputFeed: QuantizedStick[] | null;
public inputFeedIndex: number;
public inputRecord: QuantizedStick[] | null;
public fixedTickMode: boolean;
public fixedTicksPerUpdate: number;
constructor({
hud,
@@ -429,6 +431,8 @@ export class Game {
this.inputFeed = null;
this.inputFeedIndex = 0;
this.inputRecord = null;
this.fixedTickMode = false;
this.fixedTicksPerUpdate = 1;
}
setGameSource(source: GameSource) {
@@ -442,6 +446,11 @@ export class Game {
this.inputFeedIndex = 0;
}
setFixedTickMode(enabled: boolean, ticksPerUpdate = 1) {
this.fixedTickMode = enabled;
this.fixedTicksPerUpdate = Math.max(1, ticksPerUpdate | 0);
}
startInputRecording() {
this.inputRecord = [];
}
@@ -1774,6 +1783,8 @@ export class Game {
if (this.paused) {
this.accumulator = 0;
} else if (this.fixedTickMode) {
this.accumulator = this.fixedStep * this.fixedTicksPerUpdate;
} else {
this.accumulator = Math.min(this.accumulator + dtSeconds, this.fixedStep * MAX_FRAME_DELTA);
}