feat: move state updates to page root

This commit is contained in:
2026-06-01 15:36:21 -03:00
parent 566a684bfa
commit d66c898f23
3 changed files with 22 additions and 12 deletions
+10 -5
View File
@@ -8,7 +8,11 @@ export const FEAR_SETTINGS = {
PLAYER_SPEED: 4,
FLASHLIGHT_INTENSITY_BASE: 8,
WALL_BUFFER: 0.6,
CREATURE_SPEED: 12,
CREATURE_SPEED: 8,
EVENT_NARROW_LOOP_COUNT: 1,
EVENT_RUST_LOOP_COUNT: 2,
EVENT_FINALE_LOOP_COUNT: 3
};
const listeners = new Set<() => void>();
@@ -30,10 +34,7 @@ export const fearState = {
},
update(delta: number) {
this.isRustActive = this.loopCount >= 3;
this.finaleTriggered = this.loopCount >= 4;
const targetWidth = this.loopCount >= 2 ? 2.5 : FEAR_SETTINGS.HALLWAY_WIDTH;
const targetWidth = this.loopCount >= FEAR_SETTINGS.EVENT_NARROW_LOOP_COUNT ? 2.5 : FEAR_SETTINGS.HALLWAY_WIDTH;
const newWidth = THREE.MathUtils.lerp(this.currentWidth, targetWidth, 2 * delta);
if (Math.abs(this.currentWidth - newWidth) > 0.001) {
@@ -44,6 +45,10 @@ export const fearState = {
registerLoop(direction: 'forward' | 'backward') {
this.loopCount += 1;
this.isRustActive = this.loopCount >= FEAR_SETTINGS.EVENT_RUST_LOOP_COUNT;
this.finaleTriggered = this.loopCount >= FEAR_SETTINGS.EVENT_FINALE_LOOP_COUNT;
this.emit();
},