From 0bec0eb07adbc3a8e0f63a4916deb427ea560700 Mon Sep 17 00:00:00 2001 From: David Kotnik Date: Thu, 8 Jan 2026 16:15:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Jan=208=20Fix=20MasterWeatherSys?= =?UTF-8?q?tem=20Null=20Reference=20Error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ❌ BUG FIX #3 - Runtime Error: **Problem:** - MasterWeatherSystem.js:460 - rainEmitter.setSpeedX is not a function - No null check before accessing particle emitter methods - Crashed when entering GameScene (New Game) **Root Cause:** - Particle emitters not initialized yet when update() called - Missing method existence check **Solution:** - Added null checks: this.rainEmitter && this.snowEmitter - Added method existence check: typeof setSpeedX === 'function' - Prevents crash if emitters not ready **Changes:** - Line 458: Added null + method check for rainEmitter - Line 463: Added null + method check for snowEmitter ✅ Game now loads past menu into GameScene ✅ Ready for TestVisualAudioScene test **Test:** game.scene.start('TestVisualAudioScene') --- src/systems/MasterWeatherSystem.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/systems/MasterWeatherSystem.js b/src/systems/MasterWeatherSystem.js index 66345268d..a65fae97c 100644 --- a/src/systems/MasterWeatherSystem.js +++ b/src/systems/MasterWeatherSystem.js @@ -455,12 +455,13 @@ export default class MasterWeatherSystem { } // Update rain/snow particle positions based on wind - if (this.rainEmitter.active) { + // ✅ NULL CHECK: Ensure emitter exists and has setSpeedX method + if (this.rainEmitter && this.rainEmitter.active && typeof this.rainEmitter.setSpeedX === 'function') { const windInfluence = this.windSystem.wind.strength * 20; this.rainEmitter.setSpeedX({ min: -windInfluence, max: windInfluence }); } - if (this.snowEmitter.active) { + if (this.snowEmitter && this.snowEmitter.active && typeof this.snowEmitter.setSpeedX === 'function') { const windInfluence = this.windSystem.wind.strength * 30; this.snowEmitter.setSpeedX({ min: -windInfluence, max: windInfluence }); }