diff --git a/src/scenes/door/NightScene.ts b/src/scenes/door/NightScene.ts index 4726c25..8ee2706 100644 --- a/src/scenes/door/NightScene.ts +++ b/src/scenes/door/NightScene.ts @@ -310,7 +310,17 @@ export class NightScene extends Phaser.Scene { // Door and Floor BOTH run all night; the flags below decide which one // the player is inhabiting. Floor starts hidden. // The roster decides where you stand when the doors open (design ยง6). - this.time.delayedCall(0, () => this.applyLocation(this.role.startLoc)); + this.time.delayedCall(0, () => { + this.applyLocation(this.role.startLoc); + // ...and ANNOUNCE it. applyLocation only moves flags; the room latches + // onto the event. FloorDemoScene reads `present` when it binds this + // context, which โ€” now that the night preloads every prop texture โ€” + // happens before this runs, so a floor-start shift (bartender, glassie, + // DJ) came up visible but completely inert, and the audio filter stayed + // in door mode while you stood on the dancefloor. + this.bus.emit('night:phaseChange', { location: this.role.startLoc }); + this.bus.emit('audio:location', { location: this.role.startLoc }); + }); }; if (missing.length === 0) return launch(); for (const k of missing) this.load.image(`gen:prop:${k}`, `props/${k}.png`); diff --git a/src/scenes/floor/FloorDemoScene.ts b/src/scenes/floor/FloorDemoScene.ts index 63d3a28..18880ce 100644 --- a/src/scenes/floor/FloorDemoScene.ts +++ b/src/scenes/floor/FloorDemoScene.ts @@ -203,6 +203,7 @@ export class FloorDemoScene extends Phaser.Scene { create(data?: { night?: NightContext }): void { this.nightCtx = data?.night ?? null; + this.resetNightState(); // Wired explicitly: Phaser does not invoke a `shutdown` METHOD on a Scene // subclass; without this, listeners and sprites leak on every scene stop. this.events.once(Phaser.Scenes.Events.SHUTDOWN, () => this.teardown()); @@ -217,6 +218,42 @@ export class FloorDemoScene extends Phaser.Scene { this.load.start(); } + /** + * Wipe everything that belongs to ONE night. + * + * Phaser reuses the scene instance across restarts, so class-field + * initialisers run exactly once in the lifetime of the game โ€” every field + * below would otherwise carry last night into this one. That is not + * theoretical: a DJ shift left `djMode` set, so the next night's floor booted + * with movement locked and the keyboard eaten; last night's puddles kept + * slipping people through sprites Phaser had already destroyed; and the + * handled-patron sets marked fresh arrivals as already dealt with, because + * patron ids restart with the run. + */ + private resetNightState(): void { + this.djMode = false; + this.djBuild = null; + this.barMode = false; + this.carryingCup = false; + this.mop = null; + // The graphics these referenced went down with the previous scene shutdown; + // dropping the references is the whole job. + this.puddles = []; + this.vomitCount = 0; + this.filming = null; + this.fainter = null; + this.rack = null; + this.escorting = null; + this.target = null; + this.liveFight = null; + this.uvMode = false; + this.jointDealt.clear(); + this.maggotSeen.clear(); + this.spotted.clear(); + this.cutOffDealt.clear(); + this.slipCooldown.clear(); + } + private loadGenProps(): void { const manifest = this.cache.json.get('propManifest') as { props?: string[] } | undefined; const kinds = manifest?.props ?? [];