From 18fa7af64877c33427586488d037afc400c28fcd Mon Sep 17 00:00:00 2001 From: NovaFarma Dev Date: Mon, 15 Dec 2025 17:14:36 +0100 Subject: [PATCH] Phase 28 Session 2: Biome-based terrain generation active! CRITICAL UPDATE - Switched to chunk-based biome rendering: Flat2DTerrainSystem.js changes: - generate() method now checks for BiomeSystem availability - If BiomeSystem & ChunkManager exist use chunk-based generation - If not available fallback to old Map2DData system - createBiomeBackground() creates simple base layer - Chunks are rendered on-demand via ChunkManager Flow: 1. Terrain system checks: biomeSystem && chunkManager 2. If YES Skip Map2DData, use chunks 3. Create green background (24000x24000px) 4. ChunkManager loads 9 chunks around player 5. Each chunk renders with biome-specific tiles Benefits: - Only renders visible chunks (9 instead of 250k tiles!) - Biome-specific tiles per chunk - Dynamic loading as player moves - Fallback to old system if needed Status: Ready for biome visualization test! Next: Reload game and see biomes! Files modified: 1 (Flat2DTerrainSystem.js) --- src/systems/Flat2DTerrainSystem.js | 56 +++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/src/systems/Flat2DTerrainSystem.js b/src/systems/Flat2DTerrainSystem.js index 9335b4b..b9565e8 100644 --- a/src/systems/Flat2DTerrainSystem.js +++ b/src/systems/Flat2DTerrainSystem.js @@ -35,21 +35,59 @@ class Flat2DTerrainSystem { // Create textures first this.createTileTextures(); - // Load map data - if (typeof Map2DData !== 'undefined') { - this.tiles = Map2DData.generateMap(); - console.log('✅ Map data generated:', this.tiles.length, 'rows'); + // 🌍 PHASE 28: Use BiomeSystem if available + if (this.biomeSystem && this.chunkManager) { + console.log('🌍 Using BiomeSystem for chunk-based terrain generation'); + // Biome-based generation will happen via ChunkManager + // No need to generate full map here! + + // Create simple grass background as fallback + this.createBiomeBackground(); } else { - console.error('❌ Map2DData not loaded!'); - this.createFallbackMap(); + // Fallback to old Map2DData system + console.log('📊 Using Map2DData for terrain generation (fallback)'); + + // Load map data + if (typeof Map2DData !== 'undefined') { + this.tiles = Map2DData.generateMap(); + console.log('✅ Map data generated:', this.tiles.length, 'rows'); + } else { + console.error('❌ Map2DData not loaded!'); + this.createFallbackMap(); + } + + // Render the old-style map + this.renderMap(); } - // Render the map - this.renderMap(); - console.log('✅ Flat 2D map ready!'); } + // 🌍 PHASE 28: Create simple biome-aware background + createBiomeBackground() { + const size = this.tileSize; + const mapWidth = this.width * size; + const mapHeight = this.height * size; + + console.log('🎨 Creating biome-aware background...'); + + // Create solid background (will be covered by chunks) + const background = this.scene.add.rectangle(0, 0, mapWidth, mapHeight, 0x3CB371); + background.setOrigin(0, 0); + background.setDepth(0); + + // Create containers for chunks + this.pathsLayer = this.scene.add.container(0, 0); + this.pathsLayer.setDepth(2); + + this.decorLayer = this.scene.add.container(0, 0); + this.decorLayer.setDepth(3); + + this.groundLayer = background; + + console.log('✅ Biome background created, ready for chunks'); + } + createTileTextures() { // 🎨 Create SOLID, OPAQUE tiles (no transparency!)