stanje 4am

This commit is contained in:
2025-12-07 04:19:57 +01:00
parent 521468c797
commit 03a9cd46a2
20 changed files with 619 additions and 168 deletions

View File

@@ -11,10 +11,7 @@ class DayNightSystem {
}
init() {
// Create lighting overlay
this.overlay = this.scene.add.graphics();
this.overlay.setDepth(4999); // Below weather, above everything else
this.overlay.setScrollFactor(0); // Fixed to camera
// No local overlay - using UIScene.overlayGraphics
}
update() {
@@ -32,17 +29,24 @@ class DayNightSystem {
}
getPhase(hour) {
if (hour >= 5 && hour < 7) return 'dawn'; // 5-7
if (hour >= 7 && hour < 18) return 'day'; // 7-18
if (hour >= 18 && hour < 20) return 'dusk'; // 18-20
return 'night'; // 20-5
if (hour >= 5 && hour < 7) return 'dawn';
if (hour >= 7 && hour < 18) return 'day';
if (hour >= 18 && hour < 20) return 'dusk';
return 'night';
}
updateLighting(hour) {
const width = this.scene.cameras.main.width;
const height = this.scene.cameras.main.height;
// Get Shared Overlay from UI Scene
const uiScene = this.scene.scene.get('UIScene');
if (!uiScene || !uiScene.overlayGraphics) return;
this.overlay.clear();
const graphics = uiScene.overlayGraphics;
// IMPORTANT: DayNight is the FIRST system to render to overlay, so it MUST CLEAR it.
graphics.clear();
const width = uiScene.scale.width;
const height = uiScene.scale.height;
let color = 0x000033; // Default night blue
let alpha = 0;
@@ -72,8 +76,8 @@ class DayNightSystem {
}
if (alpha > 0) {
this.overlay.fillStyle(color, alpha);
this.overlay.fillRect(0, 0, width, height);
graphics.fillStyle(color, alpha);
graphics.fillRect(0, 0, width, height);
}
}